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 <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
parent
301d24fd88
commit
f78c51d99d
1 changed files with 2 additions and 0 deletions
|
@ -4419,11 +4419,13 @@ sub process {
|
||||||
# 1. with a type on the left -- int [] a;
|
# 1. with a type on the left -- int [] a;
|
||||||
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
|
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
|
||||||
# 3. inside a curly brace -- = { [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) {
|
while ($line =~ /(.*?\s)\[/g) {
|
||||||
my ($where, $prefix) = ($-[1], $1);
|
my ($where, $prefix) = ($-[1], $1);
|
||||||
if ($prefix !~ /$Type\s+$/ &&
|
if ($prefix !~ /$Type\s+$/ &&
|
||||||
($where != 0 || $prefix !~ /^.\s+$/) &&
|
($where != 0 || $prefix !~ /^.\s+$/) &&
|
||||||
$prefix !~ /[{,:]\s+$/ &&
|
$prefix !~ /[{,:]\s+$/ &&
|
||||||
|
$prefix !~ /\#define\s+.+\s+$/ &&
|
||||||
$prefix !~ /:\s+$/) {
|
$prefix !~ /:\s+$/) {
|
||||||
if (ERROR("BRACKET_SPACE",
|
if (ERROR("BRACKET_SPACE",
|
||||||
"space prohibited before open square bracket '['\n" . $herecurr) &&
|
"space prohibited before open square bracket '['\n" . $herecurr) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue