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>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 27fbd88..c0688e6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4419,11 +4419,13 @@
# 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) &&