Initialise the fetch-into-temporary locals - #30
Open
heitbaum wants to merge 1 commit into
Open
Conversation
Fetch() writes its out-parameter only when it returns true, and SetFieldIf() passes that result straight through, so the temporaries are never actually read uninitialised. gcc does not carry that correlation across the out-of-line SetFieldIf() call though, and gcc 16 warns on all six sites: TinyEXIF.cpp:895:51: warning: 'altitudeRef' may be used uninitialized TinyEXIF.cpp:765:62: warning: '_FocalLengthIn35mm' may be used uninitialized TinyEXIF.cpp:727:47: warning: '_ImageHeight' may be used uninitialized TinyEXIF.cpp:718:46: warning: '_ImageWidth' may be used uninitialized TinyEXIF.cpp:560:53: warning: '_RelatedImageWidth' may be used uninitialized TinyEXIF.cpp:569:54: warning: '_RelatedImageHeight' may be used uninitialized Give the temporaries an initial value. altitudeRef is declared directly under "case 5:", where an initialiser would make the jumps to the later case labels cross an initialisation, so scope it in a block covering just the declaration and its use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
gcc 16 warns
-Wmaybe-uninitializedon all six fetch-into-temporary sites inTinyEXIF.cpp:They are false positives.
Fetch()writes its out-parameter only on thereturn truepath, andSetFieldIf()returnsfetchedunchanged, so a temporary is only read when it was written:gcc just doesn't carry that correlation across the out-of-line
SetFieldIf()call. Initialising the temporaries costs nothing and silences the diagnostic.altitudeRefneeds one extra step: it is declared directly undercase 5:with no enclosing block, so adding an initialiser there would make the jumps tocase 6:and the later labels cross an initialisation (the declaration is legal today only because it has vacuous initialisation). It is wrapped in a block covering just the declaration and its use, leaving thecase 5:label and itsbreak;exactly as they are.Found building the vendored copy of TinyEXIF in xbmc/imagedecoder.heif (synced to 8c22aff) with gcc 16.2.0 for LibreELEC.