From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08340C433EF for ; Tue, 5 Oct 2021 18:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5A95613D5 for ; Tue, 5 Oct 2021 18:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234830AbhJESl5 (ORCPT ); Tue, 5 Oct 2021 14:41:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbhJESl4 (ORCPT ); Tue, 5 Oct 2021 14:41:56 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB861613D3; Tue, 5 Oct 2021 18:40:03 +0000 (UTC) Date: Tue, 5 Oct 2021 14:40:02 -0400 From: Steven Rostedt To: Jan Engelhardt Cc: Mathieu Desnoyers , Rasmus Villemoes , linux-kernel , Linus Torvalds , Paul , Josh Triplett , Lai Jiangshan , "Joel Fernandes, Google" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , rcu , netfilter-devel , coreteam , netdev Subject: Re: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) * Message-ID: <20211005144002.34008ea0@gandalf.local.home> In-Reply-To: <826o327o-3r46-3oop-r430-8qr0ssp537o3@vanv.qr> References: <20211005094728.203ecef2@gandalf.local.home> <639278914.2878.1633457192964.JavaMail.zimbra@efficios.com> <826o327o-3r46-3oop-r430-8qr0ssp537o3@vanv.qr> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, 5 Oct 2021 20:28:54 +0200 (CEST) Jan Engelhardt wrote: > On Tuesday 2021-10-05 20:06, Mathieu Desnoyers wrote: > >> instead of just "typeof(p)", to force the decay to a pointer. > > > >If the type of @p is an integer, (p) + 0 is still valid, so it will not > >prevent users from passing an integer type as argument, which is what > >the current implementation prevents. > > > >Also, AFAIU, the compiler wants to know the sizeof(p) in order to evaluate > >(p + 0). Steven's goal is to hide the structure declaration, so that would > >not work either. > > >>>> typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); > > > #define static_cast(type, expr) ((struct { type x; }){(expr)}.x) > typeof(p) p1 = (typeof(p) __force)static_cast(void *, READ_ONCE(p)); > > Let the name not fool you; it's absolutely _not_ the same as C++'s > static_cast, but still: it does emit a warning when you do pass an > integer, which is better than no warning at all in that case. > > *flies away* Are you suggesting I should continue this exercise ;-) -- Steve