From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754164AbdECSGk (ORCPT ); Wed, 3 May 2017 14:06:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41738 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbdECSGb (ORCPT ); Wed, 3 May 2017 14:06:31 -0400 Date: Wed, 3 May 2017 11:06:23 -0700 From: Greg Kroah-Hartman To: Andy Shevchenko Cc: Johan Hovold , Rob Herring , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Andrey Smirnov Subject: Re: [PATCH] tty: serdev: fix serdev_device_write return value Message-ID: <20170503180623.GA21159@kroah.com> References: <20170502001714.11576-1-robh@kernel.org> <20170502092527.GC2973@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 03, 2017 at 08:44:07PM +0300, Andy Shevchenko wrote: > On Tue, May 2, 2017 at 12:25 PM, Johan Hovold 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