tools/checkpatch: fix some bogus macro warnings

checkpatch was throwing an error for "#define FOO , bar"

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2018-08-10 20:45:41 +02:00
parent 0a62b87392
commit 7aea4b8167

View File

@ -4181,7 +4181,9 @@ sub process {
} elsif ($op eq ',') { } elsif ($op eq ',') {
my $rtrim_before = 0; my $rtrim_before = 0;
my $space_after = 0; my $space_after = 0;
if ($ctx =~ /Wx./) { if ($line=~/\#\s*define/) {
# ignore , spacing in macros
} elsif ($ctx =~ /Wx./) {
if (ERROR("SPACING", if (ERROR("SPACING",
"space prohibited before that '$op' $at\n" . $hereptr)) { "space prohibited before that '$op' $at\n" . $hereptr)) {
$line_fixed = 1; $line_fixed = 1;
@ -4847,6 +4849,7 @@ sub process {
my $ctx = ''; my $ctx = '';
my $has_flow_statement = 0; my $has_flow_statement = 0;
my $has_arg_concat = 0; my $has_arg_concat = 0;
my $complex = 0;
($dstat, $dcond, $ln, $cnt, $off) = ($dstat, $dcond, $ln, $cnt, $off) =
ctx_statement_block($linenr, $realcnt, 0); ctx_statement_block($linenr, $realcnt, 0);
$ctx = $dstat; $ctx = $dstat;
@ -4865,6 +4868,7 @@ sub process {
$define_args = substr($define_args, 1, length($define_args) - 2); $define_args = substr($define_args, 1, length($define_args) - 2);
$define_args =~ s/\s*//g; $define_args =~ s/\s*//g;
@def_args = split(",", $define_args); @def_args = split(",", $define_args);
$complex = 1;
} }
$dstat =~ s/$;//g; $dstat =~ s/$;//g;
@ -4932,7 +4936,7 @@ sub process {
} elsif ($dstat =~ /;/) { } elsif ($dstat =~ /;/) {
ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
"Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx"); "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
} else { } elsif ($complex) {
ERROR("COMPLEX_MACRO", ERROR("COMPLEX_MACRO",
"Macros with complex values should be enclosed in parentheses\n" . "$herectx"); "Macros with complex values should be enclosed in parentheses\n" . "$herectx");
} }