Cleanup/Maintenance: Build warnings with Clang
Building the code with Clang v16 reveals some warnings that we do not see with gcc in our pipelines - most likely due to different defaults. Relevant ones are probably:
Wtautological-constant-out-of-range-compare
This particular one might actually be a bug? @venkateshsa
lib_enc/ivas_ism_param_enc.c:163:103: warning: result of comparison of constant 32768 with expression of type 'Word16' (aka 'short') is always true [-Wtautological-constant-out-of-range-compare]
163 | assert( ( power_ratios_m[b][m] >= ONE_IN_Q14 /* 0.5 in Q15 */ ) && ( power_ratios_m[b][m] <= ONE_IN_Q15 /* 1 in Q15 */ ) );
| ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
Wself-assign:
lib_enc/SNR_calc_fx.c:403:23: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
403 | snr_delta = snr_delta;
| ~~~~~~~~~ ^ ~~~~~~~~~
lib_enc/SNR_calc_fx.c:450:23: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
450 | snr_delta = snr_delta;
| ~~~~~~~~~ ^ ~~~~~~~~~
lib_enc/SNR_calc_fx.c:497:23: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
497 | snr_delta = snr_delta;
| ~~~~~~~~~ ^ ~~~~~~~~~
lib_enc/ivas_stereo_dft_td_itd.c:233:7: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
233 | g = g;
| ~ ^ ~
lib_enc/ivas_stereo_dft_td_itd.c:237:9: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
237 | nsr = nsr;
| ~~~ ^ ~~~
lib_enc/ivas_stereo_icbwe_enc.c:513:25: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
513 | slopeILD_fx = slopeILD_fx;
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~
lib_enc/ivas_mc_paramupmix_enc.c:996:23: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
996 | tmp_4 = tmp_4;
| ~~~~~ ^ ~~~~~
lib_enc/ivas_mc_paramupmix_enc.c:997:26: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
997 | exp_tmp4 = exp_tmp4;
| ~~~~~~~~ ^ ~~~~~~~~
lib_com/swb_bwe_com_lr_fx.c:211:13: warning: variable 'p_diff_peak_pos' set but not used [-Wunused-but-set-variable]
211 | Word16 *p_diff_peak_pos, *pm1_diff_peak_pos;
| ^
lib_com/lsf_tools_fx.c:3329:15: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
3329 | n = n;
| ~ ^ ~
lib_dec/ivas_masa_dec.c:2330:18: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
2330 | E_fx = E_fx;
| ~~~~ ^ ~~~~
lib_rend/ivas_mcmasa_ana.c:904:28: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
904 | surrCoh_fx = surrCoh_fx;
| ~~~~~~~~~~ ^ ~~~~~~~~~~
lib_rend/ivas_mcmasa_ana.c:1094:34: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
1094 | spreadCoh_fx = spreadCoh_fx;
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
lib_rend/ivas_mcmasa_ana.c:1103:34: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
1103 | spreadCoh_fx = spreadCoh_fx;
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
lib_rend/ivas_mcmasa_ana.c:1145:33: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
1145 | cohRatio_fx = cohRatio_fx;
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~
lib_rend/ivas_mcmasa_ana.c:1156:33: warning: explicitly assigning value of variable of type 'Word32' (aka 'int') to itself [-Wself-assign]
1156 | cohRatio_fx = cohRatio_fx;
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~
lib_dec/avq_dec_fx.c:276:20: warning: explicitly assigning value of variable of type 'Word16' (aka 'short') to itself [-Wself-assign]
276 | nq_est = nq_est;
| ~~~~~~ ^ ~~~~~~
lib_enc/swb_tbe_enc_fx.c:687:18: warning: variable 'k' set but not used [-Wunused-but-set-variable]
687 | Word16 i, j, k;
| ^
lib_enc/swb_bwe_enc_lr_fx.c:357:19: warning: variable 'ptr_predBuf_ni' set but not used [-Wunused-but-set-variable]
357 | const Word16 *ptr_predBuf_ni;
| ^
lib_dec/dec_uv_fx.c:47:19: warning: variable 'p_Aq_fx' set but not used [-Wunused-but-set-variable]
47 | const Word16 *p_Aq_fx;
| ^
Wunused-but-set-variable
lib_enc/swb_tbe_enc_fx.c:687:18: warning: variable 'k' set but not used [-Wunused-but-set-variable]
687 | Word16 i, j, k;
| ^
lib_enc/swb_bwe_enc_lr_fx.c:357:19: warning: variable 'ptr_predBuf_ni' set but not used [-Wunused-but-set-variable]
357 | const Word16 *ptr_predBuf_ni;
| ^
lib_dec/dec_uv_fx.c:47:19: warning: variable 'p_Aq_fx' set but not used [-Wunused-but-set-variable]
47 | const Word16 *p_Aq_fx;
| ^
Then, there are some which are probably less relevant, will just list them below. Imho, the above ones should be fixed and added to the build tests (by adding build test for clang, especially the Wself-assign warnings does not seem to be there in gcc v9).
Rest of warnings:
lib_enc/ivas_mct_core_enc.c:245:55: warning: suggest braces around initialization of subobject [-Wmissing-braces]
245 | Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { NULL };
| ^~~~
| { }
lib_enc/cod_tcx_fx.c:4239:30: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
4239 | if ( ( st->last_core == ACELP_CORE ) )
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
lib_enc/cod_tcx_fx.c:4239:30: note: remove extraneous parentheses around the comparison to silence this warning
4239 | if ( ( st->last_core == ACELP_CORE ) )
| ~ ^ ~
lib_enc/cod_tcx_fx.c:4239:30: note: use '=' to turn this equality comparison into an assignment
4239 | if ( ( st->last_core == ACELP_CORE ) )
| ^~
| =
lib_com/count.c:440:33: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
440 | void ClearNbTimeObjectsAreCalled()
| ^
| void
lib_com/count.c:452:30: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
452 | Word32 TotalWeightedOperation()
| ^
| void
lib_com/count.c:475:30: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
475 | Word32 DeltaWeightedOperation()
| ^
| void
1 warning generated.
lib_dec/core_dec_init_fx.c:1290:30: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
1290 | if ( ( st->ini_frame == 0 ) )
| ~~~~~~~~~~~~~~^~~~
lib_dec/core_dec_init_fx.c:1290:30: note: remove extraneous parentheses around the comparison to silence this warning
1290 | if ( ( st->ini_fr Compiling lib_dec/rst_dec_fx.c
lib_dec/dec_LPD_fx.c:451:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
451 | if ( ( st->core == ACELP_CORE ) )
| ~~~~~~~~~^~~~~~~~~~~~~
lib_dec/dec_LPD_fx.c:451:25: note: remove extraneous parentheses around the comparison to silence this warning
451 | if ( ( st->core == ACELP_CORE ) )
| ~ ^ ~
lib_dec/dec_LPD_fx.c:451:25: note: use '=' to turn this equality comparison into an assignment
451 | if ( ( st->core == ACELP_CORE ) )
| ^~
| =
lib_dec/core_dec_init_fx.c:1290:30: note: use '=' to turn this equality comparison into an assignment
1290 | if ( ( st->ini_frame == 0 ) )
| ^~
| =
lib_dec/core_dec_init_fx.c:1363:26: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
1363 | if ( ( st->ini_frame == 0 ) )
| ~~~~~~~~~~~~~~^~~~
lib_dec/core_dec_init_fx.c:1363:26: note: remove extraneous parentheses around the comparison to silence this warning
1363 | if ( ( st->ini_frame == 0 ) )
| ~ ^ ~
lib_dec/core_dec_init_fx.c:1363:26: note: use '=' to turn this equality comparison into an assignment
1363 | if ( ( st->ini_frame == 0 ) )
| ^~
| =
lib_dec/avq_dec_fx.c:187:39: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
187 | if ( ( nq[svOrder[j]] == 0 ) )
| ~~~~~~~~~~~~~~~^~~~
lib_dec/avq_dec_fx.c:187:39: note: remove extraneous parentheses around the comparison to silence this warning
187 | if ( ( nq[svOrder[j]] == 0 ) )
| ~ ^ ~
lib_dec/avq_dec_fx.c:187:39: note: use '=' to turn this equality comparison into an assignment
187 | if ( ( nq[svOrder[j]] == 0 ) )
| ^~