Re: [PATCH] staging: xillybus: Consolidate return statements in xilly_probe()

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

 



On Wed, Jun 18, 2014 at 02:10:21PM +0200, Tobias Klauser wrote:
> No need for two return statements, just call xillybus_do_cleanup() in
> case of an error before returning.
> 
> Signed-off-by: Tobias Klauser <tklauser@xxxxxxxxxx>
> ---
>  drivers/staging/xillybus/xillybus_pcie.c |    7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c
> index a4fe51c..518ba6c 100644
> --- a/drivers/staging/xillybus/xillybus_pcie.c
> +++ b/drivers/staging/xillybus/xillybus_pcie.c
> @@ -200,11 +200,8 @@ static int xilly_probe(struct pci_dev *pdev,
>  	}
>  
>  	rc = xillybus_endpoint_discovery(endpoint);
> -
> -	if (!rc)
> -		return 0;

Yes.  I don't like the original code which does "success handling"
instead or error handling.

> -
> -	xillybus_do_cleanup(&endpoint->cleanup, endpoint);
> +	if (rc)
> +		xillybus_do_cleanup(&endpoint->cleanup, endpoint);
>  
>  	return rc;

I don't like when people mix error and success paths like this.  It's
not really a clean up.  Keep the two paths entirely separate.

I started to look at what xillybus_do_cleanup() does, but according to
later emails it goes away completely.  That is a better solution.

regards,
dan carpenter

_______________________________________________
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