From: Eric Dumazet <eric.dumazet@gmail.com>
To: Wei Yongjun <weiyj.lk@gmail.com>
Cc: gregkh@linuxfoundation.org, yongjun_wei@trendmicro.com.cn,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8192e: use is_zero_ether_addr() instead of memcmp()
Date: Thu, 23 Aug 2012 09:54:03 +0200 [thread overview]
Message-ID: <1345708443.5904.186.camel@edumazet-glaptop> (raw)
In-Reply-To: <CAPgLHd-VLPp-tpF77tTc9aj8-VO30jy2yhsi7KyW_NFQOqNqag@mail.gmail.com>
On Thu, 2012-08-23 at 15:19 +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Using is_zero_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 <yongjun_wei@trendmicro.com.cn>
> ---
> drivers/staging/rtl8192e/rtllib_softmac_wx.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> index 1bb6b52..3cedfd9 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> @@ -14,6 +14,8 @@
> */
>
>
> +#include <linux/etherdevice.h>
> +
> #include "rtllib.h"
> #include "dot11d.h"
> /* FIXME: add A freqs */
> @@ -137,7 +139,6 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
> {
>
> int ret = 0;
> - u8 zero[] = {0, 0, 0, 0, 0, 0};
> unsigned long flags;
>
> short ifup = ieee->proto_started;
> @@ -157,7 +158,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
> goto out;
> }
>
> - if (memcmp(temp->sa_data, zero, ETH_ALEN) == 0) {
> + if (is_zero_ether_addr(temp->sa_data)) {
> spin_lock_irqsave(&ieee->lock, flags);
> memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
BTW this looks suspicious : Why is it using memcpy() if temp->sa_data is
known to be zero ?
> ieee->wap_set = 0;
> @@ -177,7 +178,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
>
> ieee->cannot_notify = false;
> memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
> - ieee->wap_set = (memcmp(temp->sa_data, zero, ETH_ALEN) != 0);
> + ieee->wap_set = (!is_zero_ether_addr(temp->sa_data));
>
ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
> spin_unlock_irqrestore(&ieee->lock, flags);
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2012-08-23 7:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 7:19 Wei Yongjun
2012-08-23 7:54 ` Eric Dumazet [this message]
2012-08-23 8:28 Wei Yongjun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345708443.5904.186.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=weiyj.lk@gmail.com \
--cc=yongjun_wei@trendmicro.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®