Received: by 10.192.165.156 with SMTP id m28csp1025311imm; Wed, 18 Apr 2018 02:41:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+0LAexwtwGLdsoKLbaSGzLFqwz+EcfvaLn+Bp9IdjaW9QdUJfk4yvxsQz+SzVacdAVv9Ih X-Received: by 10.99.113.78 with SMTP id b14mr1193651pgn.76.1524044485837; Wed, 18 Apr 2018 02:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524044485; cv=none; d=google.com; s=arc-20160816; b=PNpiBxd0G8NhAXIwVEGvu16Rw+J+Hsk+EAYbWOvzoSMW99NRhUpJCniwYI3QGVbEGG choi4u3xZ3kkmvb3QEorAj5dRSOHWZwHfuiF+wKWwsKw27Svr8LyyIQenIB0MByvELih /t2efJ+tQ0GQ+7Q+9QSqFU9EXP3tJWPHyguWY4G6qOdScbsQ0PWKExmgPnWkpfwVJK+m xXXmWMJD18+XYqhhUWa7FvtTV08E639tfiHJ6HfLFF6R9shfSS2pUPk9gulxMxO/tl1j c9l3KWiH5f3gB25DlMSCC0tPlOmhJOffQkCt9dTa4aiNiWZrwTIZwpijmDGrEnK3dN+N /tEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=MeCHvZG/HwYptoQvZHZd61WrO/jPEF/ZSt6BsbbfF1U=; b=gvK2Ddxn5R4x7a7XBnFQ8iTTjLj6gKEIX757uduLGMhgSihlSr8OPsBD5uzZBFq+D8 jfUekDerJFhMwQTt4AsDIOp/hFM6yO2X0ujvQsaXV3NsbpwSWNUCCeQIeG4xfLXqbEg3 Pi0xHp394mYTe6dc+Pd7ehuhwTkhAurAnYrOWLv0VQyl4dBUvo64g5GVbnhjshGf4AF0 qO5gIl+KcBzv7rRJFfuIQqw9VFGGpWklb0+mN8l+Yt/ywEvyJWFydRcB0mIlQ2bbUU3+ 1zsHVubxF0+lSGRgCMNVqbRszD3frIHAA32fZq6RU7W1/9EeaTJzWs+rVEalg/wrMCdQ QETg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4-v6si937001plo.190.2018.04.18.02.41.11; Wed, 18 Apr 2018 02:41:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbeDRJkD convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Apr 2018 05:40:03 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55368 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750983AbeDRJkC (ORCPT ); Wed, 18 Apr 2018 05:40:02 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 87599342CE0C5; Wed, 18 Apr 2018 17:39:59 +0800 (CST) Received: from localhost (10.202.226.43) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 18 Apr 2018 17:39:56 +0800 Date: Wed, 18 Apr 2018 10:39:48 +0100 From: Jonathan Cameron To: =?ISO-8859-1?Q?Hern=E1n?= Gonzalez CC: Jonathan Cameron , , , Peter Meerwald-Stadler , , , , Subject: Re: [PATCH v2 03/14] staging: iio: ad7746: Fix bound checkings Message-ID: <20180418103948.00004b93@huawei.com> In-Reply-To: References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> <1523637411-8531-4-git-send-email-hernan@vanguardiasur.com.ar> <20180415160550.4705667e@archlinux> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.202.226.43] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Apr 2018 11:47:05 -0300 Hern?n Gonzalez wrote: > On Sun, Apr 15, 2018 at 12:05 PM, Jonathan Cameron wrote: > > On Fri, 13 Apr 2018 13:36:40 -0300 > > Hern?n Gonzalez wrote: > > > >> Also remove unnecessary parenthesis > > I am probably missing something. I'm not sure what you mean > > by fix bound checking? There are superfluous brackets, but > > I don't see any functional change to indicate there was anything > > wrong with the original checks. > > > > Maybe I'm wrong but | is a bitwise operator while || is a logical one. > There are no functional changes as you said but, from K&R, "One must > distinguish the bitwise operators & and | from the logical operators > && and II, which imply left-to-right evaluation of a truth value. For > example, if x is 1 and y is 2, then x & y is zero while x && y is one" > so it'd be slightly faster if the first condition is true, and it > would be the "correct" operator to use in this case, even though it > doesn't affect the result. Got you, I missed the operator change entirely. Doh. Jonathan > > >> > >> Signed-off-by: Hern?n Gonzalez > >> --- > >> drivers/staging/iio/cdc/ad7746.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c > >> index 516aa93..d793785 100644 > >> --- a/drivers/staging/iio/cdc/ad7746.c > >> +++ b/drivers/staging/iio/cdc/ad7746.c > >> @@ -458,7 +458,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, > >> ret = 0; > >> break; > >> case IIO_CHAN_INFO_CALIBBIAS: > >> - if ((val < 0) | (val > 0xFFFF)) { > >> + if (val < 0 || val > 0xFFFF) { > >> ret = -EINVAL; > >> goto out; > >> } > >> @@ -470,7 +470,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, > >> ret = 0; > >> break; > >> case IIO_CHAN_INFO_OFFSET: > >> - if ((val < 0) | (val > 43008000)) { /* 21pF */ > >> + if (val < 0 || val > 43008000) { /* 21pF */ > >> ret = -EINVAL; > >> goto out; > >> } > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html