Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp148785lqp; Wed, 20 Mar 2024 17:11:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWW8goaRXgNMUJGlq95qRr3KpFBhS/EqoTySaQKZ6/ANyStKmb54qsXGjCfENlve98ND6idUTR08tyGL5wyV/H/PRVI0RXg1pWKagFusQ== X-Google-Smtp-Source: AGHT+IETQgnKm40n0cwOXG36jXM9lkHFIgCNLC7NTlgYf6d101MUkNc4Km6km6FubTulY716X82h X-Received: by 2002:a05:622a:1b0d:b0:431:22f1:6974 with SMTP id bb13-20020a05622a1b0d00b0043122f16974mr110306qtb.23.1710979907555; Wed, 20 Mar 2024 17:11:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710979907; cv=pass; d=google.com; s=arc-20160816; b=CJO6R6HTxifHUBAzAD9LEIMHhf86TAvYHi3r73LAg/lZeKDkccuTiQj7B+wU1gmkfd HBQmx6d+a15/B3abT2VQSoyUBiYu1PjRDE0Ba2fawzjM3MWJpE5fuI3kdMOwAQIXMZ5w YeMgQtxeUD+R6XxeEBLx1xBWrWHadnvYqRTdmaXE4U3mb5UzzDUQ5VsfhFAZPglNow07 KLeYVNYjQTeIyD34BSOFLMxbpzNgaC6iI7yVDCXNMcX0gerS/putlvQGc+osdQStBO1a ypowo7Hrzy+t5VPBiGFiX6/LoFdg7uap2PSJIA14FFAIhiW9bsvIDKyQkwzUS84tDze9 p4Dw== 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=JTaYNZjsHaHnFra9dFolcwLLda7uJXcKDeL82AgowKw=; fh=GuRA4zBSYwzG8zfJkBRiprchMjhWnEFhozWQin0R1Uo=; b=OCseKxJrotfFiXs8KZk/YL+hPTG8p8U+/WXZ7FZGJoR4yz3wS9OCAnou3P05SaF2Qe 10baJlSzptk2LF3is1mCH91/9gKF2knCtKeosYjru7SnoESDzlYGHClcN8zEDWN86jGm 1hMkN0nDAwrYHZVDu4dYc5Nt5HTEIXjxt2+zNawSL6vlpe3bAvFwZiWLctqW7ysul7d5 /4n10pnfdRM55rK5pfdR+to0R+x+Ycu2FrHDnioVRHa0/Sh55kLWdBFo2iVLZDoWRpsO HvIBVBYM52gFlrQM6yWIVc2+yqm1t2QMHWHjxSx4xYwi2cKbO/0+XqUuwecNvhQAzb+c BO2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mVyb9tD1; 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-109511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 h4-20020ac87d44000000b0042f21130918si4607543qtb.208.2024.03.20.17.11.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 17:11:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109511-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=@gmail.com header.s=20230601 header.b=mVyb9tD1; 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-109511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109511-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3C86D1C20BE0 for ; Thu, 21 Mar 2024 00:11:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 727FA469D; Thu, 21 Mar 2024 00:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mVyb9tD1" Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (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 D6EA34A00; Thu, 21 Mar 2024 00:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710979885; cv=none; b=W42HnhG/1npDIDtNC+y/6GJovVgF5Tiqa2feOkYy+X14UbIxWeDuN8fNvB0kAoBqVumOS6SsGaM2jI8fMqjSt6nJCK+cq3JsUwrh3BDrCcB4qnmfI8UuTKi11CqUih0QHjfQk78xqKC0jXQ3ncl83U4nwdzBixKEaFFLpdTB35M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710979885; c=relaxed/simple; bh=e7T+0O5vqthsMGhxsQUT0C0fpJDXb8wB0fNnxSyElEQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SKSAmC4qF065ghfVhCc7aR0WXOrN2p6ncWT3lwu6Ks64rO7ZSiMkzwZhq87ERHOS0dQ/54MapqPBWVZW2kao9yYlT5MplWBQTdICRZ22CvQ0ATjq/cSzMRhwgVWkNzYr7TS7l0P1SuP182tQ30y0v1jGtZc2Y4iu72t6H0cLVdw= 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=mVyb9tD1; arc=none smtp.client-ip=209.85.222.46 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-f46.google.com with SMTP id a1e0cc1a2514c-7db44846727so149409241.0; Wed, 20 Mar 2024 17:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710979883; x=1711584683; 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=JTaYNZjsHaHnFra9dFolcwLLda7uJXcKDeL82AgowKw=; b=mVyb9tD15kgc9EIDuDoDA7OoT6rh0ZsbPA4YcjMx+IF3kKK8JHZdPf4KS916m9IADI WLlcHa6oO3EnsjAjZKARgp7g+vUA+kiDkU1fI/5/I5yRRG0z4nNm1rURx7U8OyKcR96M puM5hA9o8nt0kzOkbmwCe15uQQmrxRS9W9Jr7EDXGrFuDF1/293k3sHOTVtDTHLYDo26 11+MvBX0VyCMbvH4Vzx6bVuF4axnkudUyiGCvSpF0w4KMCe0Avd0O8leBlcHtR5kZzTA 2GEkq0cIlk75GPehyDZZKZ98y6AhFApRR5HZH4f65xWPTHrlIChi2dbc1fSY6VTV94vd v+Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710979883; x=1711584683; 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=JTaYNZjsHaHnFra9dFolcwLLda7uJXcKDeL82AgowKw=; b=S0gU0HNm7Rhkvctmdogamdbp5U2uiu7yEdsgjT4bIJ9Fb7V1QaRotaaVBvwvgHI77C UPhe3ZEdOMD9AYYZbqoCi31tvQtXd3Bp0xooxVwh2Dd3ZXr3nJ2KPfnfh8DQokT1gZi7 Xy8WrEaJKN5756R81kkJW1VCXqi4cTrhO4fNnmbLRzciK5dejxoz1779D3bzSMy3j3rl 0nNzCdt9o89/E2s1IVvrsqbT7dbHRxMlkocJ7lf6a/5p09SjlSS/a63EdiZmw/ivnqX/ Lskw7iTpz/Ei5grXpXlzwUMLekDutH9o2dnCMehdhQSnFQRwUDZpKISA8YqkFXruvbxv weOQ== X-Forwarded-Encrypted: i=1; AJvYcCWkvtsCMm3nlxiJkjYkv3dvpMcRV12XHKRKpWGh8WVtik85hxsGyAwrc12HGU9++aUIBTfhzKEnK8sNVm/CZTFghHC3gfMwD7yf2iLm15aTkhINR6TQ5toLWei2HAv+/LSHbIIE3l0BkWf+YooFGc3oqNRE7h+X3fDisuLGQiDjaJtB X-Gm-Message-State: AOJu0Ywyw42ao8Exo08EDMlrZ/Pb3tcNh+4P22+w96UXXIMscZ9pThnw mGR0PV4jmax5p/7wqDs7duBa6phGLpAVtTyNvVwloP66dztTqiOwTH23WM8034yTUrNJ6jdDsCz pyo+XCDyQqZFGwl/9XuZ4hbSwdug= X-Received: by 2002:a67:fd8a:0:b0:473:22dc:235a with SMTP id k10-20020a67fd8a000000b0047322dc235amr287616vsq.24.1710979882644; Wed, 20 Mar 2024 17:11:22 -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> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Thu, 21 Mar 2024 13:11:11 +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 12:39=E2=80=AFPM Meiyong Yu wr= ote: > > > > 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 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' [-Wunu= sed-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/pro= cess/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 para= meters, > I do not support this point, if the parameter is unused, why not to remov= e it. > Linux boasts support for numerous architectures, striving for independence in its drivers and core code implementation across these architectures. Consequent= ly, certain architectures may utilize parameters for the same APIs, while other= s may not. > 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 > > > >