Skip to contentSkip to conversation

fsstress: fix bogus compile warning do_renameat2()

PATCH In review Luis Chamberlain 2 participants 2 messages Sep 21, 2021 – Sep 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsstress: fix bogus compile warning do_renameat2()

gcc complains with:

fsstress.c:4629:4: warning: 'oldparid' may be used uninitialized in this function [-Wmaybe-uninitialized]

 4629 |    printf("%d/%d: rename source entry: id=%d,parent=%d\n",
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4630 |     procid, opno, oldid, oldparid);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fsstress.c:4629:4: warning: 'oldid' may be used uninitialized in this function [-Wmaybe-uninitialized]

But the varaibles are sure to be initialized, it is just that the heuristics are broken since another check is used later which confuses gcc. So just initialize the variables, to shup the compile warning.

---
 ltp/fsstress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ltp/fsstress.c +2 -2
index d2f09901..0d620d7b 100644
@@ -4517,9 +4517,9 @@ do_renameat2(int opno, long r, int mode)
 	flist_t		*flp;
 	int		id;
 	pathname_t	newf;
-	int		oldid;
+	int		oldid = 0;
 	int		parid;
-	int		oldparid;
+	int		oldparid = 0;
 	int		which;
 	int		v;
 	int		v1;
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Luis Chamberlain

gcc complains with:

fsstress.c:4629:4: warning: 'oldparid' may be used uninitialized in this function [-Wmaybe-uninitialized]

 4629 |    printf("%d/%d: rename source entry: id=%d,parent=%d\n",
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4630 |     procid, opno, oldid, oldparid);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines

fsstress.c:4629:4: warning: 'oldid' may be used uninitialized in this function [-Wmaybe-uninitialized]

But the varaibles are sure to be initialized, it is just that the heuristics are broken since another check is used later which confuses gcc. So just initialize the variables, to shup the compile warning.

https://www.urbandictionary.com/define.php?term=shup

Huh. :P

Quoted 4 lines

---

Quoted 22 lines
 ltp/fsstress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ltp/fsstress.c +2 -2
index d2f09901..0d620d7b 100644
@@ -4517,9 +4517,9 @@ do_renameat2(int opno, long r, int mode)
 	flist_t		*flp;
 	int		id;
 	pathname_t	newf;
-	int		oldid;
+	int		oldid = 0;
 	int		parid;
-	int		oldparid;
+	int		oldparid = 0;
 	int		which;
 	int		v;
 	int		v1;
Signature · 1 line
2.30.2