Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1283129lqt; Tue, 19 Mar 2024 20:45:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXf2QZvcWEELYESMQ+uoa8qb9XO7oUzLNfzqE5ulwhu3NgA8ePceGDwJt3lt0rR07ynTaryWgWTULpcscRjZ67PYi2VTsG2p5wQAotUow== X-Google-Smtp-Source: AGHT+IGBW2DftASW3zq93tFkuEm2vLGRQgu+dq2pFF1A1wBGQitxwqEOK+L+6pDLfWwI2ZKTf8TH X-Received: by 2002:a05:620a:1591:b0:788:2ac3:4be9 with SMTP id d17-20020a05620a159100b007882ac34be9mr16739178qkk.75.1710906347977; Tue, 19 Mar 2024 20:45:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710906347; cv=pass; d=google.com; s=arc-20160816; b=PBQQJozDVPhv8lm4zmc7S10xF4NLkpnaE53v9GXPaLk/aaateXmPEjdog0I/M70fzR Zn2itSfh4BuFOCEMlKU4AdEfrXfJgjVBzsfWw8tVmNftml+yoqhgTf4iiFMN1kmIddWA z37Xnzxt1iiBq2h/niyhlqMVig4KNBVEeORwmnU0EXZsKpLGREdJXErVQy8zbme9+KXj YkepUpNmjN97CzstyDD0rJUqjuE8Y4GOg67bnnDjpODJmTYetdHk82r2HKbbNSnXRnDr C6s+FNQByt1rf5W9+3bbNm2W5AJi4EFuGLJR1Ce2DUo7eNLQZdKsMWVtp3wzCROWOWEt nhag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=bR++7yPqt97FJl7Jg2JDn+hhtKQHx1x0+E2M0WcRl9U=; fh=H1uBz6SHiBxf4Ern/gXKRz2YkfEsfn7LAOs0YauuDBU=; b=pO3tF9WkdDl2fI+Y98v9EMg3dAOXuHXF28/jX1L5dah7cE6QbXRKW3KG76GSZv/W92 jfUpxH8kyWKATGGyZSgQc8A9nq3/TLnkQpOk0DO0gqFpzFj4JnsOZmAjQ3B0eyd53HCG HWS9s4GrRWxNPs2Tk+svSFwJg78BgqRooHrgRspXloZEKwz5RTa81pn27a0ud1lasRVN BQh2F09Qmd2ZbTcwih/UR/gWP9XuqQCuPllKT63zXAJ9/W5gAa9Anc0+7YtjdhKAFHGv cVms8z39Sp/u6fqYbhw0GIvv68In50GezEEuk0PIS4s6BlckGO03LsKzMahoFkZlAQD9 mQeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b="LXzxLUT/"; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-108412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wg11-20020a05620a568b00b0078a01ed56dfsi5244010qkn.175.2024.03.19.20.45.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 20:45:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b="LXzxLUT/"; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-108412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B32FF1C2109C for ; Wed, 20 Mar 2024 03:45:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AAED11CA0; Wed, 20 Mar 2024 03:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b="LXzxLUT/" Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (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 16BBE111AA; Wed, 20 Mar 2024 03:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710906340; cv=none; b=NZOFm6nrRTnD54CpmzsxpUc5FvvZsrtRnugiy4e1Rii+g/mSObMvRupX59rAyMADSGo0gahsOhJQrPKeybxqYVxOGeUWvhZfAlLQBS+SUfYYMYDQwuxYo4ql2bZ3ZJT0vIUE+5bNCNPvbkKX+H4Yr3fQSG1njxbX/U/OVUFgEGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710906340; c=relaxed/simple; bh=9B+4hshcFckMEGWpcEnVtr4t0J2t6/ex9MYdj5oM1a4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nm4y792rjSmi6bapbmlewC6nTFmCJaUplmf5B/Pj3ZgtaBiMHEnWRWX+Sf1RxnvejD44sHzMdUkj8ZLZHd4A70knj6V/5E6vkiH3xxC71JTiNFpRXtBwLx4yGJfiDDcPpOidv5KYmMCD/t0CzqWunupR5bIAGjyiVasketI3ts4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au; spf=pass smtp.mailfrom=canb.auug.org.au; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b=LXzxLUT/; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canb.auug.org.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canb.auug.org.au; s=201702; t=1710906332; bh=bR++7yPqt97FJl7Jg2JDn+hhtKQHx1x0+E2M0WcRl9U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LXzxLUT/yzHx7/wlY07PpNPali9zPrM6dbUZTrZEce2r+ZOma1aWVtvDokWr33X3U STer9Tmq4aJASu2m7zy+fp77+IgqzyfxsIJ7ymQQDs5DBhVkLsdDEuDEsht+7+OK9O Xbd0B3VhWufMH03piI7hXtQGTGXEcpJ5tP/9WESdHyHO75psZxTCHeURaIb0yA6jch ckN0tPHemQGr3DZoK22f15nov+y98rNO2MiBGJqRWNQ+hlarfF2675bFMg9VtVg+Hj 44v0q3X6klirlvbOSmawBpPyDiuKLYEdLbO7GGXL4hmj0IKsABi+hnoWD0JGPaKwuy awIw2j2QdPjZQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Tzvcr014Hz4wbp; Wed, 20 Mar 2024 14:45:31 +1100 (AEDT) Date: Wed, 20 Mar 2024 14:45:30 +1100 From: Stephen Rothwell To: Barry Song <21cnbao@gmail.com> Cc: corbet@lwn.net, workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Barry Song , Andrew Morton , 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: <20240320144530.4852845b@canb.auug.org.au> In-Reply-To: References: <20240320001656.10075-1-21cnbao@gmail.com> <20240320124207.0c127947@canb.auug.org.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/TO1BZgkbiVYW.I8uMU2NSDG"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Sig_/TO1BZgkbiVYW.I8uMU2NSDG Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Barry, On Wed, 20 Mar 2024 16:24:30 +1300 Barry Song <21cnbao@gmail.com> wrote: > > On Wed, Mar 20, 2024 at 2:42=E2=80=AFPM Stephen Rothwell wrote: > > > > On Wed, 20 Mar 2024 13:16:56 +1300 Barry Song <21cnbao@gmail.com> wrote= : =20 > > > > > > diff --git a/Documentation/process/coding-style.rst b/Documentation/p= rocess/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 enclos= ed in a do - while block: > > > do_this(b, c); \ > > > } while (0) > > > > > > +Function-like macros should evaluate their parameters, for unused pa= rameters, > > > +cast them to void: > > > + > > > +.. code-block:: c > > > + > > > + #define macrofun(a) do { (void) (a); } while (0) > > > + =20 > > > > 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. =20 >=20 > right, what about adding the below section together with the above (void)= cast? >=20 > +Another approach could involve utilizing a static inline function to rep= lace > +the macro.: > + > +.. code-block:: c > + > + static inline void fun(struct foo *foo) > + { > + } > + Looks good to me. --=20 Cheers, Stephen Rothwell --Sig_/TO1BZgkbiVYW.I8uMU2NSDG Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEENIC96giZ81tWdLgKAVBC80lX0GwFAmX6W9oACgkQAVBC80lX 0Gyhhgf9H0RNoO9xgy7+XrcwZ2zfiLubuD4oRaT2LODstAcOZQEKvdZgCun5V7SV dNLWDGUkILR7hHHhPSkfFz7qmJXheUxXmkNvbyovSoVQpKCfIJtVwO9AKnwdcafL LMBPvD4Fp/b00pLJ8rfETSorRwbE20gD5+NwesE6EtXPuwODDn4zKRwWLJHEl4Wa PCZto1uEF+6oO50pfHDTjI/e0YM73MtNDY0H/FnevXBJqvotvRJn78k4lF9vCe5x 12t/CiOLK8igzbmRH76Em3soUscClwwnPm8U54BEm4hf3Yn72+rFpJRFKjwejFcW ErErslr5cReDA7sSPZfE/cJOjqQcmQ== =8E06 -----END PGP SIGNATURE----- --Sig_/TO1BZgkbiVYW.I8uMU2NSDG--