1
0
Fork 0

checkpatch: add --strict test for spaces around arithmetic

Some prefer code to have spaces around arithmetic so instead of:
        a = b*c+d;
suggest
        a = b * c + d;

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
hifive-unleashed-5.1
Joe Perches 2015-02-13 14:38:57 -08:00 committed by Linus Torvalds
parent 101ee6802a
commit d2e025f364
1 changed files with 16 additions and 1 deletions

View File

@ -3689,7 +3689,22 @@ sub process {
$op eq '*' or $op eq '/' or
$op eq '%')
{
if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
if ($check) {
if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) {
if (CHK("SPACING",
"spaces preferred around that '$op' $at\n" . $hereptr)) {
$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
$fix_elements[$n + 2] =~ s/^\s+//;
$line_fixed = 1;
}
} elsif (!defined $fix_elements[$n + 2] && $ctx !~ /Wx[OE]/) {
if (CHK("SPACING",
"space preferred before that '$op' $at\n" . $hereptr)) {
$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]);
$line_fixed = 1;
}
}
} elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
if (ERROR("SPACING",
"need consistent spacing around '$op' $at\n" . $hereptr)) {
$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";