Re: [PATCH v7 27/34] i2c: tegra: Check errors for both positive and negative values

Thierry Reding
2020-09-21T11:24:32Z

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

On Thu, Sep 17, 2020 at 04:50:06PM +0300, Andy Shevchenko wrote:
> On Thu, Sep 17, 2020 at 3:09 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> > On Wed, Sep 09, 2020 at 01:39:59AM +0300, Dmitry Osipenko wrote:
>
> > Why? All of these functions "return 0 on success or a negative error
> > code on failure", don't they?
>
> And what is the point of having ' < 0' in all those cases?

It's explicitly checking for the documented error cases. And you'll
occasionally have a function that can return non-zero on success.
Testing for < 0 is the safest way to check for failure in the majority
of cases.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]