Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp136318lqp; Wed, 20 Mar 2024 16:38:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOZtNSjauf32/NomVihaqBw5IHVFyyGvBSS/jnsc2YOgM2x7m9OBAIzJqY9gyZIVXXJodtw/l+OvbVwb9Vr6cjHKKj1sX4gA4wSBP6ew== X-Google-Smtp-Source: AGHT+IFxi38LXNdY6KKQZHFez8GOTkTrpuhCMt2VcWkCFG0h5ODzGa0qO+qLgWfnYZtjszSMvKEl X-Received: by 2002:a05:6214:2628:b0:691:2b87:2814 with SMTP id gv8-20020a056214262800b006912b872814mr406266qvb.41.1710977933226; Wed, 20 Mar 2024 16:38:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710977933; cv=pass; d=google.com; s=arc-20160816; b=YmTS7f8+iktStkVFe8qp0lOntYsg9qSgyzvVkPBY2rxYvpAg3Puf3rQ9XiLlU+uMxX DE1lnHZTueN2vJ5IJh0V7IW/FxZvxczDA8G7GWC1oeuEia3LoWYsP4cB4wmuE8SDkItG u2Ys1+OkCERSpa3Nh8sWJIuxpdfLUXzpcD6OzorX4hunmYLUnTQY2SGl17lfgYLfPn03 f0d5Z8gzPDWv/OfjeD06YVJmxq5DTQA7drdVCWEH6AZF5NmER0QQkRBoD6Id6jt7F9xi fHUCIzdufZmAwl7hs/WUQYHHKsfPJp52hNumjbEBrn71Wiy+AMTbTCPXnDgNIMWOkdiJ VBQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:from :content-transfer-encoding:dkim-signature; bh=NJNvmjRg6+oJD+f8rosyW4DUgth/EkIgF8KUF7RekOg=; fh=xrFFumq8nx+PNKBlsNvu123in1Wp61phvQ8lrKiapoQ=; b=ga3OUmSkNcrKpMalAp4R1wTyXxzo+0CvxT/tnQ/yRHYi4WUok22UD585Lr7u1dE/M1 vuPWgTSkF72OKGt7Wg+VsacPlaANWPsGY72rGDFA4trfMmbfhqSKVvLc/JM3Zq739NVp TsxSpn9qTekHbbvVnx1qaJz3cA3eiTyqkD0kwxtIuegorD0oLbdGUi8Cv9MxnezAMFe8 SFWsI7VA8o+JU47IuTQHw2RJbUkkV67+mb9SYl0EuLikCJSP0L4jobUkzrDEPLV/Hydo SRHiMf85DmJNlklpDuNf6s0HwpJdpMhgIemvYoo2g+hr1CMNnEZ8PgApAsS6EdW6MIEm Bxzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=g+JfZlv5; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-109494-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jp14-20020ad45f8e000000b0068f654b037dsi13490752qvb.610.2024.03.20.16.38.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 16:38:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109494-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=@126.com header.s=s110527 header.b=g+JfZlv5; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-109494-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E3E511C20EDF for ; Wed, 20 Mar 2024 23:38:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B78EE8615E; Wed, 20 Mar 2024 23:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="g+JfZlv5" Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.9]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C55F11E87E; Wed, 20 Mar 2024 23:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710977925; cv=none; b=t/FofJQhtX0KhjAKYeTnhF/sx9heQCRfSmNXepYtiipBKadYhCdQSYgWuIOXfX9+rr4cMMhRctwRVchT4n6iu9atyqySkdW5YuCMKpfEarTNOwmxi1nxqxQ/7sxSnv6KKPTV/CMbFNNuw+fPIa8sWshCIDxy4pFzSXoIP5rJ5Z4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710977925; c=relaxed/simple; bh=+2SWIsd88ucu5ws7uxhQnlemEmeUg8lx9NbQy9iP82Q=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:References: Cc:In-Reply-To:To; b=HWV4J5J48mTD8iVJIndjQZWp5OPZVSYE7+HVafEvI3AK8+FND6Ws0thuMUXRMlgrvZdODYBJ4kClL9Tdr3W5qrRK3SfsI/8f+oH5rWu6nrDKNKw6LKkPZ8r+I3eZAnAKFg0fyiuxcmxbid3pnpbaPWljPL0Dm2dghmMXVRokFhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=g+JfZlv5; arc=none smtp.client-ip=220.197.31.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Content-Type:From:Mime-Version:Subject:Date: Message-Id; bh=NJNvmjRg6+oJD+f8rosyW4DUgth/EkIgF8KUF7RekOg=; b=g +JfZlv5pCw6ae43XDwcHmzR4d1lHl9pvpTQMsm/WZKERzH+NIsNImOSiXpm874dC /VMHqVTcE3m8EeA1J4Yjy9UUK46cBsAfUT+mN9ytXs+zgIDZTwkyxGNJ09QY2o95 kGbaV+VzJ03oaiCxpnz2mK1Jk7VQNuQRIeYw4+idAA= Received: from smtpclient.apple (unknown [119.143.49.21]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wD3Py80c_tl2DLlAA--.33361S2; Thu, 21 Mar 2024 07:37:26 +0800 (CST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Meiyong Yu Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] Documentation: coding-style: ask function-like macros to evaluate parameters Date: Thu, 21 Mar 2024 07:37:14 +0800 Message-Id: References: <20240320001656.10075-1-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 In-Reply-To: <20240320001656.10075-1-21cnbao@gmail.com> To: Barry Song <21cnbao@gmail.com> X-Mailer: iPhone Mail (21E219) X-CM-TRANSID:_____wD3Py80c_tl2DLlAA--.33361S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAFWrur45Xr1DtrW3Zw15XFb_yoW5Gr1xpF Z8JF47Xa18XFyUArnrJ392yFyxJrWrCFW3Wrsxtry5uF43A3Z2gry3tr15uan7Ar409ay7 ua12krsruFyayrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bbiSdUUUUU= X-CM-SenderInfo: 5phl501qjo53a6rslhhfrp/1tbijh2nhmVLZvJUWgABsH > On Mar 20, 2024, at 08:17, Barry Song <21cnbao@gmail.com> wrote: >=20 > =EF=BB=BFFrom: Barry Song >=20 > 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 =3D sg_page(req->d= st); > | >=20 > The reason is that flush_dcache_page() is implemented as a noop > macro on these platforms as below, >=20 > #define flush_dcache_page(page) do { } while (0) >=20 > The driver code, for itself, seems be quite innocent and placing > maybe_unused seems pointless, >=20 > struct page *dst_page =3D sg_page(req->dst); >=20 > for (i =3D 0; i < nr_pages; i++) > flush_dcache_page(dst_page + i); >=20 > And it should be independent of architectural implementation > differences. >=20 > Let's have a guidance in codingstyle to ask for the evaluation > of parameters. >=20 > 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(+) >=20 > diff --git a/Documentation/process/coding-style.rst b/Documentation/proces= s/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) >=20 > +Function-like macros should evaluate their parameters, for unused paramet= ers, I do not support this point, if the parameter is unused, why not to remove i= t. about the warning, is tool misreport, the tool must make better > +cast them to void: > + > +.. code-block:: c > + > + #define macrofun(a) do { (void) (a); } while (0) > + > Things to avoid when using macros: >=20 > 1) macros that affect control flow: > -- > 2.34.1 >=20