staging: r8188eu: Reorganize error handling in rtw_drv_init()
authorNathan Chancellor <nathan@kernel.org>
Thu, 12 Aug 2021 20:40:27 +0000 (13:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Aug 2021 06:37:19 +0000 (08:37 +0200)
commit0bd35146642bdc56f1b87d75f047b1c92bd2bd39
tree891d997a649dcfb08ebf734a14d18cb7f01cbe29
parent72a5e1d7496309e9734d20073a81a9bbffd8d79d
staging: r8188eu: Reorganize error handling in rtw_drv_init()

After commit 987219ad34a6 ("staging: r8188eu: remove lines from Makefile
that silence build warnings"), clang warns:

drivers/staging/r8188eu/os_dep/usb_intf.c:726:6: warning: variable
'status' is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
        if (!if1) {
            ^~~~
drivers/staging/r8188eu/os_dep/usb_intf.c:741:6: note: uninitialized use
occurs here
        if (status != _SUCCESS)
            ^~~~~~
drivers/staging/r8188eu/os_dep/usb_intf.c:726:2: note: remove the 'if'
if its condition is always false
        if (!if1) {
        ^~~~~~~~~~~
drivers/staging/r8188eu/os_dep/usb_intf.c:714:12: note: initialize the
variable 'status' to silence this warning
        int status;
                  ^
                   = 0
1 warning generated.

status is not initialized if the call to usb_dvobj_init() or
rtw_usb_if1_init() fails.

Looking at the error function as a whole, the error handling is odd
compared to the rest of the kernel, which prefers to set error codes on
goto paths, rather than a global "status" variable which determines the
error code at the end of the function and function calls in the case of
error.

Rearrange the error handling of this function to bring it more inline
with how the kernel does it in most cases, which helps readability.

The call to rtw_usb_if1_deinit() is eliminated because it is not
possible to ever hit it; if rtw_usb_if1_init() fails, the goto call
jumps over the call to rtw_usb_if1_deinit() and in the success case,
status is set to _SUCCESS.

Acked-by: Phillip Potter <phil@philpotter.co.uk>
Acked-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210812204027.338872-4-nathan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/os_dep/usb_intf.c