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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Kershner <david.kershner@xxxxxxxxxx> writes:
> Visordriver_probe_device gotos were messy, clean them up.
>
> Signed-off-by: David Kershner <david.kershner@xxxxxxxxxx>
> Signed-off-by: Timothy Sell <timothy.sell@xxxxxxxxxx>
> ---
>  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
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux