From d341f9990885094bf6b4636d9327da5af2439307 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 2 Mar 2026 01:35:40 +0900 Subject: [PATCH] Fix GCC 16 warnings in silk/float/pitch_analysis_core_FLP.c Fix two compiler warnings reported with GCC 16 (issue #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: #451 --- silk/float/pitch_analysis_core_FLP.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/silk/float/pitch_analysis_core_FLP.c b/silk/float/pitch_analysis_core_FLP.c index 0530a8831..a01955a78 100644 --- a/silk/float/pitch_analysis_core_FLP.c +++ b/silk/float/pitch_analysis_core_FLP.c @@ -82,7 +82,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, opus_int i, k, d, j; silk_float frame_8kHz[ PE_MAX_FRAME_LENGTH_MS * 8 ]; silk_float frame_4kHz[ PE_MAX_FRAME_LENGTH_MS * 4 ]; - opus_int16 frame_8_FIX[ PE_MAX_FRAME_LENGTH_MS * 8 ]; + opus_int16 frame_8_FIX[ PE_MAX_FRAME_LENGTH_MS * 8 ] = {0}; opus_int16 frame_4_FIX[ PE_MAX_FRAME_LENGTH_MS * 4 ]; opus_int32 filt_state[ 6 ]; silk_float threshold, contour_bias; @@ -165,7 +165,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, /****************************************************************************** * FIRST STAGE, operating in 4 khz ******************************************************************************/ - silk_memset(C, 0, sizeof(silk_float) * nb_subfr * ((PE_MAX_LAG >> 1) + 5)); + silk_memset(C, 0, sizeof(silk_float) * (size_t)nb_subfr * ((PE_MAX_LAG >> 1) + 5)); target_ptr = &frame_4kHz[ silk_LSHIFT( sf_length_4kHz, 2 ) ]; for( k = 0; k < nb_subfr >> 1; k++ ) { /* Check that we are within range of the array */