[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] checkpatch: Eliminate false positive in case of
From: |
Leonid Bloch |
Subject: |
[Qemu-devel] [PATCH 2/2] checkpatch: Eliminate false positive in case of space before square bracket in a definition |
Date: |
Thu, 29 Oct 2015 11:48:38 +0200 |
Now, macro definition such as "#define abc(x) [x] = y" should pass
without an error.
Signed-off-by: Leonid Bloch <address@hidden>
---
scripts/checkpatch.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 455d94b..e7d9cce 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1716,11 +1716,13 @@ sub process {
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
# 3. inside a curly brace -- = { [0...10] = 5 }
# 4. after a comma -- [1] = 5, [2] = 6
+# 5. in a macro definition -- #define abc(x) [x] = y
while ($line =~ /(.*?\s)\[/g) {
my ($where, $prefix) = ($-[1], $1);
if ($prefix !~ /$Type\s+$/ &&
($where != 0 || $prefix !~ /^.\s+$/) &&
$prefix !~ /{\s+$/ &&
+ $prefix !~ /\#\s*define[^(]*\([^)]*\)\s+$/ &&
$prefix !~ /,\s+$/) {
ERROR("space prohibited before open square
bracket '['\n" . $herecurr);
}
--
2.4.3