Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753916AbdC2QQR (ORCPT ); Wed, 29 Mar 2017 12:16:17 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34018 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752827AbdC2QQN (ORCPT ); Wed, 29 Mar 2017 12:16:13 -0400 MIME-Version: 1.0 In-Reply-To: <1490790791-5694-2-git-send-email-singhalsimran0@gmail.com> References: <1490790791-5694-1-git-send-email-singhalsimran0@gmail.com> <1490790791-5694-2-git-send-email-singhalsimran0@gmail.com> From: Daniel Baluta Date: Wed, 29 Mar 2017 19:16:11 +0300 Message-ID: Subject: Re: [Outreachy kernel] [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro To: simran singhal Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , "linux-iio@vger.kernel.org" , Linux Kernel Mailing List , outreachy-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1041 Lines: 30 On Wed, Mar 29, 2017 at 3:33 PM, simran singhal wrote: > Use macro min() to get the minimum of two values for brevity and > readability. > > Signed-off-by: simran singhal > --- > drivers/iio/common/st_sensors/st_sensors_i2c.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c > index c83df4d..7a68fdd 100644 > --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c > +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c > @@ -39,7 +39,7 @@ static int st_sensors_i2c_read_byte(struct st_sensor_transfer_buffer *tb, > *res_byte = err & 0xff; > > st_accel_i2c_read_byte_error: > - return err < 0 ? err : 0; > + return min(err, 0); > } Appreciate the brevity but this certainly doesn't make code easier to read. In linux kernel err < 0 signifies an error and be replacing comparison < 0 with min() we some hide the meaning of this. thanks, Daniel.