Re: drivers/md/bcache/super.c:108:14: sparse: sparse: restricted __le64 degrades to integer
From: Christoph Hellwig
Date: Thu Dec 12 2024 - 01:24:02 EST
On Wed, Dec 11, 2024 at 12:34:20AM +0800, Coly Li wrote:
> > drivers/md/bcache/super.c:108:24: sparse: expected unsigned int nr_keys
> > drivers/md/bcache/super.c:108:24: sparse: got restricted __le16 [usertype] keys
> >>> drivers/md/bcache/super.c:108:14: sparse: sparse: restricted __le64 degrades to integer
>
> It complains about line 108 which is,
> > cafe563591446cf Kent Overstreet 2013-03-23 107 err = "Bad checksum";
> > cafe563591446cf Kent Overstreet 2013-03-23 @108 if (s->csum != csum_set(s))
> > cafe563591446cf Kent Overstreet 2013-03-23 109 goto err;
>
> Here s->sum is __le64, csum_set() is uint64_t, these two types have same length. I don’t see the direct connection between code and warning.
The are the same size, but not the same endianess. In other words this
is a hint that this code is most likely broken on big endian systems
due to the lack of a bytespace (which is a no-op on little endian
systems).