All of lore.kernel.org
 help / color / mirror / Atom feed
* [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
@ 2012-08-19 16:36 Tomas Winkler
  2012-08-19 16:56 ` Julia Lawall
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tomas Winkler @ 2012-08-19 16:36 UTC (permalink / raw)
  To: kernel-janitors

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want
to compare 6 bytes (ETH_ALEN).

As network stack already provides helper function
is_zero_ether_addr() we use that instead of memcmp

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Rupesh Gujare <rgujare@ozmodevices.com>
---
V1: by Dan Carpenter <dan.carpenter@oracle.com>
V2: replace memcmp with is_zero_ether_addr
V3: include <linux/etherdevice.h>

 drivers/staging/ozwpan/ozcdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index d983219..758ce0a 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -8,6 +8,7 @@
 #include <linux/cdev.h>
 #include <linux/uaccess.h>
 #include <linux/netdevice.h>
+#include <linux/etherdevice.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
 #include "ozconfig.h"
@@ -213,7 +214,7 @@ static int oz_set_active_pd(u8 *addr)
 		if (old_pd)
 			oz_pd_put(old_pd);
 	} else {
-		if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
+		if (is_zero_ether_addr(addr)) {
 			spin_lock_bh(&g_cdev.lock);
 			pd = g_cdev.active_pd;
 			g_cdev.active_pd = 0;
-- 
1.7.4.4


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

* Re: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
  2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
@ 2012-08-19 16:56 ` Julia Lawall
  2012-08-19 19:21 ` Winkler, Tomas
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2012-08-19 16:56 UTC (permalink / raw)
  To: kernel-janitors

There seems also to be an opportunity in drivers/scsi/qla2xxx/qla_init.c:

memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))

julia

On Sun, 19 Aug 2012, Tomas Winkler wrote:

> "addr" is a pointer so it's either 4 or 8 bytes, but actually we want
> to compare 6 bytes (ETH_ALEN).
>
> As network stack already provides helper function
> is_zero_ether_addr() we use that instead of memcmp
>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Rupesh Gujare <rgujare@ozmodevices.com>
> ---
> V1: by Dan Carpenter <dan.carpenter@oracle.com>
> V2: replace memcmp with is_zero_ether_addr
> V3: include <linux/etherdevice.h>
>
> drivers/staging/ozwpan/ozcdev.c |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
> index d983219..758ce0a 100644
> --- a/drivers/staging/ozwpan/ozcdev.c
> +++ b/drivers/staging/ozwpan/ozcdev.c
> @@ -8,6 +8,7 @@
> #include <linux/cdev.h>
> #include <linux/uaccess.h>
> #include <linux/netdevice.h>
> +#include <linux/etherdevice.h>
> #include <linux/poll.h>
> #include <linux/sched.h>
> #include "ozconfig.h"
> @@ -213,7 +214,7 @@ static int oz_set_active_pd(u8 *addr)
> 		if (old_pd)
> 			oz_pd_put(old_pd);
> 	} else {
> -		if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
> +		if (is_zero_ether_addr(addr)) {
> 			spin_lock_bh(&g_cdev.lock);
> 			pd = g_cdev.active_pd;
> 			g_cdev.active_pd = 0;
> -- 
> 1.7.4.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* RE: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
  2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
  2012-08-19 16:56 ` Julia Lawall
@ 2012-08-19 19:21 ` Winkler, Tomas
  2012-08-19 19:33 ` Julia Lawall
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Winkler, Tomas @ 2012-08-19 19:21 UTC (permalink / raw)
  To: kernel-janitors

> 
> There seems also to be an opportunity in drivers/scsi/qla2xxx/qla_init.c:
> 
> memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))

If you plan do semantic patch then there are also examples of:

./drivers/staging/rtl8712/rtl871x_recv.c:            
 if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) |

similarly 
is_broadcast_ether_addr()  to replace memcmp  with 6 off 0xFF

and endless number of memcmp that can be replaced with 
ether_addr_equal()

Thanks
Tomas

 
> julia
> 
> On Sun, 19 Aug 2012, Tomas Winkler wrote:
> 
> > "addr" is a pointer so it's either 4 or 8 bytes, but actually we want
> > to compare 6 bytes (ETH_ALEN).
> >
> > As network stack already provides helper function
> > is_zero_ether_addr() we use that instead of memcmp
> >
> > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> > Cc: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: Rupesh Gujare <rgujare@ozmodevices.com>
> > ---
> > V1: by Dan Carpenter <dan.carpenter@oracle.com>
> > V2: replace memcmp with is_zero_ether_addr
> > V3: include <linux/etherdevice.h>
> >
> > drivers/staging/ozwpan/ozcdev.c |    3 ++-
> > 1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/staging/ozwpan/ozcdev.c
> > b/drivers/staging/ozwpan/ozcdev.c index d983219..758ce0a 100644
> > --- a/drivers/staging/ozwpan/ozcdev.c
> > +++ b/drivers/staging/ozwpan/ozcdev.c
> > @@ -8,6 +8,7 @@
> > #include <linux/cdev.h>
> > #include <linux/uaccess.h>
> > #include <linux/netdevice.h>
> > +#include <linux/etherdevice.h>
> > #include <linux/poll.h>
> > #include <linux/sched.h>
> > #include "ozconfig.h"
> > @@ -213,7 +214,7 @@ static int oz_set_active_pd(u8 *addr)
> > 		if (old_pd)
> > 			oz_pd_put(old_pd);
> > 	} else {
> > -		if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
> > +		if (is_zero_ether_addr(addr)) {
> > 			spin_lock_bh(&g_cdev.lock);
> > 			pd = g_cdev.active_pd;
> > 			g_cdev.active_pd = 0;
> > --
> > 1.7.4.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> > kernel-janitors" in the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >

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

* RE: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
  2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
  2012-08-19 16:56 ` Julia Lawall
  2012-08-19 19:21 ` Winkler, Tomas
@ 2012-08-19 19:33 ` Julia Lawall
  2012-08-22 10:19 ` Rupesh Gujare
  2012-09-04 17:34 ` Dan Carpenter
  4 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2012-08-19 19:33 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 19 Aug 2012, Winkler, Tomas wrote:

>>
>> There seems also to be an opportunity in drivers/scsi/qla2xxx/qla_init.c:
>>
>> memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))
>
> If you plan do semantic patch then there are also examples of:
>
> ./drivers/staging/rtl8712/rtl871x_recv.c:
> if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) |
>
> similarly
> is_broadcast_ether_addr()  to replace memcmp  with 6 off 0xFF
>
> and endless number of memcmp that can be replaced with
> ether_addr_equal()

OK, thanks for the suggestions.  I will take a look.

julia

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

* RE: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
  2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
                   ` (2 preceding siblings ...)
  2012-08-19 19:33 ` Julia Lawall
@ 2012-08-22 10:19 ` Rupesh Gujare
  2012-09-04 17:34 ` Dan Carpenter
  4 siblings, 0 replies; 6+ messages in thread
From: Rupesh Gujare @ 2012-08-22 10:19 UTC (permalink / raw)
  To: kernel-janitors


________________________________________
From: Tomas Winkler [tomas.winkler@intel.com]
Sent: 19 August 2012 17:36
To: gregkh@linuxfoundation.org
Cc: alan@linux.intel.com; devel@linuxdriverproject.org; kernel-janitors@vger.kernel.org; Tomas Winkler; Dan Carpenter; Rupesh Gujare
Subject: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want
to compare 6 bytes (ETH_ALEN).

As network stack already provides helper function
is_zero_ether_addr() we use that instead of memcmp

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Rupesh Gujare <rgujare@ozmodevices.com>
---
V1: by Dan Carpenter <dan.carpenter@oracle.com>
V2: replace memcmp with is_zero_ether_addr
V3: include <linux/etherdevice.h>

Acked-by: Rupesh Gujare<rgujare@ozmodevices.com> 


--
Regards,
Rupesh Gujare

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

* Re: [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd()
  2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
                   ` (3 preceding siblings ...)
  2012-08-22 10:19 ` Rupesh Gujare
@ 2012-09-04 17:34 ` Dan Carpenter
  4 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2012-09-04 17:34 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Aug 19, 2012 at 07:36:37PM +0300, Tomas Winkler wrote:
> "addr" is a pointer so it's either 4 or 8 bytes, but actually we want
> to compare 6 bytes (ETH_ALEN).
> 
> As network stack already provides helper function
> is_zero_ether_addr() we use that instead of memcmp
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Rupesh Gujare <rgujare@ozmodevices.com>
> ---
> V1: by Dan Carpenter <dan.carpenter@oracle.com>
> V2: replace memcmp with is_zero_ether_addr
> V3: include <linux/etherdevice.h>
> 

Acked-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


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

end of thread, other threads:[~2012-09-04 17:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-19 16:36 [staging-next V3] ozwpan: fix memcmp() test in oz_set_active_pd() Tomas Winkler
2012-08-19 16:56 ` Julia Lawall
2012-08-19 19:21 ` Winkler, Tomas
2012-08-19 19:33 ` Julia Lawall
2012-08-22 10:19 ` Rupesh Gujare
2012-09-04 17:34 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.