On Sat, Jul 24, 2021 at 7:01 PM Al Viro viro@zeniv.linux.org.uk wrote:
On Sat, Jul 24, 2021 at 06:24:29PM +0200, Sven Eckelmann wrote:
The special attribute force must be used in such statements when the cast is known to be safe to avoid these warnings.
I can see why this would warn, but I'm having trouble reproducing the warning on linux-next.
How about container_of(ptr, typeof(*__pptr), x) instead of a cast?
Would be easier to follow...
If both work equally well, I'd prefer Sven's patch since that only expands 'type' once, while container_of() expands it three more times. This may not make much of a difference, but I've seen a number of cases where nested macros can explode the preprocessed code size enough to slow down kernel compilation over all, and it's quite possible to have get_unaligned()/put_unaligned in the middle of that, with a complex expression passed into that.
Arnd