[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210320105424.GA3698@agape.jhs>
Date: Sat, 20 Mar 2021 11:54:24 +0100
From: Fabio Aiuto <fabioaiuto83@...il.com>
To: gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
apw@...onical.com, joe@...ches.com
Subject: CHECKPATCH: missing a warning soon after include files decl -c
Hi,
here's an issue in checkpatch.pl
$ perl script/checkpatch.pl -f drivers/staging/rtl8723bs/core/rtw_ap.c
I get three warning related to an extern declaration
WARNING: externs should be avoided in .c files
#14: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:14:
+extern unsigned char WMM_OUI[];
--
WARNING: externs should be avoided in .c files
#15: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:15:
+extern unsigned char WPS_OUI[];
--
WARNING: externs should be avoided in .c files
#16: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:16:
+extern unsigned char P2P_OUI[];
----------------------
but the file checked has 4 extern declaration:
-----------------------------
#define _RTW_AP_C_
#include <drv_types.h>
#include <rtw_debug.h>
#include <asm/unaligned.h>
extern unsigned char RTW_WPA_OUI[];
extern unsigned char WMM_OUI[];
extern unsigned char WPS_OUI[];
extern unsigned char P2P_OUI[];
void init_mlme_ap_info(struct adapter *padapter)
-------------------------------
If I add a ';' this way:
----------------------------
#define _RTW_AP_C_
#include <drv_types.h>
#include <rtw_debug.h>
#include <asm/unaligned.h>
;
extern unsigned char RTW_WPA_OUI[];
extern unsigned char WMM_OUI[];
extern unsigned char WPS_OUI[];
extern unsigned char P2P_OUI[];
void init_mlme_ap_info(struct adapter *padapter)
--------------------------------
the missing warning appears:
----------------------------------
WARNING: externs should be avoided in .c files
#13: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:13:
+extern unsigned char RTW_WPA_OUI[];
--
WARNING: externs should be avoided in .c files
#14: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:14:
+extern unsigned char WMM_OUI[];
--
WARNING: externs should be avoided in .c files
#15: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:15:
+extern unsigned char WPS_OUI[];
--
WARNING: externs should be avoided in .c files
#16: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:16:
+extern unsigned char P2P_OUI[];
-------------------------------------------
Applying this ugly patch to debug:
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index df8b23dc1eb0..ecbbb731361c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6810,6 +6810,11 @@ sub process {
{
WARN("AVOID_EXTERNS",
"externs should be avoided in .c files\n" . $herecurr);
+ } elsif ($realfile =~ /\.c$/ && defined $stat &&
+ $stat =~ /extern\s+/)
+ {
+ WARN("AVOID_EXTERNS",
+ "print stat value\n" . $stat);
}
# check for function declarations that have arguments without identifier names
--------------
I get:
WARNING: print stat value
+#include <XXXXXXXXXXX>
#include <XXXXXXXXXXX>
#include <XXXXXXXXXXXXXXX>
extern unsigned char RTW_WPA_OUI[];
WARNING: externs should be avoided in .c files
#14: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:14:
+extern unsigned char WMM_OUI[];
WARNING: externs should be avoided in .c files
#15: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:15:
+extern unsigned char WPS_OUI[];
WARNING: externs should be avoided in .c files
#16: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:16:
+extern unsigned char P2P_OUI[];
I don't know if it's best to fix the regex of the particular "extern in .c files issue"
or maybe how the statement is computed. Should a statement represent a single line?
Suggestions are welcome,
fabio
Powered by blists - more mailing lists