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 6B83AC433EF for ; Tue, 5 Oct 2021 21:09:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D4B16108F for ; Tue, 5 Oct 2021 21:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236314AbhJEVLB (ORCPT ); Tue, 5 Oct 2021 17:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhJEVLA (ORCPT ); Tue, 5 Oct 2021 17:11:00 -0400 Received: from a3.inai.de (a3.inai.de [IPv6:2a01:4f8:10b:45d8::f5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A0DC061749; Tue, 5 Oct 2021 14:09:09 -0700 (PDT) Received: by a3.inai.de (Postfix, from userid 25121) id 15A2B586F499E; Tue, 5 Oct 2021 23:09:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by a3.inai.de (Postfix) with ESMTP id 1240C60EFF223; Tue, 5 Oct 2021 23:09:08 +0200 (CEST) Date: Tue, 5 Oct 2021 23:09:08 +0200 (CEST) From: Jan Engelhardt To: Steven Rostedt 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) * In-Reply-To: <20211005163754.66552fb3@gandalf.local.home> Message-ID: References: <20211005094728.203ecef2@gandalf.local.home> <639278914.2878.1633457192964.JavaMail.zimbra@efficios.com> <826o327o-3r46-3oop-r430-8qr0ssp537o3@vanv.qr> <20211005144002.34008ea0@gandalf.local.home> <20211005154029.46f9c596@gandalf.local.home> <20211005163754.66552fb3@gandalf.local.home> User-Agent: Alpine 2.25 (LSU 592 2021-09-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 2021-10-05 22:37, Steven Rostedt wrote: > >Really, thinking about abstraction, I don't believe there's anything wrong >with returning a pointer of one type, and then typecasting it to a pointer >of another type. Is there? As long as whoever uses the returned type does >nothing with it. Illegal. https://en.cppreference.com/w/c/language/conversion subsection "Pointer conversion" "No other guarantees are offered" >struct trace_pid_list *trace_pid_list_alloc(void) >{ > struct pid_list *pid_list; > > pid_list = kmalloc(sizeof(*pid_list), GFP_KERNEL); > [..] > > return (struct trace_pid_list *)pid_list; >} struct trace_pid_list { void *pid_list; }; struct trace_pid_list trace_pid_list_alloc(void) { struct trace_pid_list t; t.pid_list = kmalloc(sizeof(t.orig), GFP_KERNEL); return t; } void freethat(struct strace_pid_list x) { kfree(x.pid_list); } Might run afoul of -Waggregate-return in C.