Please discard "checkpatch: warn when using extern with function prototypes in .h files"
I noticed that a patch got committed to checkpatch to complain about function prototypes prefixed by "extern".
Please discard/revert this patch:
commit 7cd0f806622836e386ef18ad1950a9a729803019
Author: Joe Perches <[email protected]>
Date: Wed Aug 28 10:16:00 2013 +1000
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.
This is inaccurate. It's actually a useful visual cue - so if anything, please make checkpatch indicate that it be added to all future function prototypes.
David
Joe Perches
maintainerPATCH 1/1 checkpatch: Make extern in .h prototypes quieter.
The use of extern in .h files is a bit contentious.
Make it emitted only when --strict is used on the
command-line.
--- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -3927,8 +3927,8 @@ 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) && + if (CHK("AVOID_EXTERNS", + "extern prototypes should be avoided in .h files\n" . $herecurr) && $fix) { $fixed[$linenr - 1] =~ s/(.*)\bextern\s+(.*)/$1$2/; }
Re: [PATCH] checkpatch: Make extern in .h prototypes quieter.
Quoted 4 lines · Joe Perches
The use of extern in .h files is a bit contentious.
Make it emitted only when --strict is used on the
command-line.
IIRC, the original intention was to always use "extern" in external function or data declarations, and then complain if any "extern" keyword was found in *.c files. Always using the "extern" keyword makes it easier to flag those.
scripts/checkpatch.pl sub process { · line 3931
Quoted 4 lines
scripts/checkpatch.pl +2
-2- if (WARN("AVOID_EXTERNS", - "extern prototypes should be avoided in .h files\n" . $herecurr) && + if (CHK("AVOID_EXTERNS", + "extern prototypes should be avoided in .h files\n" . $herecurr) &&
I know it's not the subject of this patch, but shouldn't "extern prototypes" be "extern keywords"?
Quoted 3 lines
$fix) {
$fixed[$linenr - 1] =~ s/(.*)\bextern\s+(.*)/$1$2/;
}Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Joe Perches
maintainerRe: [PATCH] checkpatch: Make extern in .h prototypes quieter.
Quoted 2 lines · Geert Uytterhoeven
I know it's not the subject of this patch, but shouldn't "extern prototypes" be "extern keywords"?
No, extern is required for variables.