From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 References: <20210724162429.394792-1-sven@narfation.org> In-Reply-To: From: Arnd Bergmann Date: Mon, 26 Jul 2021 14:57:31 +0200 Message-ID: Subject: Re: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning Content-Type: text/plain; charset="UTF-8" List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Al Viro Cc: Sven Eckelmann , Arnd Bergmann , b.a.t.m.a.n@lists.open-mesh.org, linux-arch , Linux Kernel Mailing List On Sat, Jul 24, 2021 at 7:01 PM Al Viro 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