History

checkpatch: fix a number of COMPLEX_MACRO false positives

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.

Vladimir Zapolskiy committed 10 years ago

Commit 6b10df41 parent 62e15a61 file · +3 −2Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+3−2
@@ -4550,7 +4550,7 @@ sub process { · 4549 unmodified lines
45504550 # Flatten any parentheses and braces
45514551 while ($dstat =~ s/\([^\(\)]*\)/1/ ||
45524552 $dstat =~ s/\{[^\{\}]*\}/1/ ||
4553− $dstat =~ s/\[[^\[\]]*\]/1/)
4553+ $dstat =~ s/.\[[^\[\]]*\]/1/)
45544554 {
45554555 }
45564556
@@ -4570,7 +4570,8 @@ sub process { · 13 unmodified lines
45704570 union|
45714571 struct|
45724572 \.$Ident\s*=\s*|
4573− ^\"|\"$
4573+ ^\"|\"$|
4574+ ^\[
45744575 }x;
45754576 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
45764577 if ($dstat ne '' &&