public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives
@ 2015-10-29 21:36 Vladimir Zapolskiy
  2015-10-29 22:46 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Zapolskiy @ 2015-10-29 21:36 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft; +Cc: Andrew Morton, linux-kernel

A simple search over the kernel souce displays a number of correctly
defined multiline macro, which generally are used as an array element
initializer:

% find ../linux -type f | xargs grep -B1 -H '^[:space]*\[.*\\$'

However checkpatch.pl unexpectedly complains about all these macro
definitions:

% ./scripts/checkpatch.pl --types COMPLEX_MACRO -f include/linux/perf/arm_pmu.h

ERROR: Macros with complex values should be enclosed in parentheses
+#define PERF_MAP_ALL_UNSUPPORTED					\
+	 [0 ... PERF_COUNT_HW_MAX - 1] = HW_OP_UNSUPPORTED

The change intends to fix this type of false positives by flattening
only array members and skipping array element designators.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 scripts/checkpatch.pl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f2a1131..3882893 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4526,7 +4526,7 @@ sub process {
 			# Flatten any parentheses and braces
 			while ($dstat =~ s/\([^\(\)]*\)/1/ ||
 			       $dstat =~ s/\{[^\{\}]*\}/1/ ||
-			       $dstat =~ s/\[[^\[\]]*\]/1/)
+			       $dstat =~ s/.\[[^\[\]]*\]/1/)
 			{
 			}
 
@@ -4546,7 +4546,8 @@ sub process {
 				union|
 				struct|
 				\.$Ident\s*=\s*|
-				^\"|\"$
+				^\"|\"$|
+				^\[
 			}x;
 			#print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
 			if ($dstat ne '' &&
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-10 18:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29 21:36 [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives Vladimir Zapolskiy
2015-10-29 22:46 ` Joe Perches
2015-10-29 23:52   ` Vladimir Zapolskiy
2015-11-10 18:01     ` Vladimir Zapolskiy
2015-11-10 18:08       ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox