RE: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sven Eckelmann
> Sent: 24 July 2021 17:24
> 
> Sparse will try to check casting of simple integer types which are marked
> as __bitwise. This for example "disallows" simple casting of __be{16,32,64}
> or __le{16,32,64} to other types. This is also true for pointers to
> variables with this type.
> 
> But the new generic {get,put}_unaligned is doing that by (reinterpret)
> casting the original pointer to a new (anonymous) struct pointer. This will
> then create warnings like:
> 
>   net/batman-adv/distributed-arp-table.c:1461:19: warning: cast from restricted __be32 *
>   net/batman-adv/distributed-arp-table.c:1510:23: warning: cast from restricted __be32 [usertype]
> *[assigned] magic
>   net/batman-adv/distributed-arp-table.c:1588:24: warning: cast from restricted __be32 [usertype]
> *[assigned] yiaddr
> 
> The special attribute force must be used in such statements when the cast
> is known to be safe to avoid these warnings.

At least the __force is being added to an existing cast.

The real problems are when a (__force __le32)value cast is used
to silence sparse.
These should really be something like:
	__tell_sparce(__le32, value)
so that the whole thing can be removed by the preprocessor when
compiling the code.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux