OSDN Git Service

checkpatch: improve "no space necessary after cast" test
authorJoe Perches <joe@perches.com>
Fri, 13 Feb 2015 22:38:52 +0000 (14:38 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:40 +0000 (21:21 -0800)
Code like:
if (a < sizeof(<type>) &&
and
{ .len = sizeof(<type>) },

incorrectly emits that warning, so add more exceptions to avoid
the warning.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 7f1804e..a9baaab 100755 (executable)
@@ -2541,7 +2541,7 @@ sub process {
                        }
                }
 
-               if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;\({\[\<\>])/ &&
+               if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ &&
                    (!defined($1) || $1 !~ /sizeof\s*/)) {
                        if (CHK("SPACING",
                                "No space is necessary after a cast\n" . $herecurr) &&