All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: Petr Mladek <pmladek@suse.com>
Cc: Arnd Bergmann <arnd@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	YueHaibing <yuehaibing@huawei.com>, Jessica Yu <jeyu@kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] [v2] printk: avoid -Wsometimes-uninitialized warning
Date: Mon, 4 Oct 2021 13:31:25 +0100	[thread overview]
Message-ID: <YVr0HRnfzttC/wqX@chrisdown.name> (raw)
In-Reply-To: <YVrH5MUdS6uE/zDj@alley>

Petr Mladek writes:
>On Tue 2021-09-28 11:17:26, Chris Down wrote:
>> Arnd Bergmann writes:
>> > From: Arnd Bergmann <arnd@arndb.de>
>> >
>> > clang notices that the pi_get_entry() function would use
>> > uninitialized data if it was called with a non-NULL module
>> > pointer on a kernel that does not support modules:
>> >
>> > kernel/printk/index.c:32:6: error: variable 'nr_entries' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>> >        if (!mod) {
>> >            ^~~~
>> > kernel/printk/index.c:38:13: note: uninitialized use occurs here
>> >        if (pos >= nr_entries)
>> >                   ^~~~~~~~~~
>> > kernel/printk/index.c:32:2: note: remove the 'if' if its condition is always true
>> >        if (!mod) {
>> >
>> > Rework the condition to make it clear to the compiler that we are always
>> > in the second case. Unfortunately the #ifdef is still required as the
>> > definition of 'struct module' is hidden when modules are disabled.
>> >
>> > Fixes: 337015573718 ("printk: Userspace format indexing support")
>>
>> This changelog should make it clear that this is theoretical and will never
>> actually happen, which is salient information for people who are considering
>> whether it should go in stable or similar.
>
>IMHO, the sentence "Rework the condition to make it clear that this
>is theoretical and will never actually happen" is rather clear.

Sounds good to me, thanks!

I guess it's unneeded at this point, but feel free to add:

Acked-by: Chris Down <chris@chrisdown.name>

>Well, I am not a native speaker.
>
>Anyway, I have pushed the patch into printk/linux.git, branch
>for-5.16.
>
>Best Regards,
>Petr

      reply	other threads:[~2021-10-04 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28  9:34 [PATCH] [v2] printk: avoid -Wsometimes-uninitialized warning Arnd Bergmann
2021-09-28 10:17 ` Chris Down
2021-10-04  9:22   ` Petr Mladek
2021-10-04 12:31     ` Chris Down [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=YVr0HRnfzttC/wqX@chrisdown.name \
    --to=chris@chrisdown.name \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=jeyu@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=yuehaibing@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.