Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4957719pxb; Tue, 5 Oct 2021 14:12:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwllXRoErRyYAGSmvrFW5qRrjNAvKxCtdyTYkaAb2DrYRrDfy4aEhGXCvdYg4Pg2m6jJwX X-Received: by 2002:a17:906:2e85:: with SMTP id o5mr27270149eji.543.1633468363049; Tue, 05 Oct 2021 14:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633468363; cv=none; d=google.com; s=arc-20160816; b=cw3bH+BtY1bec60NdN3UNnJaquC2Ma/xbV1Gb41iv/YOALSwtvZxrsM4py9Ox8n5jU Wg4YGEjfq7/4Q3YZuzA8/oiMnSrq+hgjMCBYuGtPnR6XjDQDe+xbg3r4Gsd7KI3gITqv aN/tM/E+Bi151D4HqNeuIu0LRnkHcoxg4fP1p4kVbL5UAs/MRe9Jq7r5MuvAU817Kh64 XPylRzUMwQDqV2raVfu8Zzeex9XTx5DNGLOv9dHbDlfTKOEamVhsc4z7ejTGfVqGOMi4 L5K6Vjt7cuJ6w/WBJvhWyGEZGTedA78Yiq1AtjN4jZ1KP9Mq2wOTiifcf1rfNltQ60OK /Eow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=abdpXUfI1pAz35bT5V7B0eKKVaaV4XwyVMiR6sYVfJ0=; b=gEA2X09W1jIa4nl0zNZgHOYmfFoayMHMBIG6E+sdwxHgiS4Gr29aDS15QaFI3XuKUw g7aPao15TvFcnfHmpEG4MPo0wAuYZQT8HSk+8arV+jK+KnB3gNhqsYQ4EnucnAdGgKzg 8TyxSZfgYoCyxFY6PfG16/u4LN9slLsrGz4QE80/wEzH5EGO7uGlD8SI9aujAHE3/skt 6YJeRCojCvqGUTy4tZxccbPjNnMydRsVasJGfBg+zPdGbv5EUoqSqeDB5EINudXartcJ IDJN3qGMsJZSceMblYXJ/GYtoZE4vTa6cfezQRVJfRPapxW/sXO5C7P97fcgikLh+lfU JTWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si43370546ejc.6.2021.10.05.14.12.19; Tue, 05 Oct 2021 14:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236093AbhJEVLB (ORCPT + 99 others); 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.