sg3_utils
sg3_utils copied to clipboard
Uninitialized warning when building testsuite
In building the testsuite on a few different architectures, I noticed a warning on s390x that might be worth consideration:
221s sg_scat_gath.cpp: In member function ‘int scat_gath_list::append_1or(int64_t, int64_t)’: 221s sg_scat_gath.cpp:603:23: warning: ‘sge.scat_gath_elem::lba’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~ 221s sg_scat_gath.cpp:603:33: warning: ‘sge.scat_gath_elem::num’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~ 221s sg_scat_gath.cpp:603:23: warning: ‘sge.scat_gath_elem::lba’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~ 221s sg_scat_gath.cpp:603:33: warning: ‘sge.scat_gath_elem::num’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~ 221s sg_scat_gath.cpp:603:23: warning: ‘sge.scat_gath_elem::lba’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~ 221s sg_scat_gath.cpp:603:33: warning: ‘sge.scat_gath_elem::num’ may be used uninitialized [-Wmaybe-uninitialized] 221s 603 | high_lba_p1 = sge.lba + sge.num; 221s | ~~~~^~~ 221s sg_scat_gath.cpp:563:26: note: ‘sge’ declared here 221s 563 | class scat_gath_elem sge; 221s | ^~~
I'm not entirely sure why this warning shows only on s390x, but the logic in logic in scat_gath_list::append_1or() it looks like it takes INT32_MAX into consideration, so perhaps the value on s390x is causing a clause to be skipped?
I was able to work around it by manually initializing the flagged structure members, but this may be only papering over whatever the real issue is:
@@ -562,6 +562,8 @@ scat_gath_list::append_1or(int64_t extra_blks, int64_t start_lba)
const int max_nbs = MAX_SGL_NUM_VAL;
int64_t cnt = 0;
class scat_gath_elem sge;
-
sge.lba = 0;
-
sge.num = 0;
if ((extra_blks <= 0) && (start_lba < 0))
return o_num; /* nothing to do */