All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsstress: fix bogus compile warning do_renameat2()
@ 2021-09-21 17:50 Luis Chamberlain
  2021-09-22 17:24 ` Brian Foster
  0 siblings, 1 reply; 2+ messages in thread
From: Luis Chamberlain @ 2021-09-21 17:50 UTC (permalink / raw)
  To: fstests; +Cc: Luis Chamberlain, kaixuxia, Brian Foster

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.

Cc: kaixuxia <kaixuxia@tencent.com>
Cc: Brian Foster <bfoster@redhat.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 ltp/fsstress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index d2f09901..0d620d7b 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-22 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-21 17:50 [PATCH] fsstress: fix bogus compile warning do_renameat2() Luis Chamberlain
2021-09-22 17:24 ` Brian Foster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.