diff options
| author | Joe Perches <joe@perches.com> | 2017-07-12 17:37:02 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-12 19:26:04 -0400 |
| commit | 596ed45b5b5b7e4624c813ddeffe0e100f8b13ba (patch) | |
| tree | bbd32af5df774f80235fefdf2c332ac8630021c4 /scripts/checkpatch.pl | |
| parent | 0f55685627d6dd2beda55a82abc02297f0f8e5c2 (diff) | |
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)
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>
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8f940c09918f..2287a0bca863 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -5576,10 +5576,18 @@ sub process { | |||
| 5576 | "architecture specific defines should be avoided\n" . $herecurr); | 5576 | "architecture specific defines should be avoided\n" . $herecurr); |
| 5577 | } | 5577 | } |
| 5578 | 5578 | ||
| 5579 | # check that the storage class is not after a type | ||
| 5580 | if ($line =~ /\b($Type)\s+($Storage)\b/) { | ||
| 5581 | WARN("STORAGE_CLASS", | ||
| 5582 | "storage class '$2' should be located before type '$1'\n" . $herecurr); | ||
| 5583 | } | ||
| 5579 | # Check that the storage class is at the beginning of a declaration | 5584 | # Check that the storage class is at the beginning of a declaration |
| 5580 | if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) { | 5585 | if ($line =~ /\b$Storage\b/ && |
| 5586 | $line !~ /^.\s*$Storage/ && | ||
| 5587 | $line =~ /^.\s*(.+?)\$Storage\s/ && | ||
| 5588 | $1 !~ /[\,\)]\s*$/) { | ||
| 5581 | WARN("STORAGE_CLASS", | 5589 | WARN("STORAGE_CLASS", |
| 5582 | "storage class should be at the beginning of the declaration\n" . $herecurr) | 5590 | "storage class should be at the beginning of the declaration\n" . $herecurr); |
| 5583 | } | 5591 | } |
| 5584 | 5592 | ||
| 5585 | # check the location of the inline attribute, that it is between | 5593 | # check the location of the inline attribute, that it is between |
