Skip to contentSkip to conversation

staging/ozwpan: Fix zero address check in oz_set_active_pd

PATCH In review Andi Kleen 3 participants 4 messages Sep 3, 2012 – Sep 4, 2012 Staging

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 staging/ozwpan: Fix zero address check in oz_set_active_pd

gcc 4.8 warns about the incorrect memcmp size. I think it's supposed to be an ethernet address, so should be always 6 bytes.

The code was wrong, would either compare 4 or 8 bytes (32bit vs 64bit)

/backup/lsrc/git/linux-lto-2.6/drivers/staging/ozwpan/ozcdev.c: In function 'oz_set_active_pd':
/backup/lsrc/git/linux-lto-2.6/drivers/staging/ozwpan/ozcdev.c:216:43: warning: argument to 'sizeof' in 'memcmp' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]

   if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
                                           ^
drivers/staging/ozwpan/ozcdev.c +1 -1
index d983219..63c1b67 100644
@@ -213,7 +213,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 (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) {
 			spin_lock_bh(&g_cdev.lock);
 			pd = g_cdev.active_pd;
 			g_cdev.active_pd = 0;
#1 lore raw
Quoted 17 lines · Andi Kleen

gcc 4.8 warns about the incorrect memcmp size. I think it's supposed to be an ethernet address, so should be always 6 bytes.

The code was wrong, would either compare 4 or 8 bytes (32bit vs 64bit)

/backup/lsrc/git/linux-lto-2.6/drivers/staging/ozwpan/ozcdev.c: In function 'oz_set_active_pd':
/backup/lsrc/git/linux-lto-2.6/drivers/staging/ozwpan/ozcdev.c:216:43: warning: argument to 'sizeof' in 'memcmp' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]

    if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
                                            ^
drivers/staging/ozwpan/ozcdev.c +0 -0
index d983219..63c1b67 100644

drivers/staging/ozwpan/ozcdev.c static int oz_set_active_pd(u8 *addr) · line 219

Quoted 8 lines
drivers/staging/ozwpan/ozcdev.c +1 -1
@@ -213,7 +213,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 (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) {
  			spin_lock_bh(&g_cdev.lock);
  			pd = g_cdev.active_pd;
  			g_cdev.active_pd = 0;

Its already fixed by this patch :-

http://driverdev.linuxdriverproject.org/pipermail/devel/2012-August/029734.html

Signature · 2 lines
Regards,
Rupesh Gujare