Commit 8800cf0a authored by Leonid Bloch's avatar Leonid Bloch Committed by Paolo Bonzini

checkpatch: Eliminate false positive in case of space before square bracket in a definition

Now, macro definition such as "#define abc(x) [x] = y" should pass
without an error.
Signed-off-by: 's avatarLeonid Bloch <leonid@daynix.com>
Message-Id: <1446112118-12376-3-git-send-email-leonid@daynix.com>
Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
parent 409db6eb
...@@ -1716,11 +1716,13 @@ sub process { ...@@ -1716,11 +1716,13 @@ sub process {
# 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. after a comma -- [1] = 5, [2] = 6 # 4. after a comma -- [1] = 5, [2] = 6
# 5. in a macro definition -- #define abc(x) [x] = y
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 !~ /\#\s*define[^(]*\([^)]*\)\s+$/ &&
$prefix !~ /,\s+$/) { $prefix !~ /,\s+$/) {
ERROR("space prohibited before open square bracket '['\n" . $herecurr); ERROR("space prohibited before open square bracket '['\n" . $herecurr);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment