Received: by 10.192.165.148 with SMTP id m20csp1406035imm; Sat, 21 Apr 2018 07:43:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+NR2ibaj/bgQWcnMmw/fBRS7X3hN5FG309uLg7qxcGkfxWdwybNep1f/ne2Wk6/7V9JyCt X-Received: by 10.98.196.19 with SMTP id y19mr8637732pff.97.1524321836226; Sat, 21 Apr 2018 07:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524321836; cv=none; d=google.com; s=arc-20160816; b=gxp2RPVN0edf8G1PYdGQO7l/fuX/FQihE6/b0OpvTzG50/5f5Yme+p+3oZEiBfhDVK BKUJvqVMz2U+Nw4wQlV1l7Jrm2lxNjXLkK6rcQDuQStSyA/rEuNdxFwdQEg7cH9FqqP9 Q9WPK97GCQdyWQBAw4GS2g9seeId6CJZ/p9sK+MbwnelAj6nEwPzcs0tiXejJaADAdlJ wjIu2cpmvRq7Jk0zBYOpN5jdNVrd3uLia4/6nn0zcABV2dQzB7xx43yuq3aLevX4dgLW pQj2GJiwxbzkLuo6xcqvwya4r0KAGMzM1wmKNN5tGKuuadHo0FCJIdHGj8UQBxuhpeN0 HJfw== 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 :dmarc-filter:arc-authentication-results; bh=nEm8/HBpeIw7qwJkxolu5Kg8g35q5JoHFFtN0C9zcQ4=; b=TilqS0YAjAWycAoho0klAAvXg9INoJAgu6RC2eqPc8WVjYsJY34MYJgIqWx8SB4pKB 3MXyc69Bx5YJio6TxrMlv4Kk5ZLwQZLpLb9KVjAYnlBd+b6vhkYMYsKgUlYU8PWLLHCm x+cKs8tan3PlR+xArROSRrq109vqnKyl8hxPnPRNLiOqhiRPR2F8VwX3zXA1oVmNFVhw va/B69bh5NplOfuydIGjE+uWPuOBTFa+OKBJb9Nq8GaPrhj5KR8uMB2cWDX9crHgUORT Eolt4tWgVy0qIhk1jutpCU/eB/9F5WBDFj1FgsUiBbLd/xbinnp79WWerRkAp2wm4D69 314A== 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 1-v6si7945920plo.228.2018.04.21.07.43.18; Sat, 21 Apr 2018 07:43:56 -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 S1752838AbeDUOkX convert rfc822-to-8bit (ORCPT + 99 others); Sat, 21 Apr 2018 10:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:33558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752754AbeDUOkW (ORCPT ); Sat, 21 Apr 2018 10:40:22 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BDC5204EF; Sat, 21 Apr 2018 14:40:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BDC5204EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sat, 21 Apr 2018 15:40:13 +0100 From: Jonathan Cameron To: Jonathan Cameron Cc: =?UTF-8?B?SGVybsOhbg==?= Gonzalez , , , Peter Meerwald-Stadler , , , , Subject: Re: [PATCH v2 03/14] staging: iio: ad7746: Fix bound checkings Message-ID: <20180421154013.3e9c3c3e@archlinux> In-Reply-To: <20180418103948.00004b93@huawei.com> References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> <1523637411-8531-4-git-send-email-hernan@vanguardiasur.com.ar> <20180415160550.4705667e@archlinux> <20180418103948.00004b93@huawei.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Apr 2018 10:39:48 +0100 Jonathan Cameron wrote: > 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. > Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > 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 > > -- > 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