Re: fs/erofs/zdata.c:198:22: sparse: sparse: non size-preserving integer to pointer cast

From: Luc Van Oostenryck
Date: Fri Aug 07 2020 - 11:05:34 EST


On Fri, Aug 07, 2020 at 10:48:12PM +0800, Gao Xiang wrote:
> On Fri, Aug 07, 2020 at 08:08:10PM +0800, kernel test robot wrote:
> > sparse warnings: (new ones prefixed by >>)
> >
> > >> fs/erofs/zdata.c:198:22: sparse: sparse: non size-preserving integer to pointer cast
> > fs/erofs/zdata.c:282:22: sparse: sparse: non size-preserving integer to pointer cast
> > fs/erofs/zdata.c:1094:24: sparse: sparse: non size-preserving integer to pointer cast
>
> I don't think these are valid warnings.

Indeed, they're not.

> All these three lines are using cmpxchg struct page * (which is equivalent to unsigned long
> in these cmpxchg macros) and nothing special at all in my opinion (Especially the last two
> lines).

What is special is that s390 use __sync_val_compare_and_swap() to implement
cmpxchg(). This builtin has a return type which depends on its arguments
while sparse was always using 'int' as the return type.

A patch is on the way.

Regards,
-- Luc Van Oostenryck