diff options
author | Joe Perches <joe@perches.com> | 2014-12-10 18:51:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 20:41:11 -0500 |
commit | 2381097b6c9b8621797a717c0b199f780ecaa992 (patch) | |
tree | 9209e3eb909d3b9aab1ab762fee4270e5da17b3e /scripts | |
parent | 69c953c85c6cca85565ab32e4264b2efb6272e0e (diff) |
checkpatch: add an error test for no space before comma
Using code like:
int foo , bar;
is not preferred to:
int foo, bar;
so emit an error on this style.
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-x | scripts/checkpatch.pl | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 374abf443636..696254eee78b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -3563,14 +3563,33 @@ sub process { | |||
3563 | } | 3563 | } |
3564 | } | 3564 | } |
3565 | 3565 | ||
3566 | # , must have a space on the right. | 3566 | # , must not have a space before and must have a space on the right. |
3567 | } elsif ($op eq ',') { | 3567 | } elsif ($op eq ',') { |
3568 | my $rtrim_before = 0; | ||
3569 | my $space_after = 0; | ||
3570 | if ($ctx =~ /Wx./) { | ||
3571 | if (ERROR("SPACING", | ||
3572 | "space prohibited before that '$op' $at\n" . $hereptr)) { | ||
3573 | $line_fixed = 1; | ||
3574 | $rtrim_before = 1; | ||
3575 | } | ||
3576 | } | ||
3568 | if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { | 3577 | if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { |
3569 | if (ERROR("SPACING", | 3578 | if (ERROR("SPACING", |
3570 | "space required after that '$op' $at\n" . $hereptr)) { | 3579 | "space required after that '$op' $at\n" . $hereptr)) { |
3571 | $good = $fix_elements[$n] . trim($fix_elements[$n + 1]) . " "; | ||
3572 | $line_fixed = 1; | 3580 | $line_fixed = 1; |
3573 | $last_after = $n; | 3581 | $last_after = $n; |
3582 | $space_after = 1; | ||
3583 | } | ||
3584 | } | ||
3585 | if ($rtrim_before || $space_after) { | ||
3586 | if ($rtrim_before) { | ||
3587 | $good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]); | ||
3588 | } else { | ||
3589 | $good = $fix_elements[$n] . trim($fix_elements[$n + 1]); | ||
3590 | } | ||
3591 | if ($space_after) { | ||
3592 | $good .= " "; | ||
3574 | } | 3593 | } |
3575 | } | 3594 | } |
3576 | 3595 | ||