Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1607851lqt; Wed, 20 Mar 2024 08:49:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD04FjrXUFQ9CQOgO7rxpLN6oxlPUpIQibXPvdHIzL0ceAvs9DgMkRwo+pui4L7xUD+/rfMI5ZLy7sp+Trt9CA6LM50UzAKVQCWcvRSQ== X-Google-Smtp-Source: AGHT+IFkVZBMrYGf5PHSFeFjjNUjbD3y2Z91+Pc6YkYhzIJvRE90buK7F/BYVq8NJZYK+Ge0xfhI X-Received: by 2002:a05:6a20:54a4:b0:1a3:6f13:b11b with SMTP id i36-20020a056a2054a400b001a36f13b11bmr76701pzk.4.1710949768651; Wed, 20 Mar 2024 08:49:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710949768; cv=pass; d=google.com; s=arc-20160816; b=ZaNQcEOUNCH3W9GLO78hNFV9aAMQA2BsgAG4m+ozg2dxieEeviXQ4tkmVFXD0gJ8dj 5IGXuE6zcvcRdd+pXToi76vdt+GCw4JR80SEvXt1Y9riu7TkLTnmDsXPcj2NBWXXhM0Z lp8CvuF0hiAa0L3MWGRFJ2h5miC0x1FpYA7qc8iIDfZAtiOEqVjadNfjD6tVVDi+qLs/ 6aYU9RHXSiFAKOunidrh98niCudrWsQToMel6wSAk8b9vYwrmg0ZKhBV2R6vyl4W4mcb OFU3dOjVgKiDNa3mfDKgCFTC2zhmMMV6ELC2bLfGGUAoEpBBrLUmaztqsle+6t5cEPkn el7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=hlh0P2m1kYH25IeWEy9uVtkS7+jHdUzf+vE3QcOnAQk=; fh=5s4TNFT8KxXRlsk3CqxAnNH8GXGUCsMS4MGWlaWIN+Q=; b=AATikPEnRDm4lK+36ijFN8wPOcEsI1nZ5k146SVUnuEBb/46OieAw6Tu79R8HwIjSD OVk5iNdeHi9vZhWcKRc1JtnUckoBiubwi0GbsAZYl99NJh+De6dRtrlT93hIr+/TXcN9 mB1jYUU7hUTaPRwfK2EMJr/knszeYq91GyFof5kvZGmOBKbK5JfGh/PcIqaAbWIhtTzN lo4r9m+r8X2MlBOmQFQHM/egigUlR3NWFbyAQq0aCOdxTVjweGjkwu6Cam+bNGsTdq4C MYJ6fa7XSw1UrFBiiA3gv3dJtL7Z3UDKP4bh3qunHnxGO1LcxElWfSjMvYU2oYJVZoN8 kQ2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="jI/2aoqT"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-109119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109119-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t188-20020a6281c5000000b006e444ed29edsi13204136pfd.200.2024.03.20.08.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 08:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="jI/2aoqT"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-109119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109119-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 582EE281F0E for ; Wed, 20 Mar 2024 15:49:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CFD0535C6; Wed, 20 Mar 2024 15:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="jI/2aoqT" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1453D4207B; Wed, 20 Mar 2024 15:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710949761; cv=none; b=FWs2leAOMjlweLoUzV/S0mP95aGJByhxRXt5nRniMDM01zCH1/2njJBsKAH22ildG33MnJjWmWQz7/sIRNeFhANbju2MQ0yiaeg+0cBiJmr+mit4vm2MgrQ7qlbHMZv3Kmq+PVOVdr7PYavUHWAWK/OloD5bGP+GPIsxSUaUlgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710949761; c=relaxed/simple; bh=xcQAtsJlg/6AQJ48E0amQtY7Z3hqsM9mpclT5/9SuDg=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=os5cTHbvhNhTm0xQaiHo2aOQPUAOzcYBIOoVpY4Ljg4heO5MEbCygfpyrDHAklvpRf4QMrq0ji/Iri/mLza5OgyP1RkuCtyEQniIKWnBPTn8+VwUBLD3s7lff5cNZDjvtJef9l28Gg+xuudaARzYaJ4Y6pxBGR2dG16bLlfpkeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=jI/2aoqT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E6A9C433F1; Wed, 20 Mar 2024 15:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1710949760; bh=xcQAtsJlg/6AQJ48E0amQtY7Z3hqsM9mpclT5/9SuDg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jI/2aoqT/NM4PhQBSgnMksuVBN5TmmO56fJxz6vCsNKB18ODmv003QyOXH8SNMUJy q0Npy88cO3ylVwE05OPq5Bly9SI+m2U7ars9yBevkXafVr5AVDUDZ7jW9VEyAmRCo2 qjJ3XLVzyHpDNB6skiTgS/iyqtO5iY+J5ollYWV8= Date: Wed, 20 Mar 2024 08:49:19 -0700 From: Andrew Morton To: Barry Song <21cnbao@gmail.com> Cc: Stephen Rothwell , corbet@lwn.net, workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Barry Song , Chris Zankel , Huacai Chen , Herbert Xu , Guenter Roeck , Max Filippov Subject: Re: [PATCH] Documentation: coding-style: ask function-like macros to evaluate parameters Message-Id: <20240320084919.8e18adb418347feed6bfc8ae@linux-foundation.org> In-Reply-To: References: <20240320001656.10075-1-21cnbao@gmail.com> <20240320124207.0c127947@canb.auug.org.au> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Wed, 20 Mar 2024 16:24:30 +1300 Barry Song <21cnbao@gmail.com> wrote: > Hi Stephen, > Thanks for reviewing. > > On Wed, Mar 20, 2024 at 2:42 PM Stephen Rothwell wrote: > > > > Hi Barry, > > > > On Wed, 20 Mar 2024 13:16:56 +1300 Barry Song <21cnbao@gmail.com> wrote: > > > > > > diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst > > > index 9c7cf7347394..8065747fddff 100644 > > > --- a/Documentation/process/coding-style.rst > > > +++ b/Documentation/process/coding-style.rst > > > @@ -827,6 +827,13 @@ Macros with multiple statements should be enclosed in a do - while block: > > > do_this(b, c); \ > > > } while (0) > > > > > > +Function-like macros should evaluate their parameters, for unused parameters, > > > +cast them to void: > > > + > > > +.. code-block:: c > > > + > > > + #define macrofun(a) do { (void) (a); } while (0) > > > + > > > > Maybe add some comment about using a static inline function for these > > simple versions instead, if at all possible, (it is suggested just > > above this section) since that will still type check arguments. > > right, what about adding the below section together with the above (void) cast? > > +Another approach could involve utilizing a static inline function to replace > +the macro.: > + > +.. code-block:: c > + > + static inline void fun(struct foo *foo) > + { > + } > + Stronger than that please. Just tell people not to use macros in such situations. Always code it in C.