]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - scripts/checkpatch.pl
checkpatch: warn when using extern with function prototypes in .h files
[karo-tx-linux.git] / scripts / checkpatch.pl
index 7c79c91662c80060a83b86dd83ea61ef22be1c23..e2cb1f4621b7e710332a59aa52cd26f315306c37 100755 (executable)
@@ -3878,6 +3878,16 @@ sub process {
                        }
                }
 
+# check for new externs in .h files.
+               if ($realfile =~ /\.h$/ &&
+                   $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
+                       if (WARN("AVOID_EXTERNS",
+                                "extern prototypes should be avoided in .h files\n" . $herecurr) &&
+                           $fix) {
+                               $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
+                       }
+               }
+
 # check for new externs in .c files.
                if ($realfile =~ /\.c$/ && defined $stat &&
                    $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)