[PATCH 1/5] checkpatch: fix false errors due to macro concatenation

From: Daniel Walker
Date: Mon Sep 21 2009 - 22:15:24 EST


The macro concatenation (##) sequence can cause false errors when checking
macro's. Checkpatch doesn't currently know about the operator.

For example this line,

+ entry = (struct ftrace_raw_##call *)raw_data; \

is correct but it produces the following error,

ERROR: need consistent spacing around '*' (ctx:WxB)
+ entry = (struct ftrace_raw_##call *)raw_data;\
^

The line above doesn't have any spacing problems, and if you remove the
macro concatenation sequence checkpatch doesn't give any errors. This change
resolves this by just always removing "##" in every line checked.

Signed-off-by: Daniel Walker <dwalker@xxxxxxxxxx>
---
scripts/checkpatch.pl | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2d5ece7..09bab22 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -397,6 +397,11 @@ sub sanitise_line {
$res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
}

+ # The macro concatenation sequence is unique so we can just delete it.
+ # If it's not deleted it screws up the rest of the matching and can
+ # result in false errors.
+ $res =~ s/($Ident|\s)\s*\#\#\s*($Ident|\s)/$1$2/g;
+
return $res;
}

--
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/