From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] xfs_io: fix gcc complaints about potentially uninitialized variables
Date: Fri, 31 May 2024 13:12:22 -0700 [thread overview]
Message-ID: <20240531201222.GS52987@frogsfrogsfrogs> (raw)
From: Darrick J. Wong <djwong@kernel.org>
When I turned on UBSAN on the userspace build with gcc 12.2, I get this:
bulkstat.c: In function ‘bulkstat_single_f’:
bulkstat.c:316:24: error: ‘ino’ may be used uninitialized [-Werror=maybe-uninitialized]
316 | ret = -xfrog_bulkstat_single(&xfd, ino, flags, &bulkstat);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bulkstat.c:293:41: note: ‘ino’ was declared here
293 | uint64_t ino;
| ^~~
I /think/ this is a failure of the gcc static checker to notice that sm
will always be set to the last element of the tags[] array if it didn't
set ino, but this code could be more explicit about deciding to
fallback to strtoul.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
io/bulkstat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io/bulkstat.c b/io/bulkstat.c
index 829f6a025153..f312c6d55f47 100644
--- a/io/bulkstat.c
+++ b/io/bulkstat.c
@@ -301,7 +301,7 @@ bulkstat_single_f(
for (i = optind; i < argc; i++) {
struct single_map *sm = tags;
- uint64_t ino;
+ uint64_t ino = NULLFSINO;
unsigned int flags = 0;
/* Try to look up our tag... */
@@ -314,7 +314,7 @@ bulkstat_single_f(
}
/* ...or else it's an inode number. */
- if (sm->tag == NULL) {
+ if (ino == NULLFSINO) {
errno = 0;
ino = strtoull(argv[i], NULL, 10);
if (errno) {
next reply other threads:[~2024-05-31 20:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 20:12 Darrick J. Wong [this message]
2024-06-01 5:02 ` [PATCH] xfs_io: fix gcc complaints about potentially uninitialized variables Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240531201222.GS52987@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox