fsstress: fix bogus compile warning do_renameat2()
authorLuis Chamberlain <mcgrof@kernel.org>
Tue, 21 Sep 2021 17:50:59 +0000 (10:50 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 26 Sep 2021 12:48:24 +0000 (20:48 +0800)
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>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsstress.c

index b4ddf5e2ef35eadf578d4e38649c4641da9fa7bf..90ae432e789e8ecffbb244e23383ab596196531a 100644 (file)
@@ -4504,9 +4504,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;