public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Johan Hovold <johan@kernel.org>, Rob Herring <robh@kernel.org>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: Re: [PATCH] tty: serdev: fix serdev_device_write return value
Date: Wed, 3 May 2017 11:06:23 -0700	[thread overview]
Message-ID: <20170503180623.GA21159@kroah.com> (raw)
In-Reply-To: <CAHp75Vc+pK5cMkO=1dHR-Xx8zhe4RR0Zv5KDvChZE6MUfVQwcQ@mail.gmail.com>

On Wed, May 03, 2017 at 08:44:07PM +0300, Andy Shevchenko wrote:
> On Tue, May 2, 2017 at 12:25 PM, Johan Hovold <johan@kernel.org> wrote:
> > On Mon, May 01, 2017 at 07:17:14PM -0500, Rob Herring wrote:
> 
> >> -     return ret < 0 ? ret : (count ? -ETIMEDOUT : 0);
> >> +     return ret < 0 ? ret : (count ? -ETIMEDOUT : wr_cnt);
> >
> > That's some nasty use of the ternary operator. Ditching it completely
> > would be more readable.
> >
> >         if (ret < 0)
> >                 return ret;
> >
> >         if (count)
> >                 return -ETIMEDOUT;
> >
> >         return wr_count;
> 
> 
> While I agree on the first part, I would go still with one ternary at the end:
> 
>             return count ? -ETIMEDOUT : wr_count;

Ick, no, make it easy to read, we write code for developers first, the
compiler second.  Ditching it completly is a good idea.

thanks,

greg k-h

      reply	other threads:[~2017-05-03 18:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02  0:17 [PATCH] tty: serdev: fix serdev_device_write return value Rob Herring
2017-05-02  9:25 ` Johan Hovold
2017-05-02 12:30   ` Rob Herring
2017-05-03 17:44   ` Andy Shevchenko
2017-05-03 18:06     ` Greg Kroah-Hartman [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=20170503180623.GA21159@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrew.smirnov@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh@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