[PATCH] scripts: macro_checker: match parameter identifier boundaries

From: Hamdy Abou El Anein

Date: Tue Nov 03 2026 - 13:14:40 EST


From: Hamdy Abou El Anein <hamdy.aea@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
---
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: