]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_io: fix gcc complaints about potentially uninitialized variables
authorDarrick J. Wong <djwong@kernel.org>
Sun, 2 Jun 2024 23:33:17 +0000 (16:33 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:43 +0000 (11:37 -0700)
commitcaf4117df8a8787239df053d331546166812b0d0
treecef06d2b0acd8b4411e14a23795b7648c2a8a99f
parent9a51e91a017bf285ea5fd5c5a6a7534e2ca56587
xfs_io: fix gcc complaints about potentially uninitialized variables

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
io/bulkstat.c