Skip to contentSkip to conversation

hostap:hostap_ioctl.c Fix variable 'ret' set but not used

PATCH NAK Justin P. Mattock 2 participants 7 messages Aug 3, 2010 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 hostap:hostap_ioctl.c Fix variable 'ret' set but not used

Resend version 3

The below patch fixes a warning message generated by GCC:
CC [M] drivers/net/wireless/hostap/hostap_ioctl.o
drivers/net/wireless/hostap/hostap_ioctl.c: In function 'prism2_request_scan':
drivers/net/wireless/hostap/hostap_ioctl.c:1666:6: warning: variable 'ret' set but not used

---
 drivers/net/wireless/hostap/hostap_ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
index a85e43a..2cf6532 100644
@@ -1689,7 +1689,7 @@ static int prism2_request_scan(struct net_device *dev)
 	if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
 				 sizeof(scan_req))) {
 		printk(KERN_DEBUG "SCANREQUEST failed\n");
-		ret = -EINVAL;
+		return ret;
 	}
 
 	if (!local->host_roaming)
Signature · 1 line
1.7.1.rc1.21.gf3bd6
#1 lore raw
Quoted 18 lines · Justin P. Mattock

Resend version 3

The below patch fixes a warning message generated by GCC:
 CC [M]  drivers/net/wireless/hostap/hostap_ioctl.o drivers/net/wireless/hostap/hostap_ioctl.c: In function 'prism2_request_scan':
drivers/net/wireless/hostap/hostap_ioctl.c:1666:6: warning: variable 'ret' set but not used

---
 drivers/net/wireless/hostap/hostap_ioctl.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/hostap/hostap_ioctl.c +0 -0
index a85e43a..2cf6532 100644

drivers/net/wireless/hostap/hostap_ioctl.c static int prism2_request_scan(struct net_device *dev) · line 1695

Quoted 8 lines
drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
@@ -1689,7 +1689,7 @@ static int prism2_request_scan(struct net_device *dev)
        if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
                                 sizeof(scan_req))) {
                printk(KERN_DEBUG "SCANREQUEST failed\n");
-               ret = -EINVAL;
+               return ret;
        }
 
        if (!local->host_roaming)

NACK: This doesn't actually fix the error mentioned.

Attached is a more correct patch.

Apologies for the attachment, I'm building the patch by hand at work and only have gMail to send it with.

This should apply to wireless-testing.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/

Hostap: Fix "'ret' set but not used" warning message from GCC in hostap

CC [M] drivers/net/wireless/hostap/hostap_ioctl.o
drivers/net/wireless/hostap/hostap_ioctl.c: In function 'prism2_request_scan':
drivers/net/wireless/hostap/hostap_ioctl.c:1666:6: warning: variable 'ret' set but not used

---

drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
@@ -1696,7 +1696,7 @@
 		hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
 				HFA384X_ROAMING_FIRMWARE);
 
-	return 0;
+	return ret;
 }
 
 #else /* !PRISM2_NO_STATION_MODES */
#2 lore raw
Quoted 30 lines · Julian Calaby
Quoted 18 lines · Justin P. Mattock

Resend version 3

The below patch fixes a warning message generated by GCC:
CC [M] drivers/net/wireless/hostap/hostap_ioctl.o
drivers/net/wireless/hostap/hostap_ioctl.c: In function 'prism2_request_scan':
drivers/net/wireless/hostap/hostap_ioctl.c:1666:6: warning: variable 'ret' set but not used

---
  drivers/net/wireless/hostap/hostap_ioctl.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/hostap/hostap_ioctl.c +0 -0
index a85e43a..2cf6532 100644

drivers/net/wireless/hostap/hostap_ioctl.c static int prism2_request_scan(struct net_device *dev) · line 1695

Quoted 8 lines
drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
@@ -1689,7 +1689,7 @@ static int prism2_request_scan(struct net_device *dev)
        if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST,&scan_req,
                                 sizeof(scan_req))) {
                printk(KERN_DEBUG "SCANREQUEST failed\n");
-               ret = -EINVAL;
+               return ret;
        }
 
        if (!local->host_roaming)

NACK: This doesn't actually fix the error mentioned.

Quoted 9 lines

Attached is a more correct patch.

Apologies for the attachment, I'm building the patch by hand at work and only have gMail to send it with.

This should apply to wireless-testing.

Thanks,

wait im lost.. looking at your patch looks the same(number wise) except I see different parts of code in there:

hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
HFA384X_ROAMING_FIRMWARE);

- return 0;
+ return ret;

mine is:

printk(KERN_DEBUG "SCANREQUEST failed\n");
- ret = -EINVAL;
+ return ret;

The tree Im using is Linus's tree.

any ideas?

Justin P. Mattock

#3 lore raw
Quoted 11 lines · Justin P. Mattock

wait im lost.. looking at your patch looks the same(number wise) except I see different parts of code in there:

hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE, HFA384X_ROAMING_FIRMWARE);

-       return 0;
+       return ret;

Quoted 8 lines

mine is:

printk(KERN_DEBUG "SCANREQUEST failed\n");
-               ret = -EINVAL;
+               return ret;

The tree Im using is Linus's tree.

I'm using wireless-testing, and the line you're changing is #1692, I'm changing #1699.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/
#4 lore raw
Quoted 19 lines · Julian Calaby
Quoted 18 lines · Justin P. Mattock

wait im lost.. looking at your patch looks the same(number wise) except I see different parts of code in there:

hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,

                                HFA384X_ROAMING_FIRMWARE);
drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
-       return 0;
+       return ret;

mine is:

printk(KERN_DEBUG "SCANREQUEST failed\n");

(quoted diff) +1 -1
-               ret = -EINVAL;
+               return ret;
Quoted 7 lines
Quoted 1 line

The tree Im using is Linus's tree.

I'm using wireless-testing, and the line you're changing is #1692, I'm changing #1699.

Thanks,

ahh.. so there's two return ret's that need to be added then..
(if so then go ahead and take my patch and add it to yours.. I'm off to other things)

cheers,

Justin P. Mattock

#5 lore raw
Quoted 28 lines · Justin P. Mattock
Quoted 27 lines · Julian Calaby
Quoted 12 lines · Justin P. Mattock

wait im lost.. looking at your patch looks the same(number wise) except I see different parts of code in there:

hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE, HFA384X_ROAMING_FIRMWARE);

-       return 0;
+       return ret;

Quoted 8 lines

mine is:

printk(KERN_DEBUG "SCANREQUEST failed\n");
-               ret = -EINVAL;
+               return ret;

The tree Im using is Linus's tree.

I'm using wireless-testing, and the line you're changing is #1692, I'm changing #1699.

Quoted 7 lines
Quoted 2 lines

Thanks,

ahh.. so there's two return ret's that need to be added then.. (if so then go ahead and take my patch and add it to yours.. I'm off to other things)

No.

The function works like this:

1. set up scan_req
2. if local->host_roaming is not set, set host roaming on the hardware
3. set scan_req on the hardware
4. if local->host_roaming is not set, set the hardware to do firmware roaming
5. If set_req could not be set on the hardware, return -EINVAL, otherwise return 0.

The significant bits are steps 2 and 4. These must *both* be executed, regardless of whether setting scan_req on the hardware succeeds or not.

As such, the return value is stored in the ret variable, which is initialised to 0 initially, then set to -EINVAL if setting scan_req on the hardware fails. Hence, step 5 can be performed by returning ret.

As such, all of your patches are wrong as they are either returning the wrong value when setting scan_req on the hardware fails, or failing to execute step 4. The *only* correct place to return a value is once the roaming status of the hardware has been set properly - i.e. at the end of the function.

I hope this has cleared up your confusion.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/
#6 lore raw
Quoted 62 lines · Julian Calaby
Quoted 28 lines · Justin P. Mattock
Quoted 27 lines · Julian Calaby
Quoted 19 lines · Justin P. Mattock

wait im lost.. looking at your patch looks the same(number wise) except I see different parts of code in there:

hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,

                                HFA384X_ROAMING_FIRMWARE);
drivers/net/wireless/hostap/hostap_ioctl.c +1 -1
-       return 0;
+       return ret;

mine is:

printk(KERN_DEBUG "SCANREQUEST failed\n");

(quoted diff) +1 -1
-               ret = -EINVAL;
+               return ret;
Quoted 1 line

The tree Im using is Linus's tree.

I'm using wireless-testing, and the line you're changing is #1692, I'm changing #1699.

Quoted 7 lines
Quoted 2 lines

Thanks,

ahh.. so there's two return ret's that need to be added then.. (if so then go ahead and take my patch and add it to yours.. I'm off to other things)

No.

The function works like this:

1. set up scan_req
2. if local->host_roaming is not set, set host roaming on the hardware
3. set scan_req on the hardware
4. if local->host_roaming is not set, set the hardware to do firmware roaming
5. If set_req could not be set on the hardware, return -EINVAL, otherwise return 0.

The significant bits are steps 2 and 4. These must *both* be executed, regardless of whether setting scan_req on the hardware succeeds or not.

As such, the return value is stored in the ret variable, which is initialised to 0 initially, then set to -EINVAL if setting scan_req on the hardware fails. Hence, step 5 can be performed by returning ret.

As such, all of your patches are wrong as they are either returning the wrong value when setting scan_req on the hardware fails, or failing to execute step 4. The *only* correct place to return a value is once the roaming status of the hardware has been set properly - i.e. at the end of the function.

Quoted 4 lines

I hope this has cleared up your confusion.

Thanks,

cleared it up perfectly... didnt think that using ret down more would work..(was stuck a few lines up) but it does.. just tested your version out and no warning messages..

cheers,

Justin P. Mattock