[PATCH 38/61] checkpatch: dont warn about unused macro arg on empty body

Jim Cromie jim.cromie at gmail.com
Wed Sep 25 18:10:30 UTC 2024


we currently get:
  WARNING: Argument 'name' is not used in function-like macro
on:
  #define DRM_CLASSMAP_USE(name)  /* nothing here */

Following this advice is wrong here; the macro should properly fail
if invoked with 0 or 2+ args.

Signed-off-by: Jim Cromie <jim.cromie at gmail.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a10dca447e34..b57d57fe5f06 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6051,7 +6051,7 @@ sub process {
 				}
 
 # check if this is an unused argument
-				if ($define_stmt !~ /\b$arg\b/) {
+				if ($define_stmt !~ /\b$arg\b/ && $define_stmt) {
 					WARN("MACRO_ARG_UNUSED",
 					     "Argument '$arg' is not used in function-like macro\n" . "$herectx");
 				}
-- 
2.46.1



More information about the Intel-gfx-trybot mailing list