All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: "Hernán Gonzalez" <hernan@vanguardiasur.com.ar>
Cc: Jonathan Cameron <jic23@kernel.org>, <knaack.h@gmx.de>,
	<lars@metafoo.de>, Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	<gregkh@linuxfoundation.org>, <Michael.Hennerich@analog.com>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 03/14] staging: iio: ad7746: Fix bound checkings
Date: Wed, 18 Apr 2018 10:39:48 +0100	[thread overview]
Message-ID: <20180418103948.00004b93@huawei.com> (raw)
In-Reply-To: <CALfa3vFgh7jtb=B6doOu-y2Bm77wu4zVdLE1LuxbruTTKjLU=A@mail.gmail.com>

On Mon, 16 Apr 2018 11:47:05 -0300
Hernán Gonzalez <hernan@vanguardiasur.com.ar> wrote:

> On Sun, Apr 15, 2018 at 12:05 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> > On Fri, 13 Apr 2018 13:36:40 -0300
> > Hernán Gonzalez <hernan@vanguardiasur.com.ar> 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 <hernan@vanguardiasur.com.ar>
> >> ---
> >>  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


  reply	other threads:[~2018-04-18  9:40 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 16:36 [PATCH v2 00/14] Move ad7746 driver out of staging Hernán Gonzalez
2018-04-13 16:36 ` [PATCH v2 01/14] staging: iio: ad7746: Automatically swap values in readings/writings Hernán Gonzalez
2018-04-15 15:02   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 02/14] staging: iio: ad7746: Adjust arguments to match open parenthesis Hernán Gonzalez
2018-04-15 15:03   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 03/14] staging: iio: ad7746: Fix bound checkings Hernán Gonzalez
2018-04-15 15:05   ` Jonathan Cameron
2018-04-16 14:47     ` Hernán Gonzalez
2018-04-16 14:47       ` Hernán Gonzalez
2018-04-18  9:39       ` Jonathan Cameron [this message]
2018-04-21 14:40         ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 04/14] staging: iio: ad7746: Fix multiple line dereference Hernán Gonzalez
2018-04-15 15:07   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 05/14] staging: iio: ad7746: Reorder includes alphabetically Hernán Gonzalez
2018-04-15 15:09   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 06/14] staging: iio: ad7746: Reorder variable declarations Hernán Gonzalez
2018-04-15 15:10   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 07/14] staging: iio: ad7746: Remove unused defines Hernán Gonzalez
2018-04-15 15:12   ` Jonathan Cameron
2018-04-16 14:50     ` Hernán Gonzalez
2018-04-16 14:50       ` Hernán Gonzalez
2018-04-13 16:36 ` [PATCH v2 08/14] staging: iio: ad7746: Add dt-bindings Hernán Gonzalez
2018-04-15 15:19   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 09/14] staging: iio: ad7746: Add remove() Hernán Gonzalez
2018-04-15 15:31   ` Jonathan Cameron
2018-04-18 19:25     ` Hernán Gonzalez
2018-04-18 19:25       ` Hernán Gonzalez
2018-04-19  9:14       ` Michael Hennerich
2018-04-13 16:36 ` [PATCH v2 10/14] staging: iio: ad7746: Add comments Hernán Gonzalez
2018-04-15 15:35   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 11/14] staging: iio: ad7746: Add devicetree bindings documentation Hernán Gonzalez
2018-04-15 15:37   ` Jonathan Cameron
2018-04-16 14:55     ` Hernán Gonzalez
2018-04-16 14:55       ` Hernán Gonzalez
2018-04-16 20:08   ` Rob Herring
2018-04-13 16:36 ` [PATCH v2 12/14] staging: iio: ad7746: Add ABI documentation Hernán Gonzalez
2018-04-15 15:40   ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 13/14] Move ad7746 out of staging Hernán Gonzalez
2018-04-15 17:04   ` Jonathan Cameron
2018-04-15 18:46     ` Joe Perches
2018-04-15 19:48       ` Jonathan Cameron
2018-04-13 16:36 ` [PATCH v2 14/14] staging: iio: Remove ad7746 from staging Hernán Gonzalez
2018-04-15 15:43   ` Jonathan Cameron
2018-04-15 19:24     ` Joe Perches
2018-04-15 19:52       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180418103948.00004b93@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hernan@vanguardiasur.com.ar \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.