[PATCH] fix comparison of unsigned expression < 0
Andrey Konovalov
andreyknvl at gmail.com
Wed Dec 13 07:31:35 PST 2023
On Mon, Dec 4, 2023 at 5:12 AM Dan Carpenter <dan.carpenter at linaro.org> wrote:
>
> > But I actually don't think we need to fix anything here.
> >
> > This issue looks quite close to a similar comparison with 0 issue
> > Linus shared his opinion on here:
> >
> > https://lore.kernel.org/all/Pine.LNX.4.58.0411230958260.20993@ppc970.osdl.org/
> >
> > I don't know if the common consensus with the regard to issues like
> > that changed since then. But if not, perhaps we can treat this kernel
> > test robot report as a false positive.
>
> I would say that the consensus has changed somewhere around 2015 or
> so. Unsigned comparisons to zero used to be one of the most common
> types of bugs in new code but now almost all subsystems have turned on
> the GCC warning for this.
>
> However, this is a Smatch warning and I agree with Linus on this. For
> example, Smatch doesn't complain about the example code the Linus
> mentioned.
>
> if (a < 0 || a > X)
>
> And in this case, it's a one liner fix for me to add KASAN_SHADOW_OFFSET
> as an allowed macro and silence the warning.
Hi Dan,
If this sounds like a good idea to you, please add an exception.
>From the KASAN side, I think adding an exception for this case makes sense.
Thank you!
More information about the Linux-mediatek
mailing list