lkml.org 
[lkml]   [2021]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectCHECKPATCH: 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

\
 
 \ /
  Last update: 2021-03-20 12:13    [W:0.099 / U:1.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site