linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Kelly <martin@martingkelly.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: linux-iio@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Rob Herring <robh+dt@kernel.org>,
	Daniel Baluta <daniel.baluta@gmail.com>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH v4 6/6] iio:bmi160: use if (ret) instead of if (ret < 0)
Date: Mon, 4 Feb 2019 09:07:50 -0800	[thread overview]
Message-ID: <1197951a-61c3-65a7-b7c7-2396116ea13e@martingkelly.com> (raw)
In-Reply-To: <CAOMZO5BNK+v6t3qFYs5b+NpPHkrR4jiuy13DsM=AOQxAR3kY4g@mail.gmail.com>

On 2/4/19 7:15 AM, Fabio Estevam wrote:
> On Sat, Feb 2, 2019 at 10:30 PM Martin Kelly <martin@martingkelly.com> 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.

      reply	other threads:[~2019-02-04 17:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-02 21:55 [PATCH v4 0/6] iio:bmi160: add drdy interrupt support Martin Kelly
2019-02-02 21:55 ` [PATCH v4 1/6] iio:bmi160: add SPDX identifiers Martin Kelly
2019-02-09 14:49   ` Jonathan Cameron
2019-02-02 21:55 ` [PATCH v4 2/6] iio:bmi160: add drdy interrupt support Martin Kelly
2019-02-09 15:15   ` Jonathan Cameron
2019-02-02 21:55 ` [PATCH v4 3/6] dt-bindings: fix incorrect bmi160 IRQ note Martin Kelly
2019-02-09 15:17   ` Jonathan Cameron
2019-02-09 18:37     ` Martin Kelly
2019-02-02 21:55 ` [PATCH v4 4/6] dt-bindings: document open-drain property Martin Kelly
2019-02-09 15:20   ` Jonathan Cameron
2019-02-02 21:56 ` [PATCH v4 5/6] iio:bmi160: use iio_pollfunc_store_time Martin Kelly
2019-02-09 15:24   ` Jonathan Cameron
2019-02-02 21:56 ` [PATCH v4 6/6] iio:bmi160: use if (ret) instead of if (ret < 0) Martin Kelly
2019-02-02 23:12   ` Fabio Estevam
2019-02-03  0:30     ` Martin Kelly
2019-02-04 15:15       ` Fabio Estevam
2019-02-04 17:07         ` Martin Kelly [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1197951a-61c3-65a7-b7c7-2396116ea13e@martingkelly.com \
    --to=martin@martingkelly.com \
    --cc=daniel.baluta@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).