Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 11, 2017 at 01:20:23PM +0200, Andy Shevchenko wrote:
> On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> > I get a Smatch warning here:
> > 
> >     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
> >     error: testing array offset 'j' after use.
> > 
> > The code is harmless, but the checker is right that we should swap
> > these
> > two conditions so we verify that the offset is within bounds before we
> > use it.
> 
> > -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> > -				(j < SKL_MAX_CLK_RATES); j++) {
> > +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> > +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
> >  			if (sclk[id].rate_cfg[j].rate == rate) {
> >  				present = true;
> >  				break;
> 
> I would rather remove also redundant parens and move the condition into
> the loop.

I didn't like the way the code was written either but it's impossible
to know how much change people are going to accept.  Even though I think
that extra parenthesis shouldn't have been there, the original author
felt they helped, so I try to be accomodating...

Anyway, I can resend.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux