lkml.org 
[lkml]   [2017]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] tty: serdev: fix serdev_device_write return value
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;

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2017-05-03 19:44    [W:0.088 / U:0.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site