[PATCH v2 1/2] ASoC: cs35l41: CS35L41 Boosted Smart Amplifier
David Rhodes
drhodes at opensource.cirrus.com
Fri Jul 2 17:23:52 CEST 2021
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:
>>>> +static irqreturn_t cs35l41_irq(int irq, void *data)
>>>> +{
>>>> + struct cs35l41_private *cs35l41 = data;
>>>> + unsigned int status[4] = {0, 0, 0, 0};
>>>> + unsigned int masks[4] = {0, 0, 0, 0};
>
>>> are those inits necessary, you override them below with the regmap reads?
>
>> This one gets flagged by static analyzers so I'd like to keep the inits
>
> That sounds like you have an actual issue and you're just shutting up
> the static analysers, not fixing whatever they were telling you.
>
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.
More information about the Alsa-devel
mailing list