mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Cristian Marussi" <cristian.marussi@arm.com>,
	"Arnd Bergmann" <arnd@kernel.org>
Cc: "Sudeep Holla" <sudeep.holla@arm.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] firmware: arm_scmi: avoid returning uninialized data
Date: Fri, 16 Feb 2024 21:19:02 +0100	[thread overview]
Message-ID: <e880e5c4-143c-4c51-adc5-e517f319579e@app.fastmail.com> (raw)
In-Reply-To: <Zc-ZfgVbAvAZVrPu@pluto>

On Fri, Feb 16, 2024, at 18:21, Cristian Marussi wrote:
> On Fri, Feb 16, 2024 at 05:32:53PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> Clang notices that there is a code path through
>> scmi_powercap_notify_supported() that returns an
>> undefined value:
>> 
>
> thanks for looking at this, this series that I've just posted is still
> to be reviewd at all, so I would expect issues :D...BUT in this case I
> dont think that the clang report is valid since, inside the culprit
> function scmi_powercap_notify_supported(), a few lines before the
> reported usage of unitialized data there is a check (@line 816) on the
> 'bounds' of evt_id itself
>
> 	if (evt_id >= ARRAY_SIZE(evt_2_cmd) || src_id >= pi->num_domains)
> 		return false;
>
> so basically the mentioned if/else WILL be evaluated in some of its
> branches for sure and supported wont be uninitialized.
>
> Indeed, I removed from here (and from all the series) the explicit
> initialization at definition time right before posting the series.
>
> Having saidm that...maybe it is just brain-dead this approach of mine
> since it is able to fool clang & friends...I would add bACK an explicit
> initialization of supported all across this series in V2, if this
> sounds good to you.

I'm fine with any solution that avoids the warning. I usually
prefer the explicit assignment where it's needed over having
it as part of the declaration, and in this case I would
probably pick a switch/case of a set of if/else fi/else
blocks

     Arnd

      reply	other threads:[~2024-02-16 20:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16 16:32 Arnd Bergmann
2024-02-16 17:21 ` Cristian Marussi
2024-02-16 20:19   ` Arnd Bergmann [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=e880e5c4-143c-4c51-adc5-e517f319579e@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=justinstitt@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sudeep.holla@arm.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®