History

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.

Andy Whitcroft committed 18 years ago

Commit 8d31cfc1 parent e2a763c1 file · +11 −0Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+11−0
@@ -1435,6 +1435,17 @@ sub process { · 1434 unmodified lines
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;