Fix [-Wuninitialized] warning in sr_port/repl_filter.c from gcc 12.1
-
The below is a warning we started seeing in Release builds of YottaDB when compiled with gcc 12.1.
sr_port/repl_filter.c: In function 'jnl_v44TOv22': sr_port/repl_filter.c:1262:49: warning: 'this_strm_seqno' is used uninitialized [-Wuninitialized] 1262 | seq_num this_upd_seqno, this_strm_seqno; | ^~~~~~~~~~~~~~~
-
The variable
this_strm_seqno
is set inside awhile()
loop and used later outside the loop under a different set ofif
conditions. And this is probably what triggered the alert. But in my understanding it is not possible in practice to reach the later use of the variable with an uninitialized value. I suspect this is a false alert from the compiler. -
That said, the
jnl_v44TOv22
function (where this warning now shows up) is anyways used only in rare cases (when replicating from YottaDB r1.24 onwards to a GT.M version V5.5-000 thru V6.1-000). -
Therefore the fix approach chosen in this commit is to set
this_strm_seqno
to 0 at the start of this function. And that silences the warning. -
Interestingly,
clang-tidy
had also triggered a warning for this same code path a while ago and this was included as an expected warning in the following reference files. This expected warning no longer shows up inclang-tidy
and is now removed as part of this commit.- ci/tidy_warnings_debug.ref
- ci/tidy_warnings_release.ref