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>
This commit is contained in:
parent
101ee6802a
commit
d2e025f364
|
@ -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]) . " ";
|
||||
|
|
Loading…
Reference in New Issue