On 2014-08-12 at 20:54:48 +0200, Jeshwanth Kumar N K <jeshkumar...@gmail.com> 
wrote:
> removed goto label, and directly returning 0 not through goto.
> 
> Signed-off-by: Jeshwanth Kumar N K <jeshkumar...@gmail.com>
> ---
>  drivers/staging/wlan-ng/prism2mgmt.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
> b/drivers/staging/wlan-ng/prism2mgmt.c
> index 5837b0e..9218399 100644
> --- a/drivers/staging/wlan-ng/prism2mgmt.c
> +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> @@ -1107,8 +1107,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void 
> *msgp)
>               if (wlandev->netdev->type == ARPHRD_ETHER) {
>                       msg->resultcode.data =
>                           P80211ENUM_resultcode_invalid_parameters;
> -                     result = 0;
> -                     goto exit;
> +                     return 0;
>               }
>               /* Disable monitor mode */
>               result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
> @@ -1166,8 +1165,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void 
> *msgp)
>  
>               netdev_info(wlandev->netdev, "monitor mode disabled\n");
>               msg->resultcode.data = P80211ENUM_resultcode_success;
> -             result = 0;
> -             goto exit;
> +             return 0;
>       case P80211ENUM_truth_true:
>               /* Disable the port (if enabled), only check Port 0 */
>               if (hw->port_enabled[0]) {
> @@ -1312,17 +1310,13 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void 
> *msgp)
>               }
>  
>               msg->resultcode.data = P80211ENUM_resultcode_success;
> -             result = 0;
> -             goto exit;
> +             return 0;
>       default:
>               msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
> -             result = 0;
> -             goto exit;
> +             return 0;
>       }
>  
>  failed:
>       msg->resultcode.data = P80211ENUM_resultcode_refused;
>       result = 0;
> -exit:
> -     return result;

You will still need the return here for the cases where the 'failed'
label is the jump target. Also, this change leads to a compiler warning:

drivers/staging/wlan-ng/prism2usb.c: In function ‘prism2mgmt_wlansniff’:
drivers/staging/wlan-ng/prism2mgmt.c:1322:1: warning: control reaches end of 
non-void function [-Wreturn-type]

In any case, resetting the return value to 0 makes the function always return
successfully  and seems to signal the error condition by setting
msg->resultcode.data. This looks a bit odd to me and also doesn't correspond to
the documentation of the function's return value. It might be worthwile to take
a closer look there as well.

Thanks
Tobias
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to