From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,v-songbaohua@oppo.com,sfr@canb.auug.org.au,lukas.bulwahn@gmail.com,linux@roeck-us.net,joe@perches.com,jcmvbkbc@gmail.com,herbert@gondor.apana.org.au,dwaipayanray1@gmail.com,corbet@lwn.net,chris@zankel.net,chenhuacai@loongson.cn,broonie@kernel.org,apw@canonical.com,ma.xxn@outlook.com,akpm@linux-foundation.org
Subject: [to-be-updated] scripts-checkpatch-check-unused-parameters-for-function-like-macro.patch removed from -mm tree
Date: Fri, 29 Mar 2024 19:58:58 -0700 [thread overview]
Message-ID: <20240330025859.19A89C433C7@smtp.kernel.org> (raw)
The quilt patch titled
Subject: scripts: checkpatch: check unused parameters for function-like macro
has been removed from the -mm tree. Its filename was
scripts-checkpatch-check-unused-parameters-for-function-like-macro.patch
This patch was dropped because an updated version will be merged
------------------------------------------------------
From: Xining Xu <ma.xxn@outlook.com>
Subject: scripts: checkpatch: check unused parameters for function-like macro
Date: Fri, 22 Mar 2024 21:49:37 +1300
If function-like macros do not utilize a parameter, it might result in a
build warning. In our coding style guidelines, we advocate for utilizing
static inline functions to replace such macros. This patch verifies
compliance with the new rule.
For a macro such as the one below,
#define test(a) do { } while (0)
The test result is as follows.
ERROR: Parameter 'a' is not used in function-like macro, please use static
inline instead
#21: FILE: mm/init-mm.c:20:
+#define test(a) do { } while (0)
total: 1 errors, 0 warnings, 8 lines checked
Link: https://lkml.kernel.org/r/20240322084937.66018-3-21cnbao@gmail.com
Signed-off-by: Xining Xu <ma.xxn@outlook.com>
Tested-by: Barry Song <v-songbaohua@oppo.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Mark Brown <broonie@kernel.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
scripts/checkpatch.pl | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
--- a/scripts/checkpatch.pl~scripts-checkpatch-check-unused-parameters-for-function-like-macro
+++ a/scripts/checkpatch.pl
@@ -6109,6 +6109,30 @@ sub process {
WARN("TRAILING_SEMICOLON",
"macros should not use a trailing semicolon\n" . "$herectx");
}
+
+ if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*(\((?:[^\(\)]++|(?-1))*\))\s+(\S+.*)(\/\/.*)?/) {
+ my $params = $1 || "";
+ my $body = $2 || "";
+
+ # get the individual params
+ $params =~ tr/()//d;
+ # remove leading and trailing whitespace
+ $params =~ s/^\s+|\s+$//g;
+
+ $ctx =~ s/\n*$//;
+ my $cnt = statement_rawlines($ctx);
+ my $herectx = get_stat_here($linenr, $cnt, $here);
+
+ if ($params ne "") {
+ my @paramList = split /,\s*/, $params;
+ foreach my $param(@paramList) {
+ if ($body !~ /\b$param\b/) {
+ ERROR("UNUSED_PARAM_IN_MACRO",
+ "Parameter '$param' is not used in function-like macro, please use static inline instead\n" . "$herectx");
+ }
+ }
+ }
+ }
}
# check for redundant bracing round if etc
_
Patches currently in -mm which might be from ma.xxn@outlook.com are
reply other threads:[~2024-03-30 2:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240330025859.19A89C433C7@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=broonie@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=chris@zankel.net \
--cc=corbet@lwn.net \
--cc=dwaipayanray1@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=jcmvbkbc@gmail.com \
--cc=joe@perches.com \
--cc=linux@roeck-us.net \
--cc=lukas.bulwahn@gmail.com \
--cc=ma.xxn@outlook.com \
--cc=mm-commits@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=v-songbaohua@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.