mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hamdy Abou El Anein <info@daylightlinux.ch>
To: sunjunchao2870@gmail.com
Cc: hamdy.aea@protonmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH] scripts: macro_checker: match parameter identifier boundaries
Date: Tue,  3 Nov 2026 17:42:05 +0100	[thread overview]
Message-ID: <20261103164205.129713-1-info@daylightlinux.ch> (raw)

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:

                 reply	other threads:[~2026-11-03 16:42 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=20261103164205.129713-1-info@daylightlinux.ch \
    --to=info@daylightlinux.ch \
    --cc=hamdy.aea@protonmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sunjunchao2870@gmail.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 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®