mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: r8712u: use is_broadcast_ether_addr() to simplify the code
@ 2012-08-26  1:22 Wei Yongjun
  2012-08-26  1:44 ` Larry Finger
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-08-26  1:22 UTC (permalink / raw)
  To: Larry.Finger, florian.c.schilhabel, gregkh
  Cc: yongjun_wei, devel, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Using is_broadcast_ether_addr() to simplify the code.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)


Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/staging/rtl8712/ethernet.h            | 8 --------
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 +---
 drivers/staging/rtl8712/rtl871x_ioctl_set.c   | 6 ++----
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h
index 882d61b..9095420 100644
--- a/drivers/staging/rtl8712/ethernet.h
+++ b/drivers/staging/rtl8712/ethernet.h
@@ -35,14 +35,6 @@
 
 /*!< Is Multicast Address? */
 #define RT_ETH_IS_MULTICAST(_pAddr)	((((u8 *)(_pAddr))[0]&0x01) != 0)
-/*!< Is Broadcast Address? */
-#define RT_ETH_IS_BROADCAST(_pAddr)	(				\
-			((u8 *)(_pAddr))[0] == 0xff	&&		\
-			((u8 *)(_pAddr))[1] == 0xff	&&		\
-			((u8 *)(_pAddr))[2] == 0xff	&&		\
-			((u8 *)(_pAddr))[3] == 0xff	&&		\
-			((u8 *)(_pAddr))[4] == 0xff	&&		\
-			((u8 *)(_pAddr))[5] == 0xff)
 
 #endif /* #ifndef __INC_ETHERNET_H */
 

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 35e781f..c9a6a7f 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -407,9 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
 	if (param_len != (u32)((u8 *) param->u.crypt.key - (u8 *)param) +
 			 param->u.crypt.key_len)
 		return -EINVAL;
-	if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-	    param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-	    param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+	if (is_broadcast_ether_addr(param->sta_addr)) {
 		if (param->u.crypt.idx >= WEP_KEYS) {
 			/* for large key indices, set the default (0) */
 			param->u.crypt.idx = 0;

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index f352b32..5ab70ab 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -131,10 +131,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
 	u8 status = true;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-	if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
-	     bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
-	    (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
-	     bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
+	if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) {
 		status = false;
 		return status;
 	}



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

* Re: [PATCH] staging: r8712u: use is_broadcast_ether_addr() to simplify the code
  2012-08-26  1:22 [PATCH] staging: r8712u: use is_broadcast_ether_addr() to simplify the code Wei Yongjun
@ 2012-08-26  1:44 ` Larry Finger
  0 siblings, 0 replies; 2+ messages in thread
From: Larry Finger @ 2012-08-26  1:44 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: florian.c.schilhabel, gregkh, yongjun_wei, devel, linux-kernel

On 08/25/2012 08:22 PM, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Using is_broadcast_ether_addr() to simplify the code.
>
> spatch with a semantic match is used to found this problem.
> (http://coccinelle.lip6.fr/)
>
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>   drivers/staging/rtl8712/ethernet.h            | 8 --------
>   drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 +---
>   drivers/staging/rtl8712/rtl871x_ioctl_set.c   | 6 ++----
>   3 files changed, 3 insertions(+), 15 deletions(-)

ACKed-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks,

Larry

>
> diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h
> index 882d61b..9095420 100644
> --- a/drivers/staging/rtl8712/ethernet.h
> +++ b/drivers/staging/rtl8712/ethernet.h
> @@ -35,14 +35,6 @@
>
>   /*!< Is Multicast Address? */
>   #define RT_ETH_IS_MULTICAST(_pAddr)	((((u8 *)(_pAddr))[0]&0x01) != 0)
> -/*!< Is Broadcast Address? */
> -#define RT_ETH_IS_BROADCAST(_pAddr)	(				\
> -			((u8 *)(_pAddr))[0] == 0xff	&&		\
> -			((u8 *)(_pAddr))[1] == 0xff	&&		\
> -			((u8 *)(_pAddr))[2] == 0xff	&&		\
> -			((u8 *)(_pAddr))[3] == 0xff	&&		\
> -			((u8 *)(_pAddr))[4] == 0xff	&&		\
> -			((u8 *)(_pAddr))[5] == 0xff)
>
>   #endif /* #ifndef __INC_ETHERNET_H */
>
>
> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> index 35e781f..c9a6a7f 100644
> --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> @@ -407,9 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
>   	if (param_len != (u32)((u8 *) param->u.crypt.key - (u8 *)param) +
>   			 param->u.crypt.key_len)
>   		return -EINVAL;
> -	if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
> -	    param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
> -	    param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
> +	if (is_broadcast_ether_addr(param->sta_addr)) {
>   		if (param->u.crypt.idx >= WEP_KEYS) {
>   			/* for large key indices, set the default (0) */
>   			param->u.crypt.idx = 0;
>
> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
> index f352b32..5ab70ab 100644
> --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
> +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
> @@ -131,10 +131,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
>   	u8 status = true;
>   	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
>
> -	if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
> -	     bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
> -	    (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
> -	     bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
> +	if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) {
>   		status = false;
>   		return status;
>   	}
>
>
>


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

end of thread, other threads:[~2012-08-26  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-26  1:22 [PATCH] staging: r8712u: use is_broadcast_ether_addr() to simplify the code Wei Yongjun
2012-08-26  1:44 ` Larry Finger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome