[OPW,kernel] staging:wlan-ng/p80211conv:fix checkpatch.pl warnings
diff mbox

Message ID 1394535490-23484-1-git-send-email-swetha.kanagala@gmail.com
State New, archived
Headers show

Commit Message

swetha.kanagala@gmail.com March 11, 2014, 10:58 a.m. UTC
From: swetha kanagala <swetha.kanagala@gmail.com>

Signed-off-by: swetha kanagala <swetha.kanagala@gmail.com>

This patch has fixes for replacing printk with netdev_err and netdev_warn and replacing memcpy
with ether_addr_copy and the other coding style errors.
---
 drivers/staging/wlan-ng/p80211conv.c |   67 ++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 32 deletions(-)

Comments

Waskiewicz Jr, Peter P March 14, 2014, 12:09 a.m. UTC | #1
On Tue, 2014-03-11 at 16:28 +0530, swetha.kanagala@gmail.com wrote:
> From: swetha kanagala <swetha.kanagala@gmail.com>
> 
> Signed-off-by: swetha kanagala <swetha.kanagala@gmail.com>

This patch has the same feedback I had on your previous one.  See below.

> 
> This patch has fixes for replacing printk with netdev_err and netdev_warn and replacing memcpy
> with ether_addr_copy and the other coding style errors.
> ---
>  drivers/staging/wlan-ng/p80211conv.c |   67 ++++++++++++++++++----------------
>  1 file changed, 35 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
> index 3df753b..5e5a7e5 100644
> --- a/drivers/staging/wlan-ng/p80211conv.c
> +++ b/drivers/staging/wlan-ng/p80211conv.c
> @@ -62,7 +62,7 @@
>  #include <linux/etherdevice.h>
>  #include <linux/if_ether.h>
>  #include <linux/byteorder/generic.h>
> -
> +#include <linux/etherdevice.h>
>  #include <asm/byteorder.h>
>  
>  #include "p80211types.h"
> @@ -114,7 +114,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
>  	struct wlan_snap *e_snap;
>  	int foo;
>  
> -	memcpy(&e_hdr, skb->data, sizeof(e_hdr));
> +	ether_addr_copy(&e_hdr, skb->data);
>  
>  	if (skb->len <= 0) {
>  		pr_debug("zero-length skb!\n");
> @@ -153,11 +153,9 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
>  			e_snap->type = htons(proto);
>  			if (ethconv == WLAN_ETHCONV_8021h
>  			    && p80211_stt_findproto(proto)) {
> -				memcpy(e_snap->oui, oui_8021h,
> -				       WLAN_IEEE_OUI_LEN);
> +				ether_addr_copy(e_snap->oui, oui_8021h);
>  			} else {
> -				memcpy(e_snap->oui, oui_rfc1042,
> -				       WLAN_IEEE_OUI_LEN);
> +				ether_addr_copy(e_snap->oui, oui_rfc1042);
>  			}
>  
>  			/* tack on llc */
> @@ -178,25 +176,25 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
>  
>  	switch (wlandev->macmode) {
>  	case WLAN_MACMODE_IBSS_STA:
> -		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
> +		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
> +		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
> +		ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid);
>  		break;
>  	case WLAN_MACMODE_ESS_STA:
>  		fc |= cpu_to_le16(WLAN_SET_FC_TODS(1));
> -		memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
> +		ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid);
> +		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
> +		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr);
>  		break;
>  	case WLAN_MACMODE_ESS_AP:
>  		fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1));
> -		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
> -		memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
> +		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
> +		ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid);
> +		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr);
>  		break;
>  	default:
> -		printk(KERN_ERR
> -		       "Error: Converting eth to wlan in unknown mode.\n");
> +		netdev_err(wlandev->netdev
> +		       , "Error: Converting eth to wlan in unknown mode.\n");

If you could move the commas to the preceding line, that'd be great.
This happens in this patch alot too, I won't comment on each.

If you could respin and resend a new version, that'd be great!

-PJ

>  		return 1;
>  		break;
>  	}
> @@ -213,8 +211,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
>  				  (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
>  				  p80211_wep->iv, p80211_wep->icv);
>  		if (foo) {
> -			printk(KERN_WARNING
> -			       "Host en-WEP failed, dropping frame (%d).\n",
> +			netdev_warn(wlandev->netdev
> +			       , "Host en-WEP failed, dropping frame (%d).\n",
>  			       foo);
>  			return 2;
>  		}
> @@ -242,7 +240,7 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
>  	for (i = 0; i < wlandev->spy_number; i++) {
>  
>  		if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
> -			memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
> +			ether_addr_copy(wlandev->spy_address[i], mac);
>  			wlandev->spy_stat[i].level = rxmeta->signal;
>  			wlandev->spy_stat[i].noise = rxmeta->noise;
>  			wlandev->spy_stat[i].qual =
> @@ -310,7 +308,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  	} else {
>  		payload_offset = WLAN_HDR_A4_LEN;
>  		if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) {
> -			printk(KERN_ERR "A4 frame too short!\n");
> +			netdev_err(wlandev->netdev, "A4 frame too short!\n");
>  			return 1;
>  		}
>  		payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN);
> @@ -322,8 +320,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  	if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc)
>  	    && (wlandev->hostwep & HOSTWEP_DECRYPT)) {
>  		if (payload_length <= 8) {
> -			printk(KERN_ERR "WEP frame too short (%u).\n",
> -			       skb->len);
> +			netdev_err(wlandev->netdev
> +				, "WEP frame too short (%u).\n", skb->len);
>  			return 1;
>  		}
>  		foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
> @@ -333,8 +331,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  				       payload_length - 4);
>  		if (foo) {
>  			/* de-wep failed, drop skb. */
> -			pr_debug("Host de-WEP failed, dropping frame (%d).\n",
> -				 foo);
> +			netdev_dbg(wlandev->netdev
> +			, "Host de-WEP failed, dropping frame (%d).\n", foo);
>  			wlandev->rx.decrypt_err++;
>  			return 2;
>  		}
> @@ -367,7 +365,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  		if (payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
>  			/* A bogus length ethfrm has been encap'd. */
>  			/* Is someone trying an oflow attack? */
> -			printk(KERN_ERR "ENCAP frame too large (%d > %d)\n",
> +			netdev_err(wlandev->netdev
> +				, "ENCAP frame too large (%d > %d)\n",
>  			       payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
>  			return 1;
>  		}
> @@ -396,7 +395,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  		if (payload_length > netdev->mtu) {
>  			/* A bogus length ethfrm has been sent. */
>  			/* Is someone trying an oflow attack? */
> -			printk(KERN_ERR "SNAP frame too large (%d > %d)\n",
> +			netdev_err(wlandev->netdev
> +				, "SNAP frame too large (%d > %d)\n",
>  			       payload_length, netdev->mtu);
>  			return 1;
>  		}
> @@ -428,7 +428,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  			> netdev->mtu) {
>  			/* A bogus length ethfrm has been sent. */
>  			/* Is someone trying an oflow attack? */
> -			printk(KERN_ERR "DIXII frame too large (%ld > %d)\n",
> +			netdev_err(wlandev->netdev
> +				, "DIXII frame too large (%ld > %d)\n",
>  			       (long int)(payload_length -
>  					sizeof(struct wlan_llc) -
>  					sizeof(struct wlan_snap)), netdev->mtu);
> @@ -463,7 +464,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
>  		if (payload_length > netdev->mtu) {
>  			/* A bogus length ethfrm has been sent. */
>  			/* Is someone trying an oflow attack? */
> -			printk(KERN_ERR "OTHER frame too large (%d > %d)\n",
> +			netdev_err(wlandev->netdev
> +				, "OTHER frame too large (%d > %d)\n",
>  			       payload_length, netdev->mtu);
>  			return 1;
>  		}
> @@ -603,7 +605,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
>  
>  	/* If these already have metadata, we error out! */
>  	if (P80211SKB_RXMETA(skb) != NULL) {
> -		printk(KERN_ERR "%s: RXmeta already attached!\n",
> +		netdev_err(wlandev->netdev, "%s: RXmeta already attached!\n",
>  		       wlandev->name);
>  		result = 0;
>  		goto exit;
> @@ -613,7 +615,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
>  	rxmeta = kzalloc(sizeof(struct p80211_rxmeta), GFP_ATOMIC);
>  
>  	if (rxmeta == NULL) {
> -		printk(KERN_ERR "%s: Failed to allocate rxmeta.\n",
> +		netdev_err(wlandev->netdev, "%s: Failed to allocate rxmeta.\n",
>  		       wlandev->name);
>  		result = 1;
>  		goto exit;
> @@ -656,6 +658,7 @@ void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
>  	if (meta && meta->rx)
>  		p80211skb_rxmeta_detach(skb);
>  	else
> -		printk(KERN_ERR "Freeing an skb (%p) w/ no frmmeta.\n", skb);
> +		netdev_err(wlandev->netdev
> +			, "Freeing an skb (%p) w/ no frmmeta.\n", skb);
>  	dev_kfree_skb(skb);
>  }
> -- 
> 1.7.9.5
>

Patch
diff mbox

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 3df753b..5e5a7e5 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -62,7 +62,7 @@ 
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
 #include <linux/byteorder/generic.h>
-
+#include <linux/etherdevice.h>
 #include <asm/byteorder.h>
 
 #include "p80211types.h"
@@ -114,7 +114,7 @@  int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
 	struct wlan_snap *e_snap;
 	int foo;
 
-	memcpy(&e_hdr, skb->data, sizeof(e_hdr));
+	ether_addr_copy(&e_hdr, skb->data);
 
 	if (skb->len <= 0) {
 		pr_debug("zero-length skb!\n");
@@ -153,11 +153,9 @@  int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
 			e_snap->type = htons(proto);
 			if (ethconv == WLAN_ETHCONV_8021h
 			    && p80211_stt_findproto(proto)) {
-				memcpy(e_snap->oui, oui_8021h,
-				       WLAN_IEEE_OUI_LEN);
+				ether_addr_copy(e_snap->oui, oui_8021h);
 			} else {
-				memcpy(e_snap->oui, oui_rfc1042,
-				       WLAN_IEEE_OUI_LEN);
+				ether_addr_copy(e_snap->oui, oui_rfc1042);
 			}
 
 			/* tack on llc */
@@ -178,25 +176,25 @@  int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
 
 	switch (wlandev->macmode) {
 	case WLAN_MACMODE_IBSS_STA:
-		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+		ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid);
 		break;
 	case WLAN_MACMODE_ESS_STA:
 		fc |= cpu_to_le16(WLAN_SET_FC_TODS(1));
-		memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr);
 		break;
 	case WLAN_MACMODE_ESS_AP:
 		fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1));
-		memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
-		memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
+		ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+		ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid);
+		ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr);
 		break;
 	default:
-		printk(KERN_ERR
-		       "Error: Converting eth to wlan in unknown mode.\n");
+		netdev_err(wlandev->netdev
+		       , "Error: Converting eth to wlan in unknown mode.\n");
 		return 1;
 		break;
 	}
@@ -213,8 +211,8 @@  int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
 				  (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
 				  p80211_wep->iv, p80211_wep->icv);
 		if (foo) {
-			printk(KERN_WARNING
-			       "Host en-WEP failed, dropping frame (%d).\n",
+			netdev_warn(wlandev->netdev
+			       , "Host en-WEP failed, dropping frame (%d).\n",
 			       foo);
 			return 2;
 		}
@@ -242,7 +240,7 @@  static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
 	for (i = 0; i < wlandev->spy_number; i++) {
 
 		if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
-			memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
+			ether_addr_copy(wlandev->spy_address[i], mac);
 			wlandev->spy_stat[i].level = rxmeta->signal;
 			wlandev->spy_stat[i].noise = rxmeta->noise;
 			wlandev->spy_stat[i].qual =
@@ -310,7 +308,7 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 	} else {
 		payload_offset = WLAN_HDR_A4_LEN;
 		if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) {
-			printk(KERN_ERR "A4 frame too short!\n");
+			netdev_err(wlandev->netdev, "A4 frame too short!\n");
 			return 1;
 		}
 		payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN);
@@ -322,8 +320,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 	if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc)
 	    && (wlandev->hostwep & HOSTWEP_DECRYPT)) {
 		if (payload_length <= 8) {
-			printk(KERN_ERR "WEP frame too short (%u).\n",
-			       skb->len);
+			netdev_err(wlandev->netdev
+				, "WEP frame too short (%u).\n", skb->len);
 			return 1;
 		}
 		foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
@@ -333,8 +331,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 				       payload_length - 4);
 		if (foo) {
 			/* de-wep failed, drop skb. */
-			pr_debug("Host de-WEP failed, dropping frame (%d).\n",
-				 foo);
+			netdev_dbg(wlandev->netdev
+			, "Host de-WEP failed, dropping frame (%d).\n", foo);
 			wlandev->rx.decrypt_err++;
 			return 2;
 		}
@@ -367,7 +365,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 		if (payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
 			/* A bogus length ethfrm has been encap'd. */
 			/* Is someone trying an oflow attack? */
-			printk(KERN_ERR "ENCAP frame too large (%d > %d)\n",
+			netdev_err(wlandev->netdev
+				, "ENCAP frame too large (%d > %d)\n",
 			       payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
 			return 1;
 		}
@@ -396,7 +395,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 		if (payload_length > netdev->mtu) {
 			/* A bogus length ethfrm has been sent. */
 			/* Is someone trying an oflow attack? */
-			printk(KERN_ERR "SNAP frame too large (%d > %d)\n",
+			netdev_err(wlandev->netdev
+				, "SNAP frame too large (%d > %d)\n",
 			       payload_length, netdev->mtu);
 			return 1;
 		}
@@ -428,7 +428,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 			> netdev->mtu) {
 			/* A bogus length ethfrm has been sent. */
 			/* Is someone trying an oflow attack? */
-			printk(KERN_ERR "DIXII frame too large (%ld > %d)\n",
+			netdev_err(wlandev->netdev
+				, "DIXII frame too large (%ld > %d)\n",
 			       (long int)(payload_length -
 					sizeof(struct wlan_llc) -
 					sizeof(struct wlan_snap)), netdev->mtu);
@@ -463,7 +464,8 @@  int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
 		if (payload_length > netdev->mtu) {
 			/* A bogus length ethfrm has been sent. */
 			/* Is someone trying an oflow attack? */
-			printk(KERN_ERR "OTHER frame too large (%d > %d)\n",
+			netdev_err(wlandev->netdev
+				, "OTHER frame too large (%d > %d)\n",
 			       payload_length, netdev->mtu);
 			return 1;
 		}
@@ -603,7 +605,7 @@  int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
 
 	/* If these already have metadata, we error out! */
 	if (P80211SKB_RXMETA(skb) != NULL) {
-		printk(KERN_ERR "%s: RXmeta already attached!\n",
+		netdev_err(wlandev->netdev, "%s: RXmeta already attached!\n",
 		       wlandev->name);
 		result = 0;
 		goto exit;
@@ -613,7 +615,7 @@  int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
 	rxmeta = kzalloc(sizeof(struct p80211_rxmeta), GFP_ATOMIC);
 
 	if (rxmeta == NULL) {
-		printk(KERN_ERR "%s: Failed to allocate rxmeta.\n",
+		netdev_err(wlandev->netdev, "%s: Failed to allocate rxmeta.\n",
 		       wlandev->name);
 		result = 1;
 		goto exit;
@@ -656,6 +658,7 @@  void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
 	if (meta && meta->rx)
 		p80211skb_rxmeta_detach(skb);
 	else
-		printk(KERN_ERR "Freeing an skb (%p) w/ no frmmeta.\n", skb);
+		netdev_err(wlandev->netdev
+			, "Freeing an skb (%p) w/ no frmmeta.\n", skb);
 	dev_kfree_skb(skb);
 }