2012-08-23 06:54:06

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH] ipw2200: use is_zero_ether_addr() and is_broadcast_ether_addr()

From: Wei Yongjun <[email protected]>

Using is_zero_ether_addr() and is_broadcast_ether_addr() instead of
directly use memcmp() to determine if the ethernet address is all zeros.

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

Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/net/wireless/ipw2x00/ipw2200.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 0df4591..935120f 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -9037,18 +9037,11 @@ static int ipw_wx_set_wap(struct net_device *dev,
{
struct ipw_priv *priv = libipw_priv(dev);

- static const unsigned char any[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
- };
- static const unsigned char off[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
return -EINVAL;
mutex_lock(&priv->mutex);
- if (!memcmp(any, wrqu->ap_addr.sa_data, ETH_ALEN) ||
- !memcmp(off, wrqu->ap_addr.sa_data, ETH_ALEN)) {
+ if (is_broadcast_ether_addr(wrqu->ap_addr.sa_data) ||
+ is_zero_ether_addr(wrqu->ap_addr.sa_data)) {
/* we disable mandatory BSSID association */
IPW_DEBUG_WX("Setting AP BSSID to ANY\n");
priv->config &= ~CFG_STATIC_BSSID;




2012-08-23 21:13:08

by Stanislav Yakovlev

[permalink] [raw]
Subject: Re: [PATCH] ipw2200: use is_zero_ether_addr() and is_broadcast_ether_addr()

Hi,

On 23 August 2012 10:54, Wei Yongjun <[email protected]> wrote:
> From: Wei Yongjun <[email protected]>
>
> Using is_zero_ether_addr() and is_broadcast_ether_addr() instead of
> directly use memcmp() to determine if the ethernet address is all zeros.
>
> spatch with a semantic match is used to found this problem.
> (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> drivers/net/wireless/ipw2x00/ipw2200.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)

Looks fine, thanks.

Stanislav.