lkml.org 
[lkml]   [2020]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 08/10] mfd: atmel-smc: Silence comparison of unsigned expression < 0 is always false warning (W=1)
On Fri, 26 Jun 2020, Alexandre Belloni wrote:

> Hi,
>
> On 25/06/2020 07:46:17+0100, Lee Jones wrote:
> > GENMASK and it's callees conduct checking to ensure the passed
> > parameters are valid. One of those checks is for '< 0'. So if an
> > unsigned value is passed, in an invalid comparison takes place.
> >
> > Judging from the current code, it looks as though 'unsigned int'
> > is the correct type to use, so simply cast these small values
> > with no chance of being false negative to signed int for
> > comparison/error checking purposes.
> >
>
> I've been thinking about that one but shouldn't the proper fix be in
> GENMASK? My understanding is that this happens because l is 0 and I
> don't think GENMASK would ever expect negative number. What about simply
> checking that h != l when l is 0?

Looks like Rikard Falkeborn recently submitted a patch to 'fix' this
issue. However, Linus slammed it, decrying that it's the warning
that's wrong, not the code. Looks like the type-limits warning might
be getting downgraded to W=2 instead (although I don't see a patch
yet).

I'm going to drop this patch.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

\
 
 \ /
  Last update: 2020-06-30 14:10    [W:0.066 / U:1.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site