diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-07-24 00:29:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:25 -0400 |
commit | 8d31cfcecf67563d70cd68616cb8fb4384f24b51 (patch) | |
tree | edfe965d3efa84305a9c6fe83ecfe24b97bdc7fb /scripts | |
parent | e2a763c20b89890d2153551b1af6962b135de4c0 (diff) |
checkpatch: check spacing for square brackets
Check on the spacing before square brackets. We should only allow spaces
there if this is part of a type definition or an initialialiser.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
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 | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5f71b3050253..e7c8ab1b54bd 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1435,6 +1435,17 @@ sub process { | |||
1435 | ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); | 1435 | ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | # check for spacing round square brackets; allowed: | ||
1439 | # 1. with a type on the left -- int [] a; | ||
1440 | # 2. at the beginning of a line for slice initialisers -- [0..10] = 5, | ||
1441 | while ($line =~ /(.*?\s)\[/g) { | ||
1442 | my ($where, $prefix) = ($-[1], $1); | ||
1443 | if ($prefix !~ /$Type\s+$/ && | ||
1444 | ($where != 0 || $prefix !~ /^.\s+$/)) { | ||
1445 | ERROR("space prohibited before open square bracket '['\n" . $herecurr); | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1438 | # check for spaces between functions and their parentheses. | 1449 | # check for spaces between functions and their parentheses. |
1439 | while ($line =~ /($Ident)\s+\(/g) { | 1450 | while ($line =~ /($Ident)\s+\(/g) { |
1440 | my $name = $1; | 1451 | my $name = $1; |