Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1216681lqt; Tue, 19 Mar 2024 17:17:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxzlJB+FJS5igUs4ZTkIRiQRjq0FI1QkQdenN7a/q8e49lz/vrVajraPKdwxlPZ4LDdbHzE/MueYAJwaKvDnL/yQ2e9Tnfm12RcWoL/g== X-Google-Smtp-Source: AGHT+IFBiu/fAYbxXC7yKqj6NvtQh6zH3fzczVLkeKZD/4xZzCSb69XFbnTOiWNSyGU4T1Ob6HsM X-Received: by 2002:a17:906:39c5:b0:a46:a71d:323a with SMTP id i5-20020a17090639c500b00a46a71d323amr226186eje.72.1710893843314; Tue, 19 Mar 2024 17:17:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710893843; cv=pass; d=google.com; s=arc-20160816; b=MwAtXmetU5Xdjf0Q/rbEuP0UgKIPUz4xawXtXSM5SKyRHvgKTBYAd9jac1clEvtbe6 ahm9mbOdCBVkhP/rTRW9323zm8wjlEJfI9SUXfNTL9ChUgCZAUfjI9Eiq2Xdl0RnpY9A cDhopTcqjWtty9KIdKc1c0i/OrM1yrAx2sTvKGYePNwvuhrRDAwOvB/qc2i6y00uG3Fh 4s7R05D3+TwBM5tUn1ycueKXzKqRFSJfDHHIJxTB1VkLGJRO4L5740BbyfFLlMa0WKeo +rlzAPM7eTr7Bdnlo2nJY2tr8YdY5+wFOdnNmJrAZZq5YOKa0eg3gvSVtGdaoVcZCWqT kgjw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ewnx+qqOLD+CDSGBLXyslpAmGrwWU9vAAEvXADtuxMQ=; fh=hKsrCiKJcAo6ZM5oSk9qf3glx3kdFxXXpg1k9xcQwbI=; b=Q7ND43M8hsa8TUvF0gBHXknRYNh0+mUGxESuPZW38dK264To+40hvgEZEiciuSShoR g9GPLZIlXxqCmSXqJ2k0J4X8uWNS3npi+fRSFOHE6g5objPqOueFVAxlckIY00YO9XgO vGORAxsjhu+hiTBpTO+J8FoPLyZzYFQS7zv1ty4bUFDNGzCflc8yCyFthDH3GcyS1TSm h9PVdumF72U7fYUsYISlNnEnKQRVPF6BU0mGYYbdyyIm07R9oQsoZtr17El4UqLcItx2 Q2I5AViFDd1rWS52TR4garWxwRsYHejeYKlHPgwgUZ3ltmRYW6QQT8dQNr+Z73Z/mVD/ fQ2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIZVGkWp; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108259-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hk24-20020a170906c9d800b00a46d22a190csi1546341ejb.819.2024.03.19.17.17.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 17:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIZVGkWp; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108259-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0FF0C1F21A24 for ; Wed, 20 Mar 2024 00:17:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C538D101C6; Wed, 20 Mar 2024 00:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DIZVGkWp" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71C77F9CC; Wed, 20 Mar 2024 00:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710893836; cv=none; b=m8hb8j4fevTjUSIYcjMGChVx6NrZS2siFkvIBjewOOysoso1i3HaaH61OnTulYH4BizC9I/TWjOXIG6F6hfFaViVio39gGWvOwGzO14VW0iZ8mkgr7ZUA8GrNq8QQoPo+H0YgNAWlb6Rpr2BfIFasBDVGticM7Tf4oUBG+U2mq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710893836; c=relaxed/simple; bh=VdoFpvA7x+42mN3b3PxvQ8HMy1WtS/Ev7hI1DtopmG4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=MwuOduDyn/5gzphPkOSyG5Lk/rb20o3Xb0IHNRBsQLQM2SWa81p+m2NWEqsue5mxEbcHc+ktnmQpnYzNgYW0HtKa2YiFZr11SxXpZPHAjH1ceB4dZ+8Cyq2JCO+YCNbWP9s7ntaxd2Wnz1zKG95FguTSmXTn5UoTZqUnFlxffU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DIZVGkWp; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e6b6e000a4so345489b3a.0; Tue, 19 Mar 2024 17:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710893834; x=1711498634; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ewnx+qqOLD+CDSGBLXyslpAmGrwWU9vAAEvXADtuxMQ=; b=DIZVGkWp6myshvcxlhIBjdUs2mQ3jLq9S3/a+dfR3Zk3N6AJQpAMHwpmZ5kvmFQbD7 iOp9FyZZoH/JluqsFg0FFOxT7fPDJNJ5VplRTEdxI+iatb7TJ2sbQSq/bo/rVB6bf06/ XbvlGV4fx4AVZOQRMHrqN1OP3R+oxyEwiCwj8hd4IXx8dTZh0BKbSUIBnYhugc7nd59d 3EQqq28gHF8K+LL10AAEnUFM+fo7kBeaXU9vkBDhD1kswkwxoEHEZya8nJ5b3GSPWL86 x0PkoenLl5KRaJb/CKN1oDakiNEOuwU25piMnJp9DZrpPFENWJGPOoSuldjXtmvPQSaF /HYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710893834; x=1711498634; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ewnx+qqOLD+CDSGBLXyslpAmGrwWU9vAAEvXADtuxMQ=; b=ceDAKej0ovsckX0N/tjQoRAQXXckV/uyJklK11fMPj7/2RX/F/auX+yT3TYGn1QKKn Qua1v/HpME4bvdTNVX6wYpsj1dFR6ZM1fLd5D1lHScH1RvioNByFeCNmVMTIv3s1KYJx T2Sa24nPwUc9+cvmCOyKul9dO5cGwAIr1WfHVARDc6SIHu14mPEmhTAa8hFQOBtwARse I15ZCccTlW+MQTunTH/iTT87mbKQs1Z+nk2oOpmKwUc6h5fwl7zY/+IVJkEU5qRQQk8t qmjveL3FFaPSXBYiXSPf35c/psjrqv/i1oqyTpNaoMOl4q8DIMObBLx+sjqp7dyJkBCh xNKA== X-Forwarded-Encrypted: i=1; AJvYcCUq2Oa8yYG4ydkghkfCeahhhc/q6+cy63m67i+QFH5oarFvE/lgiz19OhQEAu2ZQNSK4nDhTNDOE8KaW/S+/I3P5nSC49Z2GQIEhxUdjRgeGsyd18dAm9C0kX8jnYqBIiDPPJ2+ X-Gm-Message-State: AOJu0YxMaMjS0N0ZheAzodvvIcfNw0SXSghPlJjRSyxi4DEdxlhevVGv DsUhJsJ/svR/HIYFViDht2re4ReVb2O0m/+kF+Ps/BREWL1l7OA4 X-Received: by 2002:a05:6a21:150c:b0:1a3:53ee:ce07 with SMTP id nq12-20020a056a21150c00b001a353eece07mr1240313pzb.28.1710893833766; Tue, 19 Mar 2024 17:17:13 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id ks11-20020a056a004b8b00b006e647059cccsm10357007pfb.33.2024.03.19.17.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 17:17:13 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: corbet@lwn.net, workflows@vger.kernel.org, linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Barry Song , Andrew Morton , Chris Zankel , Huacai Chen , Herbert Xu , Guenter Roeck , Max Filippov Subject: [PATCH] Documentation: coding-style: ask function-like macros to evaluate parameters Date: Wed, 20 Mar 2024 13:16:56 +1300 Message-Id: <20240320001656.10075-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Barry Song Recent commit 77292bb8ca69c80 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem") leads to warnings on xtensa and loongarch, In file included from crypto/scompress.c:12: include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone': include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable] 76 | struct page *page; | ^~~~ crypto/scompress.c: In function 'scomp_acomp_comp_decomp': >> crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable] 174 | struct page *dst_page = sg_page(req->dst); | The reason is that flush_dcache_page() is implemented as a noop macro on these platforms as below, #define flush_dcache_page(page) do { } while (0) The driver code, for itself, seems be quite innocent and placing maybe_unused seems pointless, struct page *dst_page = sg_page(req->dst); for (i = 0; i < nr_pages; i++) flush_dcache_page(dst_page + i); And it should be independent of architectural implementation differences. Let's have a guidance in codingstyle to ask for the evaluation of parameters. Cc: Andrew Morton Cc: Chris Zankel Cc: Huacai Chen Cc: Herbert Xu Cc: Guenter Roeck Suggested-by: Max Filippov Signed-off-by: Barry Song --- Documentation/process/coding-style.rst | 7 +++++++ 1 file changed, 7 insertions(+) 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) + Things to avoid when using macros: 1) macros that affect control flow: -- 2.34.1