Skip to content

Commit f78c51d

Browse files
rugeGerritsennashif
authored andcommitted
checkpatch: Add exception to BRACKED_SPACE rule for macros
When brackets are used in macros, there may sometimes be a space in front of them. The checkpatch script should allow this. The change includes the example that triggered the need for this change. Signed-off-by: Rubin Gerritsen <[email protected]>
1 parent 301d24f commit f78c51d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

scripts/checkpatch.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4419,11 +4419,13 @@ sub process {
44194419
# 1. with a type on the left -- int [] a;
44204420
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
44214421
# 3. inside a curly brace -- = { [0...10] = 5 }
4422+
# 4. inside macro arguments, example: #define HCI_ERR(err) [err] = #err
44224423
while ($line =~ /(.*?\s)\[/g) {
44234424
my ($where, $prefix) = ($-[1], $1);
44244425
if ($prefix !~ /$Type\s+$/ &&
44254426
($where != 0 || $prefix !~ /^.\s+$/) &&
44264427
$prefix !~ /[{,:]\s+$/ &&
4428+
$prefix !~ /\#define\s+.+\s+$/ &&
44274429
$prefix !~ /:\s+$/) {
44284430
if (ERROR("BRACKET_SPACE",
44294431
"space prohibited before open square bracket '['\n" . $herecurr) &&

0 commit comments

Comments
 (0)