Received: by 10.192.165.156 with SMTP id m28csp728415imm; Mon, 16 Apr 2018 07:49:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx49K+tg6szi0a3+C38FoHaMPkJCiOvFCSBKmruQbiEpVLXfcnqs68AbKrCMc/9dCHV6hLCDb X-Received: by 2002:a17:902:e8:: with SMTP id a95-v6mr1987228pla.274.1523890167360; Mon, 16 Apr 2018 07:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523890167; cv=none; d=google.com; s=arc-20160816; b=QX9Fzv2ZrbDV7n268rAgD5OLQ7uYaBQqBPfm/VcUVeZfoFKAc2//+jV/74jfw4KIKH OudWh7scaVhfNI8+SyjS2Ogc1N/164UYhK+7IQUYpboqrh3HeAjGdL9hw+ArLxPCaKTu 75LHAuM/89bRmL/aUsbuz2YcpTjw/sPNC6uf5Ecb9UAU3ZdNnmvYOgZ5QJM7wIJlSXZX juDQZu+9EqZFGyEzEPKN3+egKCn/WsdFv3/vgoKx8tvkPULn+REpJVv8npI6Pz9K3wRh 6+GTC8VrRx1t13QKkrtBd4oAzhC6rAO9y/0rCCCS2oj1v0zUwOBqjl99ocX/0TVR/Ii0 cS2w== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=V8JU4ZKRUgO5kQfNLel1uGf2gV5B3sbcfYFFnwMjr3Y=; b=H4txRBdIkSHbI6S9LpikSBKrF2Ti+cdQnhhefqyENW6eNTrNPI1HI8/WvdLXUamI1Q Bs7xI6Z8qPx4t3ZSAJffT/spJuw2QgueOWsfcnj6gBESBtoI8UBsYF1u9ouFM8P9F9YB 5HS33XyrHmVjwq1Bl/GGN85GAp6+mF7KYTKsl/DCHfhBjzVMpKEJ/5fYAkc+kbL41g64 ybHPFHbXvsNHLvbTejXECAkkrAStyx4ZWh5PRU99cV4f7inuPGhpiSIq6ZEEgWAkJYoC EYgNWPlIGtrM9KpJCASQQ1IFuARE66zADylSNA/Irlwo4JDD1Phx4Su9TrMvXi1xYdbJ 4NMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=09HnfZ7D; 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 l12si9638302pgc.438.2018.04.16.07.49.13; Mon, 16 Apr 2018 07:49:27 -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; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=09HnfZ7D; 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 S1751149AbeDPOr2 (ORCPT + 99 others); Mon, 16 Apr 2018 10:47:28 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:43896 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750799AbeDPOr0 (ORCPT ); Mon, 16 Apr 2018 10:47:26 -0400 Received: by mail-io0-f194.google.com with SMTP id q84so18353183iod.10 for ; Mon, 16 Apr 2018 07:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=V8JU4ZKRUgO5kQfNLel1uGf2gV5B3sbcfYFFnwMjr3Y=; b=09HnfZ7DrOlPBeCkj+se6baT9QQOu2Hf/+yZXZaSveTLMXbjgykScTsQ7WNKuzeFxv eOhdSef+yYVJ+uRQqt40Bfg7a2R4LosKk2gnlIMz03tKXiVkRZSQi+xusgDSPovNvQUU BUTrIIFN3/NEr33XQCd9TQStKeAufXtoI4Nbra35JWceYkZQCDWEawpLfnSw2BMsVDcK Q5mVB5jpTpiCm5Xuowp2PSDSF+tMAO2q6ZwO+b9FChUgVd1lZOYTnOS4H0VZ2RoEc0NP aUa0Lc5a6u2pHBesUYYvEbx1q27rDKrvUOVkyctXtedzlZjXe6bLdsUHxWucNVR+Ogbk y/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=V8JU4ZKRUgO5kQfNLel1uGf2gV5B3sbcfYFFnwMjr3Y=; b=LN5Me6pu8R8IRp4addMpGD0IpJ5RN2g3dbyzEUF9x3UGmB8dmYqfFe5m4oRgpCv6ho xLXZjO92IIN9yNXRVOz44aI/hgQb/PoRxuRRMfe7O2TTklkWxv35kq0qhEDRNofXkNih Sn3m/JY93cjcUjDjijpcJGrMtmA3mzaPSZdmE8+78SsfFRGrCfIWD9I4N2Cfu1BFwiSF bBlMl9y0DxjhQXSuo7OZ8NVLkulxp1bjEBL4+IICMVQHnY7srh1cmqnfPCJt4yvRUrGo 8TFnvEt2Kl0MmmLe1reHoOXvuB4df6eL17V1RyhYX/6wybC4uD0+Y86lRy8wh8G7DWjO WYMA== X-Gm-Message-State: ALQs6tCl6NnjRl4TEr59SmmrMWDUUqM6BlURGNLUDSrpZ9UfuSMCIBAf irwP1UUtWj4JItZkU08CGiZNpNbxcss7WdhvE2AQtw== X-Received: by 10.107.69.14 with SMTP id s14mr3069420ioa.278.1523890045724; Mon, 16 Apr 2018 07:47:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.63.196 with HTTP; Mon, 16 Apr 2018 07:47:05 -0700 (PDT) In-Reply-To: <20180415160550.4705667e@archlinux> References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> <1523637411-8531-4-git-send-email-hernan@vanguardiasur.com.ar> <20180415160550.4705667e@archlinux> From: =?UTF-8?Q?Hern=C3=A1n_Gonzalez?= Date: Mon, 16 Apr 2018 11:47:05 -0300 Message-ID: Subject: Re: [PATCH v2 03/14] staging: iio: ad7746: Fix bound checkings To: Jonathan Cameron Cc: knaack.h@gmx.de, lars@metafoo.de, Peter Meerwald-Stadler , gregkh@linuxfoundation.org, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 15, 2018 at 12:05 PM, Jonathan Cameron wrote= : > On Fri, 13 Apr 2018 13:36:40 -0300 > Hern=C3=A1n 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. >> >> Signed-off-by: Hern=C3=A1n 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_de= v, >> ret =3D 0; >> break; >> case IIO_CHAN_INFO_CALIBBIAS: >> - if ((val < 0) | (val > 0xFFFF)) { >> + if (val < 0 || val > 0xFFFF) { >> ret =3D -EINVAL; >> goto out; >> } >> @@ -470,7 +470,7 @@ static int ad7746_write_raw(struct iio_dev *indio_de= v, >> ret =3D 0; >> break; >> case IIO_CHAN_INFO_OFFSET: >> - if ((val < 0) | (val > 43008000)) { /* 21pF */ >> + if (val < 0 || val > 43008000) { /* 21pF */ >> ret =3D -EINVAL; >> goto out; >> } >