Skip to contentSkip to conversation

checkpatch: improve the STORAGE_CLASS test

PATCH New [email protected] 1 participant 1 message Jul 12, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 79/96 checkpatch: improve the STORAGE_CLASS test

From: Joe Perches <[email protected]>
Subject: checkpatch: improve the STORAGE_CLASS test

Make sure static, extern, and asmlinkage appear before a specific type.

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

---

 scripts/checkpatch.pl |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-improve-the-storage_class-test +10 -2
diff -puN scripts/checkpatch.pl~checkpatch-improve-the-storage_class-test scripts/checkpatch.pl
@@ -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

_