Skip to content

Commit

Permalink
checkpatch: fix a number of COMPLEX_MACRO false positives
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Joe Perches <[email protected]>
Cc: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
vzapolskiy authored and torvalds committed Jan 21, 2016
1 parent 62e15a6 commit 6b10df4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4550,7 +4550,7 @@ sub process {
# Flatten any parentheses and braces
while ($dstat =~ s/\([^\(\)]*\)/1/ ||
$dstat =~ s/\{[^\{\}]*\}/1/ ||
$dstat =~ s/\[[^\[\]]*\]/1/)
$dstat =~ s/.\[[^\[\]]*\]/1/)
{
}

Expand All @@ -4570,7 +4570,8 @@ sub process {
union|
struct|
\.$Ident\s*=\s*|
^\"|\"$
^\"|\"$|
^\[
}x;
#print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
if ($dstat ne '' &&
Expand Down

0 comments on commit 6b10df4

Please sign in to comment.