linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] iio:dac:ad5449: unlock on error path
Date: Mon, 5 Nov 2012 09:38:23 +0300	[thread overview]
Message-ID: <20121105063823.GA11515@mwanda> (raw)
In-Reply-To: <5093FA4A.2010006@bfs.de>

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

      reply	other threads:[~2012-11-05  6:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  7:13 [patch] iio:dac:ad5449: unlock on error path Dan Carpenter
2012-10-24  8:22 ` Lars-Peter Clausen
2012-11-02 11:06   ` Jonathan Cameron
2012-11-02 16:52     ` walter harms
2012-11-05  6:38       ` Dan Carpenter [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=20121105063823.GA11515@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=jic23@cam.ac.uk \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=wharms@bfs.de \
    /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).