]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
checkpatch: improve the STORAGE_CLASS test
authorJoe Perches <joe@perches.com>
Wed, 12 Jul 2017 21:37:02 +0000 (14:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Jul 2017 23:26:04 +0000 (16:26 -0700)
Make sure static, extern, and asmlinkage appear before a specific type.

e.g.:
int asmlinkage foo(void)
is better written
       asmlinkage int foo(void)

Link: http://lkml.kernel.org/r/31704c96df2d5fd9df0b41165940a7a4feb16a63.1499284835.git.joe@perches.com
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 8f940c09918f0e6c8971535030f92fccb0f073d5..2287a0bca863bf57ffabaae9de58aab0174826c3 100755 (executable)
@@ -5576,10 +5576,18 @@ sub process {
                            "architecture specific defines should be avoided\n" .  $herecurr);
                }
 
+# check that the storage class is not after a type
+               if ($line =~ /\b($Type)\s+($Storage)\b/) {
+                       WARN("STORAGE_CLASS",
+                            "storage class '$2' should be located before type '$1'\n" . $herecurr);
+               }
 # Check that the storage class is at the beginning of a declaration
-               if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
+               if ($line =~ /\b$Storage\b/ &&
+                   $line !~ /^.\s*$Storage/ &&
+                   $line =~ /^.\s*(.+?)\$Storage\s/ &&
+                   $1 !~ /[\,\)]\s*$/) {
                        WARN("STORAGE_CLASS",
-                            "storage class should be at the beginning of the declaration\n" . $herecurr)
+                            "storage class should be at the beginning of the declaration\n" . $herecurr);
                }
 
 # check the location of the inline attribute, that it is between