[PATCH 5/6] staging: unisys: visorbus: Cleanup gotos in visordriver_probe_device

Jes Sorensen Jes.Sorensen at redhat.com
Wed Mar 9 15:47:21 UTC 2016


David Kershner <david.kershner at unisys.com> writes:
> Visordriver_probe_device gotos were messy, clean them up.
>
> Signed-off-by: David Kershner <david.kershner at unisys.com>
> Signed-off-by: Timothy Sell <timothy.sell at unisys.com>
> ---
>  drivers/staging/unisys/visorbus/visorbus_main.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
> index 26e0374..6a228c8 100644
> --- a/drivers/staging/unisys/visorbus/visorbus_main.c
> +++ b/drivers/staging/unisys/visorbus/visorbus_main.c
> @@ -751,20 +751,21 @@ visordriver_probe_device(struct device *xdev)
>  	wmb();
>  	get_device(&dev->device);
>  	if (!drv->probe) {
> -		up(&dev->visordriver_callback_lock);
>  		rc = -ENODEV;
> -		goto away;
> +		goto err_put_and_up;
>  	}
>  	rc = drv->probe(dev);
>  	if (rc < 0)
> -		goto away;
> +		goto err_put_and_up;
>  
>  	fix_vbus_dev_info(dev);
>  	up(&dev->visordriver_callback_lock);
> +	return 0; /* success: reference kept via unmatched get_device() */
>  	rc = 0;
> -away:
> -	if (rc != 0)
> -		put_device(&dev->device);
> +
> +err_put_and_up:
> +	put_device(&dev->device);
> +	up(&dev->visordriver_callback_lock);
>  	return rc;
>  }

David,

This doesn't look right - you add a return 0 but then leave the rc = 0
assignment below it, which will never get executed given the goto label
is further down.

Why this obsession with getting rid of the gotos?

Cheers,
Jes


More information about the devel mailing list