Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp288664lqp; Thu, 21 Mar 2024 00:43:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXoeDM3wnrjx8Slk6pz4FIgiEscIzgdFTNp6AeEexDC8gqopYlb5SpD72nrnkVEKOEdOaCm6V3cGqEyrKL1Z96zdDfgXfzO2wg6s4rAA== X-Google-Smtp-Source: AGHT+IGmN4FNYoIvp+8gQVoANVvW5+bX/HTvGASLAoHgMOj8EIPgvJM8d4iuCdVFdlG7VQtGhK81 X-Received: by 2002:a17:902:d2c4:b0:1de:fc12:f66c with SMTP id n4-20020a170902d2c400b001defc12f66cmr19350736plc.27.1711006985348; Thu, 21 Mar 2024 00:43:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711006985; cv=pass; d=google.com; s=arc-20160816; b=LvYRpxwtUymehnibkbPQO2hwtQHOHebo1WQ45s4VS7+/lmGpgp72n71aCcaX8kmRh8 GOx8XxECFsZpP3Ig2GGH0i+k9M4N1fpLlwCmY0aMnB0sErKAKkM4MkLOsnBNoe78eSFB Q2c4hbJ9q4/2Z/n/oNECmnAB/iSKrK8sw/Kcj1VjgXIWCMJUJqxihq1BRRno7qczYDqz X5qr//wSygqMoEDO9FuXia36XSb1jFZHvBB9A9/4ZmA854XNNAfJH6HQ0SF8WlDQMdLy hriLo2BTat5LXooJCpCSIheCwt++w2Jfz4/el1RaL/FoL1zF9CZ0b/VScHRlMVnk0UzV frnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=8l/Bpgj/CMp2wahdMVwgC92LJlZFUWdlP+70wN3/HqI=; fh=JoKoPG9zbQlSyLTcsz+XAPu0uYvrfs2N2B/pSkTXAsw=; b=iR1mizObmTpyQBeP7Zk2PtWbh6OM9qIihU/+nMJfbXnFl1NBC7x4UCp9MOrx3obQdI TeFLBldQxU923IBG3aRj1UjxnSa04Gy+jNoWtmVtOxbSD3/WT/rbUr2Kr0C/f4VwNGSD 4jIcUHPcWf68PTYhDZYgwgFHNYnlQt4WKStSZDQPHXI9IJ2IK8tICi2iYoAJwt1xP0Ze PU2GJrAHJoAbOp9KR6hfWTRpTauqAV0S15nyuhZLM74zkXqO8EEVHtAt/ZbKDrcqHIJT X5227W7dC39vRDoBPX4qD6UbN9l4pb6e09g2iIViJUgy/6M814qOJ33qtG/RSBmGyHOF AkbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AaehkjXK; 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-109737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j4-20020a170902758400b001dd2b63e5d5si14394668pll.439.2024.03.21.00.43.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 00:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AaehkjXK; 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-109737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109737-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 451C7B2172C for ; Thu, 21 Mar 2024 07:43:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 552F358203; Thu, 21 Mar 2024 07:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AaehkjXK" Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com [209.85.222.44]) (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 C1353339B1; Thu, 21 Mar 2024 07:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711006972; cv=none; b=LD45JYhnrv8+boHUMWQ866WWARRyUKhdHqlTNI6eUe/4xvyGeNwgjaXjKqFN8gOvL7i3/BI2aOHqsLi6AphYJ+2FVg5Qs5tXtqNFF5FJQEz++8wcO5xqjjdojRisWYNNghTcbYUMxR0M9asbiNv6iEVyA9jYpwh2hLfqmBBS56Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711006972; c=relaxed/simple; bh=Becs+F28N9K1U02o0AkBnbKa+etvYaDo1+6e9Py9BYY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=F32hxcKQHoTMWmNUFhYeeq/lNhiWNjxYnLCA55Qst6/t935XrsFVw6VEImNGHRxx9MUDQS9/DlELx7ki0WwrVfGp02SpZlWRXx2dDl+yCHGkJpPlVv0JCg/LRTbbR5O7O24pf4o9s2mHegMb9/i41vlGyv9dl4Fv3pN8egVeHiU= 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=AaehkjXK; arc=none smtp.client-ip=209.85.222.44 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-ua1-f44.google.com with SMTP id a1e0cc1a2514c-7e0abfea517so316470241.0; Thu, 21 Mar 2024 00:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711006970; x=1711611770; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8l/Bpgj/CMp2wahdMVwgC92LJlZFUWdlP+70wN3/HqI=; b=AaehkjXKHmf5C+laXophkKuJjGsK9I82gjgSPU/r/nHJMZ6Fv6v/IzyxQHZUZAJTc0 juM6dhRX+lZ5Bo1AfKSGjyXfD4u4y6i0e221JfwnyRkFjKfPQrxqF5QsiCCQJ6vaupGd MSlEhHI0F/+dVg1CzTaUw4aXqcendsUYrQdhGas1taDfkMtdAgPfnIbqJIMkKMHu2hk4 y3XTl+psnsaXvCJREefxthgzxD8+S4We7nU28dKC8sFZJE4sL2Hy+stE07eao8tXpr4l +uaM3iZCVLuAs4T2aEsHathu7SfY79e35WNzR7GW46u9LyO9miZZcT2XvwHfeqGNev1U wQRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711006970; x=1711611770; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8l/Bpgj/CMp2wahdMVwgC92LJlZFUWdlP+70wN3/HqI=; b=tYZ5o/OvwA1UloCt5RuaZ2ptqQMUdSCc/tbWaTyx7eVJSmybFP1p8HouwtZppgN0XM ty6U7ePlTWB1TVSQqrsqP6KVnZoym4wT0jNtapp2eVagGmd2zrhteB7mK95CVVccXA7+ Rg009Goy9jet/ucCdouEIqETEjaWvX7gFXB80gQ50U+H0ES4CU5kz/2dcw6G5exda8W5 uF3C+0v2i7pWQ9N41xHnbfYJeVlDk8acdmRZJvA0WN2aboq/PdBkXC/ZE8WI/hqLvOEV 6wugR1sCl4oIIaQgtTKb79v/0xsDyC7GSEiaMivdeLw/twqgZGDpSHXVZIArFElcw8/L NP+w== X-Forwarded-Encrypted: i=1; AJvYcCXeZUy2dpeqaIlpio5DQgv6ttWjfTdsqaWo5kgZdAQL2IbT4oS/IGP8Frzn6lEixNe52QW/+V9uqD2P523Asr3AmaAzgN35P+deB3cq2ZFV2UQl5idSH9CW6qnJX7NI6GUMsb9xrwx9fwuIE5NEvndRG7ClzkCcBn6fIehW6M0jlLRP X-Gm-Message-State: AOJu0YxmT49llTG9qw5g+Ny5tatw/8+4rSwMW5zj1Wsibk+7nNgrFj4A VJKodkLyxmbR0wfoNJ09N7cS4etSK4k73msWqR+ihKSEgFACkqyTq2e58nwCjPyGiYCYMyyPCmZ 2Q2UlIwEhg9utj/svwYRpmENkoNDKhJLxiSM= X-Received: by 2002:a05:6122:a1c:b0:4d4:25f2:3ca6 with SMTP id 28-20020a0561220a1c00b004d425f23ca6mr20336369vkn.3.1711006969698; Thu, 21 Mar 2024 00:42:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240320001656.10075-1-21cnbao@gmail.com> <7bdc4d24-adfd-4a8c-b824-6833149f5636@126.com> In-Reply-To: <7bdc4d24-adfd-4a8c-b824-6833149f5636@126.com> From: Barry Song <21cnbao@gmail.com> Date: Thu, 21 Mar 2024 20:42:38 +1300 Message-ID: Subject: Re: [PATCH] Documentation: coding-style: ask function-like macros to evaluate parameters To: Meiyong Yu 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 21, 2024 at 5:40=E2=80=AFPM Meiyong Yu wro= te: > > > =E5=9C=A8 2024/3/21 8:11, Barry Song =E5=86=99=E9=81=93: > > On Thu, Mar 21, 2024 at 12:39=E2=80=AFPM Meiyong Yu wrote: > >> > >>> On Mar 20, 2024, at 08:17, Barry Song <21cnbao@gmail.com> wrote: > >>> > >>> =EF=BB=BFFrom: 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 b= ut 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' [-Wu= nused-variable] > >>> 174 | struct page *dst_page =3D 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 =3D sg_page(req->dst); > >>> > >>> for (i =3D 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/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, > >> I do not support this point, if the parameter is unused, why not to re= move it. > >> > > Linux boasts support for numerous architectures, striving for > > independence in its > > drivers and core code implementation across these architectures. Conseq= uently, > > certain architectures may utilize parameters for the same APIs, while o= thers may > > not. > > So the probem is designed api is not reasonable, it use not essential > paramter, > > you can change the api, but not avoid it. > Incorrect again. As an API, it must take into account various consideration= s. Just because architecture A doesn't require flushing dcache doesn't imply that architecture B doesn't need it. > Anthor question, why you do not use the parameter, if not use it, will > trigger function/feature dismiss problem ? > > >> about the warning, is tool misreport, the tool must make better > >> > > no. This is not the case. > > > >>> +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 > >>> > >> > >