* [PATCH] scripts: macro_checker: match parameter identifier boundaries
@ 2026-11-03 16:42 Hamdy Abou El Anein
0 siblings, 0 replies; only message in thread
From: Hamdy Abou El Anein @ 2026-11-03 16:42 UTC (permalink / raw)
To: sunjunchao2870; +Cc: hamdy.aea, linux-kernel
From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
A substring search treats value as used by other_value. This hides
unused parameters and can mark the macro as correct in the initial
scan, suppressing its report in the second scan.
Match identifier boundaries around each parameter. Preserve whitespace
before a continued line so that joining the replacement list does not
merge an argument with the preceding identifier.
Tested an unused value parameter next to other_value, direct use,
stringification, token pasting and a continued replacement list.
AI assistance: ChatGPT/Codex identified the issue and prepared the
change, commit message and executable regression tests.
Fixes: d1c7848b58c6 ("scripts: add macro_checker script to check unused parameters in macros")
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
scripts/macro_checker.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/macro_checker.py b/scripts/macro_checker.py
index ba550982e98..9a67b16dac9 100755
--- a/scripts/macro_checker.py
+++ b/scripts/macro_checker.py
@@ -47,10 +47,11 @@ def check_macro(macro_line, report):
if "..." in arg:
return
for arg in arguments:
- if not arg in macro_def and report == False:
+ used = re.search(r"\b" + re.escape(arg) + r"\b", macro_def)
+ if not used and report == False:
return
# if there is a correct macro with the same name, do not report it.
- if not arg in macro_def and identifier not in correct_macros:
+ if not used and identifier not in correct_macros:
print(f"Argument {arg} is not used in function-line macro {identifier}")
return
@@ -93,7 +94,6 @@ def file_check_macro(file_path, report):
macro = macro_strip(macro.string)
while macro[-1] == '\\':
macro = macro[0:-1]
- macro = macro.strip()
macro += f.readline()
macro = macro_strip(macro)
if not args.verbose:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 16:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 16:42 [PATCH] scripts: macro_checker: match parameter identifier boundaries Hamdy Abou El Anein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®