aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-02-13 17:38:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:40 -0500
commitd2e025f364369dbe0a7dee1b15f198f5718f246a (patch)
treefd9ea907fadb15c1b7f87c8b2111ec6098f4f924 /scripts
parent101ee6802a77d3a8f42538360a5e9c3f17d5d5b5 (diff)
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl17
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bf232642cbb3..32bd31c1345c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3689,7 +3689,22 @@ sub process {
3689 $op eq '*' or $op eq '/' or 3689 $op eq '*' or $op eq '/' or
3690 $op eq '%') 3690 $op eq '%')
3691 { 3691 {
3692 if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { 3692 if ($check) {
3693 if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) {
3694 if (CHK("SPACING",
3695 "spaces preferred around that '$op' $at\n" . $hereptr)) {
3696 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
3697 $fix_elements[$n + 2] =~ s/^\s+//;
3698 $line_fixed = 1;
3699 }
3700 } elsif (!defined $fix_elements[$n + 2] && $ctx !~ /Wx[OE]/) {
3701 if (CHK("SPACING",
3702 "space preferred before that '$op' $at\n" . $hereptr)) {
3703 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]);
3704 $line_fixed = 1;
3705 }
3706 }
3707 } elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
3693 if (ERROR("SPACING", 3708 if (ERROR("SPACING",
3694 "need consistent spacing around '$op' $at\n" . $hereptr)) { 3709 "need consistent spacing around '$op' $at\n" . $hereptr)) {
3695 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; 3710 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";