From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Cc: geert@linux-m68k.org
Subject: Re: [PATCH] btrfs: initialize location to fix -Wmaybe-uninitialized in btrfs_lookup_dentry()
Date: Tue, 30 Jul 2024 07:04:36 +0930 [thread overview]
Message-ID: <92c6004f-9742-4abc-91bc-347cccaa44b9@gmx.com> (raw)
In-Reply-To: <20240729200608.10722-1-dsterba@suse.com>
在 2024/7/30 05:36, David Sterba 写道:
> Some arch + compiler combinations report a potentially unused variable
> location in btrfs_lookup_dentry(). This is a false alert as the variable
> is passed by value and always valid or there's an error. The compilers
> cannot probably reason about that although btrfs_inode_by_name() is in
> the same file.
>
> > + /kisskb/src/fs/btrfs/inode.c: error: 'location.objectid' may be used
> +uninitialized in this function [-Werror=maybe-uninitialized]: => 5603:9
> > + /kisskb/src/fs/btrfs/inode.c: error: 'location.type' may be used
> +uninitialized in this function [-Werror=maybe-uninitialized]: => 5674:5
>
> m68k-gcc8/m68k-allmodconfig
> mips-gcc8/mips-allmodconfig
> powerpc-gcc5/powerpc-all{mod,yes}config
> powerpc-gcc5/ppc64_defconfig
>
> Initialize it to zero, this should fix the warnings and won't change the
> behaviour as btrfs_inode_by_name() accepts only a root or inode item
> types, otherwise returns an error.
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/linux-btrfs/bd4e9928-17b3-9257-8ba7-6b7f9bbb639a@linux-m68k.org/
> Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Although I hate to update our code for bad compilers, I guess it's
unavoidable anyway.
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 32010127710d..333b0e8587a2 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5667,7 +5667,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
> struct inode *inode;
> struct btrfs_root *root = BTRFS_I(dir)->root;
> struct btrfs_root *sub_root = root;
> - struct btrfs_key location;
> + struct btrfs_key location = { 0 };
> u8 di_type = 0;
> int ret = 0;
>
next prev parent reply other threads:[~2024-07-29 21:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 20:06 [PATCH] btrfs: initialize location to fix -Wmaybe-uninitialized in btrfs_lookup_dentry() David Sterba
2024-07-29 21:34 ` Qu Wenruo [this message]
2024-07-29 22:06 ` David Sterba
2024-07-30 7:09 ` Geert Uytterhoeven
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=92c6004f-9742-4abc-91bc-347cccaa44b9@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=geert@linux-m68k.org \
--cc=linux-btrfs@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