From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: osandov@osandov.com
Subject: [PATCH 1/4] btrfs-progs: check/lowmem: Fix a false alert on uninitialized value
Date: Mon, 18 Nov 2019 14:30:49 +0800 [thread overview]
Message-ID: <20191118063052.56970-2-wqu@suse.com> (raw)
In-Reply-To: <20191118063052.56970-1-wqu@suse.com>
[BUG]
When compiling the devel branch with commit fb8f05e40b458
("btrfs-progs: check: Make repair_imode_common() handle inodes in
subvolume trees"), the following warning will be reported:
check/mode-common.c: In function ‘detect_imode’:
check/mode-common.c|1071 col 23| warning: ‘imode’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1071 | *imode_ret = (imode | 0700);
| ~~~~~~~^~~~~~~
This only occurs for regular build. If compiled with D=1, the warning
just disappears.
[CAUSE]
Looks like a bug in gcc optimization.
The code will only set @imode_ret when @found is true.
And for every "found = true" assignment we have assigned @imode.
So this is just a false alert.
[FIX]
I hope I can fix the problem of GCC, but obviously I can't (at least for
now).
So let's assign an initial value 0 to @imode to suppress the false
alert.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
check/mode-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check/mode-common.c b/check/mode-common.c
index 10ad6d228a03..9e81082b10aa 100644
--- a/check/mode-common.c
+++ b/check/mode-common.c
@@ -972,7 +972,7 @@ int detect_imode(struct btrfs_root *root, struct btrfs_path *path,
struct btrfs_inode_item iitem;
bool found = false;
u64 ino;
- u32 imode;
+ u32 imode = 0;
int ret = 0;
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
--
2.24.0
next prev parent reply other threads:[~2019-11-18 6:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-18 6:30 [PATCH 0/4] btrfs-progs: Compiling warning fixes for devel branch Qu Wenruo
2019-11-18 6:30 ` Qu Wenruo [this message]
2019-11-18 6:30 ` [PATCH 2/4] btrfs-progs: libbtrfsutil: Convert to designated initialization for BtrfsUtilError_type Qu Wenruo
2019-11-18 6:30 ` [PATCH 3/4] btrfs-progs: libbtrfsutil: Convert to designated initialization for QgroupInherit_type Qu Wenruo
2019-11-18 6:30 ` [PATCH 4/4] btrfs-progs: libbtrfsutil: Convert to designated initialization for SubvolumeIterator_type Qu Wenruo
2019-11-18 8:23 ` [PATCH 0/4] btrfs-progs: Compiling warning fixes for devel branch Nikolay Borisov
2019-11-18 18:10 ` David Sterba
2019-11-18 18:27 ` Omar Sandoval
2019-11-18 23:47 ` Qu WenRuo
2019-11-19 20:38 ` Omar Sandoval
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=20191118063052.56970-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=osandov@osandov.com \
/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;
as well as URLs for NNTP newsgroup(s).