mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH -next] io_uring: Ensure mask is initialized in io_arm_poll_handler
Date: Mon, 2 Mar 2020 16:12:48 -0700	[thread overview]
Message-ID: <afe86a1d-dcc4-856e-48ea-f12761036e98@kernel.dk> (raw)
In-Reply-To: <20200302230118.12060-1-natechancellor@gmail.com>

On 3/2/20 4:01 PM, Nathan Chancellor wrote:
> Clang warns:
> 
> fs/io_uring.c:4178:6: warning: variable 'mask' is used uninitialized
> whenever 'if' condition is false [-Wsometimes-uninitialized]
>         if (def->pollin)
>             ^~~~~~~~~~~
> fs/io_uring.c:4182:2: note: uninitialized use occurs here
>         mask |= POLLERR | POLLPRI;
>         ^~~~
> fs/io_uring.c:4178:2: note: remove the 'if' if its condition is always
> true
>         if (def->pollin)
>         ^~~~~~~~~~~~~~~~
> fs/io_uring.c:4154:15: note: initialize the variable 'mask' to silence
> this warning
>         __poll_t mask, ret;
>                      ^
>                       = 0
> 1 warning generated.
> 
> io_op_defs has many definitions where pollin is not set so mask indeed
> might be uninitialized. Initialize it to zero and change the next
> assignment to |=, in case further masks are added in the future to avoid
> missing changing the assignment then.
> 
> Fixes: d7718a9d25a6 ("io_uring: use poll driven retry for files that support it")
> Link: https://github.com/ClangBuiltLinux/linux/issues/916
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> 
> I noticed that for-next has been force pushed; if you want to squash
> this into the commit that it fixes (or fix it in a different way), feel
> free.

Great thanks, applied. I wonder why gcc doesn't warn about that...

-- 
Jens Axboe


      reply	other threads:[~2020-03-02 23:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 23:01 Nathan Chancellor
2020-03-02 23:12 ` Jens Axboe [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=afe86a1d-dcc4-856e-48ea-f12761036e98@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=clang-built-linux@googlegroups.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.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

all inboxes | Powered by JetHome®