Re: fs/xfs/xfs_buf.c:1534 xfs_buf_submit_bio() warn: unsigned '_x' is never less than zero.

From: Philip Li
Date: Mon Feb 17 2025 - 19:39:50 EST


+ Dan

Hi Dan,

On Mon, Feb 17, 2025 at 01:12:03PM +0000, David Laight wrote:
> On Mon, 17 Feb 2025 13:06:49 +0100
> Alexandre Ghiti <alex@xxxxxxxx> wrote:
>
> > Hi Christoph,
> >
> > On 17/02/2025 10:24, Christoph Hellwig wrote:
> > > On Mon, Feb 17, 2025 at 01:53:08PM +0800, kernel test robot wrote:
> > >> New smatch warnings:
> > >> fs/xfs/xfs_buf.c:1534 xfs_buf_submit_bio() warn: unsigned '_x' is never less than zero.
> > > Looks like this is an issue in the riscv virt_to_page implementation
> > > which also shows up in various other places. Any chance this could get
> > > fixed in the riscv code?
> >
> >
> > To me, the only test that could give rise to this warning is the last
> > part of:
> >
> > #define is_linear_mapping(x) \
> >         ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) <
> > PAGE_OFFSET + KERN_VIRT_SIZE))
> >
> > But given that the config is a 32-bit config, it should not be evaluated
> > at all.
> >
> > Could that be a false-positive and then an issue in smatch?
>
> Why is smatch even looking.
> The equivalent check in gcc has been moved to -W2 because of all false positives.

Can you help check this one?

Thanks

>
> David
>