lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170503180623.GA21159@kroah.com>
Date:   Wed, 3 May 2017 11:06:23 -0700
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Johan Hovold <johan@...nel.org>, Rob Herring <robh@...nel.org>,
        "linux-serial@...r.kernel.org" <linux-serial@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Andrey Smirnov <andrew.smirnov@...il.com>
Subject: Re: [PATCH] tty: serdev: fix serdev_device_write return value

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@...nel.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ