aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-09-11 17:23:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:58:43 -0400
commit70dc8a48357ce630d8a76887a9a36f0d34c8caf2 (patch)
treeaba8963ae8efcc2c6ecaa5cb495e53254fa9d7fc /scripts/checkpatch.pl
parent7e51f1979237e01bcd4e04e434c5da79151f08f8 (diff)
checkpatch: warn when using extern with function prototypes in .h files
Using the extern keyword on function prototypes is superfluous visual noise so suggest removing it. Using extern can cause unnecessary line wrapping at 80 columns and unnecessarily long multi-line function prototypes. Signed-off-by: Joe Perches <joe@perches.com> Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org> 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-xscripts/checkpatch.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7c79c91662c8..e2cb1f4621b7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3878,6 +3878,16 @@ sub process {
3878 } 3878 }
3879 } 3879 }
3880 3880
3881# check for new externs in .h files.
3882 if ($realfile =~ /\.h$/ &&
3883 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
3884 if (WARN("AVOID_EXTERNS",
3885 "extern prototypes should be avoided in .h files\n" . $herecurr) &&
3886 $fix) {
3887 $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
3888 }
3889 }
3890
3881# check for new externs in .c files. 3891# check for new externs in .c files.
3882 if ($realfile =~ /\.c$/ && defined $stat && 3892 if ($realfile =~ /\.c$/ && defined $stat &&
3883 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 3893 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)