Fix unused return value warnings which manifest as errors. #1396
+6
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should be the correct fix for the build issues that came up on recent ECH changes.
Background: Unless you install Clang and take steps to make it the default compiler, then on many Linux distributions (esp Ubuntu) the JNI code will get built with gcc.
gcc does not consider casting to void is sufficient to avoid a warning about unused returns from a function which has the warn_unused_result attribute.
This change assigns the result to a variable with the CONSCRYPT_UNUSED attribute which works correctly on Clang, gcc and MSVC.
As for why it's OK in these cases:
The asprintf methods should probably not ignore the value but they're calling FatalError with the result so it's game over anyway. This method could use re-writing but not this PR.
The read and write on fdsEmergency in native_crypto is part of an "interesting" mechanism to prevent blocking forever when using the ConscryptFileDescriptorSocket implementation, which ought to go away but works as-is.