[PATCH] staging: vt6655: fix sparse warning for static declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Vladimir A. Nazarenko" <naszar@xxxxx>

This patch fixes the following sparse warning:
drivers/staging/vt6655/ioctl.c:44:12: warning: symbol 'wpa_Result'
	was not declared. Should it be static?

'wpa_Result' can't be static because it used not only in file where
declared (ioctl.c). To resolve this I introduce new function
clear_wpa_Result(), which complitly satisfy external (and part of
internal) needs for 'wpa_Result'. Patch by steps:
* New function clear_wpa_Result() to set all fields of clear_wpa_Result()
to zero.
* Add prototipe of clear_wpa_Result() to ioctl.h
* Replace code that set 'wpa_Result' fields to zero with  new function.
* Declare 'wpa_Result' as static.

Signed-off-by: Vladimir A. Nazarenko <naszar@xxxxx>
---
 drivers/staging/vt6655/device_main.c |  9 +--------
 drivers/staging/vt6655/ioctl.c       | 17 +++++++++++------
 drivers/staging/vt6655/ioctl.h       |  1 +
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 76d5454..598e7ec 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1553,9 +1553,6 @@ static int  device_open(struct net_device *dev)
 {
 	struct vnt_private *pDevice = netdev_priv(dev);
 	int i;
-#ifdef WPA_SM_Transtatus
-	extern SWPAResult wpa_Result;
-#endif
 
 	pDevice->rx_buf_sz = PKT_BUF_SZ;
 	if (!device_init_rings(pDevice))
@@ -1567,11 +1564,7 @@ static int  device_open(struct net_device *dev)
 		return i;
 
 #ifdef WPA_SM_Transtatus
-	memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
-	wpa_Result.proto = 0;
-	wpa_Result.key_mgmt = 0;
-	wpa_Result.eap_type = 0;
-	wpa_Result.authenticated = false;
+	clear_wpa_result();
 	pDevice->fWPA_Authened = false;
 #endif
 	pr_debug("call device init rd0 ring\n");
diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c
index 970e80d..06084ee 100644
--- a/drivers/staging/vt6655/ioctl.c
+++ b/drivers/staging/vt6655/ioctl.c
@@ -39,7 +39,16 @@
 #include "rf.h"
 
 #ifdef WPA_SM_Transtatus
-SWPAResult wpa_Result;
+static SWPAResult wpa_Result;
+
+void  clear_wpa_result(void)
+{
+	memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
+	wpa_Result.proto = 0;
+	wpa_Result.key_mgmt = 0;
+	wpa_Result.eap_type = 0;
+	wpa_Result.authenticated = false;
+}
 #endif
 
 int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq)
@@ -620,11 +629,7 @@ int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq)
 
 #ifdef WPA_SM_Transtatus
 	case 0xFF:
-		memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
-		wpa_Result.proto = 0;
-		wpa_Result.key_mgmt = 0;
-		wpa_Result.eap_type = 0;
-		wpa_Result.authenticated = false;
+		clear_wpa_result();
 		pDevice->fWPA_Authened = false;
 		if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
 			result = -EFAULT;
diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h
index 2dc5a574..5695017 100644
--- a/drivers/staging/vt6655/ioctl.h
+++ b/drivers/staging/vt6655/ioctl.h
@@ -32,5 +32,6 @@
 #include "device.h"
 
 int private_ioctl(struct vnt_private *, struct ifreq *rq);
+void clear_wpa_result(void);
 
 #endif // __IOCTL_H__
-- 
2.1.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux