checkpatch: Eliminate false positive in case of space before square bracket in a...
authorLeonid Bloch <leonid@daynix.com>
Thu, 29 Oct 2015 09:48:38 +0000 (11:48 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 15 Feb 2016 19:02:09 +0000 (20:02 +0100)
Now, macro definition such as "#define abc(x) [x] = y" should pass
without an error.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Message-Id: <1446112118-12376-3-git-send-email-leonid@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/checkpatch.pl

index e71c3d15d1d27053c60c8e3c0bd08933bd5937fd..c26f76ed094f6431155cc6f4680f75d5eb8d0a7f 100755 (executable)
@@ -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);
                        }