Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1000633lqz; Sun, 31 Mar 2024 08:54:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoeqMVM9lN97/xRWiCD6biMn9JGvQ1dTLvcgBVNUxTzayP/fN04kEckdnma8S5rCGEXmM7p4grBJVB3zUG8Z8ctLsp8PhenbPvA1mWxg== X-Google-Smtp-Source: AGHT+IF5Dbu8VY/srONRa+bA0rD0ETUgh1R5uTVmItZwFKZ4UvHzxwjzH5eReCkhSHvi5V+VCLdr X-Received: by 2002:a05:622a:59c4:b0:432:d61c:7fb with SMTP id gc4-20020a05622a59c400b00432d61c07fbmr4466246qtb.40.1711900465438; Sun, 31 Mar 2024 08:54:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711900465; cv=pass; d=google.com; s=arc-20160816; b=nCX9cRpgAVRGncD+GVsLzqVI0AouHzEH+3TZRd0hr6iueTTvgSpnQiINUx4O7BRWVP LK8jGazOS13YvoABbYfGQ1JCueTVHpbtAmixk8f6F91pnyUcrHT1L2D/3UxXgr33sqlr N7ZKMuneuMGSDsIG6TnBrb0HRyevxLlLQdNTh5LbTLnkn1jWu5XNI18BkSOJ/EkbUpp/ qRESM4EdVd04XnfJOBFPUThO53s+p0MYQy7v3tSYKd2R49iLCG3w9Ix3PQjKhIi5AC4K TiXMSJt59ptSfr0u9EzBBPQJ+uhdkSlpQhSxm3piRW8F6mGsMA1AhSErMuShYK2sd3HE v16g== 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 :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=Y68C4PXili+bDqmawrX1Q/HtYG1L4zX9ua4fut2568I=; fh=Y0wVyFiiyZf9Tl+cMHeZJyZB+pKaSxAwNSca3bXXPxU=; b=XSKKbYDapnrTCn7wEPVFA/2Za50lww62sKa0X+ZWQx2NzFaE0tyhfjh2D1g78vCb9o t1jqXlGrZJrl7RCvG+DXOX6l8DlnM4mTTPr6TqDnTXXbtg7jiq2UpCfCDry0NH3odsdW B4zdNScqFpcWRl7nI1Ju8tRMCwOUrH/4QG9thEfwf1UqSYhIYWxhKz6T1WIhRZ7YyIWd mvh+IAlDxBKzGuebpLGgOwxgzkPChFI2yp9uhc6iZaPsIgm7Ixza7lTewRsWfw/UFAcP u36CleYFJEcKO+iIMd09xuAtH2YROJdqADR2wUbPVoxbbdlB/lLNHZnVsbStLQcfHtRi gI0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-kernel+bounces-126097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126097-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v10-20020a05622a014a00b00432f2045bf8si301233qtw.546.2024.03.31.08.54.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 08:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-kernel+bounces-126097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126097-linux.lists.archive=gmail.com@vger.kernel.org" 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 20AC31C20C4F for ; Sun, 31 Mar 2024 15:54:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B930E145347; Sun, 31 Mar 2024 15:54:17 +0000 (UTC) Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) (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 61CCF1E531; Sun, 31 Mar 2024 15:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711900457; cv=none; b=fKj0zSdq1Fj4YEXbFCrCjeTp5LMDZz0GCLaD34UC/bnb6txP1rwzO4BBsTv8KUsH4OR416adoEIH/Dtxlk9HjqU6qOxAAKi9mTU4vRBswzNDo/IRzg0dJwQemzkfk2DMha14HeCjow4NrDwpRtPh8hwQi0FbRj1iSg8abKaqFyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711900457; c=relaxed/simple; bh=Uc1KW8hGMIQWMXsj9q7n3Os7KrFYC2VKY3GqwMRyHGw=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=gcfYs3YO68pl6vLX4J28WJ6ZsevJDtuZBRlj7WtTyRLLBk7GIe8xlf6TEGzHY5+53k3lta0JCgFhaZAzBU+Vjj9jUfdDonQ7DuzaAeV8yTNDyIS+geLPLgALTl5ZPUI4qAJeu2rznCGjY45rVyoSwvcC+gntP3hDOn4I4Pm5P3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7CA7A120179; Sun, 31 Mar 2024 15:54:06 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf17.hostedemail.com (Postfix) with ESMTPA id 500E818; Sun, 31 Mar 2024 15:54:01 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4 2/2] scripts: checkpatch: check unused parameters for function-like macro From: Joe Perches To: Mac Xu , Barry Song <21cnbao@gmail.com>, "akpm@linux-foundation.org" , "linux-doc@vger.kernel.org" Cc: "apw@canonical.com" , "broonie@kernel.org" , "chenhuacai@loongson.cn" , "chris@zankel.net" , "corbet@lwn.net" , "dwaipayanray1@gmail.com" , "herbert@gondor.apana.org.au" , "linux-kernel@vger.kernel.org" , "linux@roeck-us.net" , "lukas.bulwahn@gmail.com" , "sfr@canb.auug.org.au" , "v-songbaohua@oppo.com" , "workflows@vger.kernel.org" , Max Filippov Date: Sun, 31 Mar 2024 08:54:00 -0700 In-Reply-To: References: <20240328022136.5789-1-21cnbao@gmail.com> <20240328022136.5789-3-21cnbao@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Stat-Signature: uh6mfa15t5g7ucfaa49qh8ezswwjjfa6 X-Rspamd-Server: rspamout03 X-Rspamd-Queue-Id: 500E818 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/5kpa60OO0mgDP7ujpRGtlQZspuLjxAzI= X-HE-Tag: 1711900441-273597 X-HE-Meta: U2FsdGVkX1908fgJHnjrmlQdMn0+SlRyYy9HNNP+vxv3r8Dv6hY3i1jH2e/PW52vPDrGBkukRRP34YWAi41zHWzF2+JzgJwH+a5kY5/BTZCqJos60SwH3/8lneEFYkA3EYsSONF8Zx2ofUys7sq61qWoGu2oZ2eKumioqAz4U97aeIgt60V0cfoZWWoh2jZV41pbc6cWG4r6RnmQsE6ye440giOES4u0TaPzhiXX9Cg+lpIoAB2w142cfkPG3ZVRvESF98G7mWSmU0QgX2X5G8YmGuW2oILSgnxZA4+ud6j4We2iuxpeh76MBM83uHqCCFZzG8Y/nRZdE58QFAJibP3yRQ2NWtTm On Sun, 2024-03-31 at 13:46 +0000, Mac Xu wrote: > > On Thu, 2024-03-28 at 15:21 +1300, Barry Song wrote: > > > From: Xining Xu > > >=20 > > > If function-like macros do not utilize a parameter, it might result i= n a > > > build warning. In our coding style guidelines, we advocate for utili= zing > > > static inline functions to replace such macros. This patch verifies > > > compliance with the new rule. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl >=20 [] > > It seems this logic is a bit redundant to existing > > code and might be better added in the block that starts > >=20 > > (line 6026) > > # check if any macro arguments are reused (ignore '...' and 'type') > >=20 > > as that already does each param in a #define and > > ignores ... and type >=20 > Hi Joe, >=20 > Thank you for your comments with insights, as you said, code block of lin= e 6026 is a better place to=20 > place this new logic, as it already handles the logic I'd wanted like ext= racting, splitting and trimming=20 > the arguments, excluding the trailing comments etc. >=20 > By placing the logic in the new place, code duplicates are reduced. >=20 > Here's my new code (inserted from line 6044): > +# check if this is an unused argument > + if ($define_stmt !~ /\b$arg\b/) { > + WARN("UNUSED_ARG_IN_MACRO", Perhaps WARN("MACRO_ARG_UNUSED", ... to better match the others above it in the block: CHK("MACRO_ARG_REUSE", and CHK("MACRO_ARG_PRECEDENCE", Other than that trivial bit, seems ok.