From f78c51d99d1fc6deb9ec2e76e50f32fee56e8621 Mon Sep 17 00:00:00 2001 From: Rubin Gerritsen Date: Fri, 7 Jun 2024 14:57:32 +0200 Subject: [PATCH] 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 --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 27fbd880ef6397..c0688e6274182d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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) &&