* [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
* Re: [PATCH] fsstress: fix bogus compile warning do_renameat2()
2021-09-21 17:50 [PATCH] fsstress: fix bogus compile warning do_renameat2() Luis Chamberlain
@ 2021-09-22 17:24 ` Brian Foster
0 siblings, 0 replies; 2+ messages in thread
From: Brian Foster @ 2021-09-22 17:24 UTC (permalink / raw)
To: Luis Chamberlain; +Cc: fstests, kaixuxia
On Tue, Sep 21, 2021 at 10:50:59AM -0700, Luis Chamberlain wrote:
> 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.
>
https://www.urbandictionary.com/define.php?term=shup
Huh. :P
> 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>
> 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 [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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).