Message ID | 1507622059-4493-1-git-send-email-jiang.biao2@zte.com.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 10 October 2017 at 08:54, Jiang Biao <jiang.biao2@zte.com.cn> wrote: > When adding a function declaration in a .c file without extern > keywork decoration, checkpatch.pl will report *externs should be > avoided in .c files* false error. This patch fixes the bug. I don't think this is a bug. "extern int foo(void);" and "int foo(void);" have the same effect: they declare a function prototype that can be called from outside the file. We don't want to permit that in QEMU. Either: (1) the function is for use only within this file: the declaration should be "static int foo(void);" (2) the function is for use by other files too: the declaration should be in a header file, not a .c file, so the other files can use it Do you have an example of code where this warning is a problem? thanks -- PMM
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3c0a28e..c12bc4c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2534,7 +2534,7 @@ sub process { # check for new externs in .c files. if ($realfile =~ /\.c$/ && defined $stat && - $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) + $stat =~ /^.\s*(?:extern\s+)$Type\s+($Ident)(\s*)\(/s) { my $function_name = $1; my $paren_space = $2;
When adding a function declaration in a .c file without extern keywork decoration, checkpatch.pl will report *externs should be avoided in .c files* false error. This patch fixes the bug. Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn> --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)