mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>,
	Lalit Shankar Chowdhury <lalitshankarch@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>, <ntfs3@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ntfs3: work around false-postive -Wmaybe-uninitialized warnings
Date: Tue, 24 Mar 2026 18:54:47 +0100	[thread overview]
Message-ID: <f4541308-7233-46dc-aa9a-3c05f4d0ba25@paragon-software.com> (raw)
In-Reply-To: <20260312164939.946523-1-arnd@kernel.org>

On 3/12/26 17:49, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> gcc sometimes fails to analyse how two local variables in ntfs_write_bh()
> are initialized, as the initialization happens only in the first pass
> through the main loop:
>
> fs/ntfs3/fsntfs.c: In function 'ntfs_write_bh':
> fs/ntfs3/fsntfs.c:1443:17: error: 'fixup' may be used uninitialized [-Werror=maybe-uninitialized]
>   1443 |         __le16 *fixup;
>        |                 ^~~~~
> fs/ntfs3/fsntfs.c:1443:17: note: 'fixup' was declared here
>   1443 |         __le16 *fixup;
>        |                 ^~~~~
> fs/ntfs3/fsntfs.c:1487:30: error: 'sample' may be used uninitialized [-Werror=maybe-uninitialized]
>   1487 |                         *ptr = sample;
>        |                         ~~~~~^~~~~~~~
> fs/ntfs3/fsntfs.c:1444:16: note: 'sample' was declared here
>   1444 |         __le16 sample;
>
> Initializing the two variables to bogus values shuts up the warning and
> makes it clear that those cannot be used. I tried rearranging the loop to
> move the initialization in front of it, but couldn't quite figure it out.
>
> Fixes: 48d9b57b169f ("fs/ntfs3: add a subset of W=1 warnings for stricter checks")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> I don't know how the set of warnings for ntfs3 was picked, this seems to
> be based on what W=1 used to do many years ago. -Wmaybe-uninitialized is
> no longer part of it, and some of the other warnings enabled here are
> turned on by default now.
> ---
>   fs/ntfs3/fsntfs.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> index 0df2aa81d884..d0434756029b 100644
> --- a/fs/ntfs3/fsntfs.c
> +++ b/fs/ntfs3/fsntfs.c
> @@ -1440,8 +1440,8 @@ int ntfs_write_bh(struct ntfs_sb_info *sbi, struct NTFS_RECORD_HEADER *rhdr,
>   	u16 fo = le16_to_cpu(rhdr->fix_off);
>   	u16 fn = le16_to_cpu(rhdr->fix_num);
>   	u32 idx;
> -	__le16 *fixup;
> -	__le16 sample;
> +	__le16 *fixup = NULL;
> +	__le16 sample = cpu_to_le16(-1u);
>   
>   	if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_SIZE || !fn-- ||
>   	    fn * SECTOR_SIZE > bytes) {

Hello,

Thanks for the patch, applied.

Regards,
Konstantin


      reply	other threads:[~2026-03-24 17:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 16:49 Arnd Bergmann
2026-03-24 17:54 ` Konstantin Komarov [this message]

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=f4541308-7233-46dc-aa9a-3c05f4d0ba25@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=lalitshankarch@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=rpthibeault@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®