From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: David Rhodes <drhodes@opensource.cirrus.com>
Cc: robh@kernel.org, brian.austin@cirrus.com,
alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
david.rhodes@cirrus.com, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 1/2] ASoC: cs35l41: CS35L41 Boosted Smart Amplifier
Date: Mon, 12 Jul 2021 08:32:53 +0000 [thread overview]
Message-ID: <20210712083253.GG9223@ediswmail.ad.cirrus.com> (raw)
In-Reply-To: <2a795a56-0b3d-069b-b31d-b8cee0b89f4f@opensource.cirrus.com>
On Fri, Jul 02, 2021 at 10:23:52AM -0500, David Rhodes wrote:
> On 7/2/21 7:08 AM, Mark Brown wrote:
> >On Thu, Jul 01, 2021 at 03:22:53PM -0500, David Rhodes wrote:
> >>On 6/29/21 6:51 PM, Pierre-Louis Bossart wrote:
> On 6/29/21 5:27 PM, David Rhodes wrote:
> > + unsigned int status[4] = {0, 0, 0, 0};
> > + unsigned int masks[4] = {0, 0, 0, 0};
> > + unsigned int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(status); i++) {
> > + regmap_read(cs35l41->regmap,
> > + CS35L41_IRQ1_STATUS1 + (i * CS35L41_REGSTRIDE),
> > + &status[i]);
> > + regmap_read(cs35l41->regmap,
> > + CS35L41_IRQ1_MASK1 + (i * CS35L41_REGSTRIDE),
> > + &masks[i]);
> > + }
>
> Pierre is correct that both arrays will always be fully initialized
> with regmap reads in the loop before any other access.
> Without the explicit initialization, an analyzer that is not as
> smart as Pierre will tell me that the array values can be used
> uninitialized later on.
> Presumably the tool does not unroll the loop to see that every array
> value is assigned.
>
> So I don't think I have an actual issue, but I am just shutting up
> the static analyzers, although I do think I fixed what they were
> telling me.
This isn't quite correct the static analyser is flagging a real
issue here. The issue is because the return values from the
regmap_reads are not checked, if regmap_read fails then that
index in the array would not be initialised and then gets used
later. Now if the read failing isn't a situation the drive is
bothered about initalising to zero is probably fine. So I guess it
doesn't feel to me that the code particularly needs changed here,
but certainly the warning if you remove the initialisations is real.
Thanks,
Charles
next prev parent reply other threads:[~2021-07-12 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 22:27 [PATCH v2 0/2] Cirrus Logic CS35L41 Amplifier David Rhodes
2021-06-29 22:27 ` [PATCH v2 1/2] ASoC: cs35l41: CS35L41 Boosted Smart Amplifier David Rhodes
2021-06-29 23:51 ` Pierre-Louis Bossart
2021-06-30 21:35 ` David Rhodes
2021-07-01 11:54 ` Pierre-Louis Bossart
2021-07-01 20:22 ` David Rhodes
2021-07-02 12:08 ` Mark Brown
2021-07-02 15:23 ` David Rhodes
2021-07-02 15:48 ` Mark Brown
2021-07-02 15:52 ` David Rhodes
2021-07-12 8:32 ` Charles Keepax [this message]
2021-06-29 22:27 ` [PATCH v2 2/2] ASoC: cs35l41: Add bindings for CS35L41 David Rhodes
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=20210712083253.GG9223@ediswmail.ad.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=brian.austin@cirrus.com \
--cc=broonie@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=drhodes@opensource.cirrus.com \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=robh@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 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.