All of lore.kernel.org
 help / color / mirror / Atom feed
* CHECKPATCH: missing a warning soon after include files decl -c
@ 2021-03-20 10:54 Fabio Aiuto
  2021-03-20 10:59 ` Greg KH
  0 siblings, 1 reply; 72+ messages in thread
From: Fabio Aiuto @ 2021-03-20 10:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, apw, joe

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

^ permalink raw reply related	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2021-03-24  9:58 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 10:54 CHECKPATCH: missing a warning soon after include files decl -c Fabio Aiuto
2021-03-20 10:59 ` Greg KH
2021-03-20 11:28   ` Joe Perches
2021-03-20 14:17     ` Fabio Aiuto
2021-03-24  9:58     ` Fabio Aiuto
2021-03-20 14:49   ` Fabio Aiuto
2021-03-21  7:03     ` Greg KH
2021-03-22 14:31       ` [PATCH 00/11] staging: rtl8723bs: fix extern declaration checkpatch issues Fabio Aiuto
2021-03-22 14:31         ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 01/11] staging: rtl8723bs: delete extern declarations in core/rtw_ap.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 02/11] staging: rtl8723bs: moved function prototypes out of core/rtw_efuse.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 16:07           ` Greg KH
2021-03-22 16:07             ` Greg KH
2021-03-22 18:22             ` Fabio Aiuto
2021-03-22 18:22               ` Fabio Aiuto
2021-03-22 19:29           ` Dan Carpenter
2021-03-22 19:29             ` Dan Carpenter
2021-03-23 13:25             ` Fabio Aiuto
2021-03-23 13:25               ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 03/11] staging: rtl8723bs: moved function prototype out of core/rtw_ioctl_set.c and core/rtw_mlme.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 16:09           ` Greg KH
2021-03-22 16:09             ` Greg KH
2021-03-22 18:28             ` Fabio Aiuto
2021-03-23  7:13               ` Greg KH
2021-03-23 12:56             ` [PATCH v2 0/9] fix extern declarations checkpatch issues Fabio Aiuto
2021-03-23 12:56               ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 1/9] staging: rtl8723bs: removed function prototypes in core/rtw_efuse.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 2/9] staging: rtl8723bs: moved function prototype out of core/rtw_ioctl_set.c and core/rtw_mlme.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 3/9] staging: rtl8723bs: removed function prototypes and made statics in core/rtw_recv.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 4/9] staging: rtl8723bs: delete extern declarations in core/rtw_wlan_util.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 5/9] staging: rtl8723bs: remove function prototypes in hal/odm.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 6/9] staging: rtl8723bs: move function prototypes out of os_dep/int_fs.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 7/9] staging: rtl8723bs: remove undefined function prototype in of os_dep/sdio_intf.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 8/9] staging: rtl8723bs: remove unnecessary extern in os_dep/sdio_intf.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 12:56               ` [PATCH v2 9/9] staging: rtl8723bs: remove blank line os_dep/os_intfs.c Fabio Aiuto
2021-03-23 12:56                 ` Fabio Aiuto
2021-03-23 13:08               ` [PATCH v2 0/9] fix extern declarations checkpatch issues Greg KH
2021-03-23 13:08                 ` Greg KH
2021-03-22 14:31         ` [PATCH 04/11] staging: rtl8723bs: moved function prototypes out of core/rtw_recv.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 16:09           ` Greg KH
2021-03-22 16:09             ` Greg KH
2021-03-22 14:31         ` [PATCH 05/11] staging: rtl8723bs: remove argument in recv_indicatepkts_pkt_loss_cnt Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 16:11           ` Greg KH
2021-03-22 16:11             ` Greg KH
2021-03-22 18:19             ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 06/11] staging: rtl8723bs: move function prototype out of core/rtw_recv.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 07/11] staging: rtl8723bs: delete extern declarations in core/rtw_wlan_util.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 08/11] staging: rtl8723bs: move function prototypes out of hal/odm.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 09/11] staging: rtl8723bs: move function prototypes out of os_dep/int_fs.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 10/11] staging: rtl8723bs: remove undefined function prototype in of os_dep/sdio_intf.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 14:31         ` [PATCH 11/11] staging: rtl8723bs: remove unnecessary extern in os_dep/sdio_intf.c Fabio Aiuto
2021-03-22 14:31           ` Fabio Aiuto
2021-03-22 16:06           ` Greg KH
2021-03-22 16:06             ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.