Re: [PATCH v4 6/6] iio:bmi160: use if (ret) instead of if (ret < 0)

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

 



On 2/4/19 7:15 AM, Fabio Estevam wrote:
On Sat, Feb 2, 2019 at 10:30 PM Martin Kelly <martin@xxxxxxxxxxxxxxxx> wrote:

Jonathan Cameron pointed out that the check is for functions that return
0 on success. Thus, the check should be either "if (ret != 0)" or "if
(ret)". Jonathan prefers "if (ret)", so I'm using that. By leaving it at
"if (ret < 0)", technically a function could return positive numbers and
not count as an error, which is a bug.

I fail to see how regmap_read()/regmap_write() functions could return
positive numbers on error.


It's not that the functions actually do return positive numbers (they don't). It's just that the success criteria is documented as "returns 0 on success". Thus logically the correct check for error is "if (ret != 0)" or just "if (ret)". This also is a bit self-documenting. That's why this patch is a cleanup instead of a bugfix.



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux