Skip to content

Commit

Permalink
checkpatch: Add exception to BRACKED_SPACE rule for macros
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rugeGerritsen authored and nashif committed Jun 14, 2024
1 parent 301d24f commit f78c51d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4419,11 +4419,13 @@ sub process {
# 1. with a type on the left -- int [] a;
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
# 3. inside a curly brace -- = { [0...10] = 5 }
# 4. inside macro arguments, example: #define HCI_ERR(err) [err] = #err
while ($line =~ /(.*?\s)\[/g) {
my ($where, $prefix) = ($-[1], $1);
if ($prefix !~ /$Type\s+$/ &&
($where != 0 || $prefix !~ /^.\s+$/) &&
$prefix !~ /[{,:]\s+$/ &&
$prefix !~ /\#define\s+.+\s+$/ &&
$prefix !~ /:\s+$/) {
if (ERROR("BRACKET_SPACE",
"space prohibited before open square bracket '['\n" . $herecurr) &&
Expand Down

0 comments on commit f78c51d

Please sign in to comment.