Re: [patch] iio:dac:ad5449: unlock on error path

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

 



On Fri, Nov 02, 2012 at 05:52:26PM +0100, walter harms wrote:
> if i understand the code correct you can simply the flow
> by turning the check on its head.
> 
> ret = spi_sync(st->spi, &msg);
> if (ret>=0)
>     *val = be16_to_cpu(st->data[1]);
> mutex_unlock(&indio_dev->mlock);
> return ret;

It's better to always treat errors as the special case and success
as the normal case.  It makes the code more readable if every check
is consistent.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux