Fix GCC 16 warnings in silk/float/pitch_analysis_core_FLP.c#461
Open
Nicolas0315 wants to merge 1 commit intoxiph:mainfrom
Open
Fix GCC 16 warnings in silk/float/pitch_analysis_core_FLP.c#461Nicolas0315 wants to merge 1 commit intoxiph:mainfrom
Nicolas0315 wants to merge 1 commit intoxiph:mainfrom
Conversation
Fix two compiler warnings reported with GCC 16 (issue xiph#451): 1. -Wmaybe-uninitialized for 'frame_8_FIX': GCC cannot prove that frame_8_FIX is always initialized before use, even though all three branches of the Fs_kHz conditional write to it. Zero-initialize the array to silence the warning. The cost is negligible (640 bytes, called once per pitch analysis). 2. -Wstringop-overflow for silk_memset on C[]: The size expression 'sizeof(silk_float) * nb_subfr * ((PE_MAX_LAG >> 1) + 5)' involves signed int 'nb_subfr' multiplied with unsigned size_t from sizeof. GCC 16 warns that the intermediate result could theoretically be negative and wrap to a huge value. Cast nb_subfr to size_t to make the arithmetic unambiguously unsigned. Fixes: xiph#451
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.
Fix two compiler warnings reported in #451 when building with GCC 16:
1.
-Wmaybe-uninitializedforframe_8_FIXGCC 16 cannot prove that
frame_8_FIXis always initialized before use at line 157 (silk_resampler_down2call), even though all three branches of theFs_kHzconditional (16, 12, 8) write to it before the common path reads it.Fix: Zero-initialize the array at declaration. The cost is negligible — 640 bytes (
PE_MAX_FRAME_LENGTH_MS * 8 * sizeof(opus_int16)=40 * 8 * 2), called once per pitch analysis invocation.2.
-Wstringop-overflowforsilk_memsetonC[]The size expression
sizeof(silk_float) * nb_subfr * ((PE_MAX_LAG >> 1) + 5)mixessize_t(fromsizeof) with signedopus_int(nb_subfr). GCC 16's improved overflow analysis warns that the intermediate product could theoretically be negative and wrap to a huge value (~UINT64_MAX), exceeding the maximum object size.Fix: Cast
nb_subfrtosize_tto make the arithmetic unambiguously unsigned.nb_subfris always positive (validated by the caller and bounded byPE_MAX_NB_SUBFR = 4).Fixes #451.