linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "dan.carpenter@oracle.com" <dan.carpenter@oracle.com>,
	"lars@metafoo.de" <lars@metafoo.de>
Cc: "kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"Popa, Stefan Serban" <StefanSerban.Popa@analog.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
	"knaack.h@gmx.de" <knaack.h@gmx.de>
Subject: Re: [PATCH] iio: imu: adis16480: clean up a condition
Date: Thu, 26 Sep 2019 11:06:39 +0000	[thread overview]
Message-ID: <9e40c550310d6f30e6481329e01061beb474bc33.camel@analog.com> (raw)
In-Reply-To: <20190926081016.GA2332@mwanda>

On Thu, 2019-09-26 at 11:10 +0300, Dan Carpenter wrote:
> [External]
> 
> The "t" variable is unsigned so it can't be less than zero.  We really
> are just trying to prevent divide by zero bugs so just checking against
> zero is sufficient.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/iio/imu/adis16480.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index b99d73887c9f..e144e567675d 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -318,7 +318,7 @@ static int adis16480_set_freq(struct iio_dev
> *indio_dev, int val, int val2)
>  	unsigned int t, reg;

I would just change the type of "t" to "int".
Especially, since "val" & "val2" are "int".

Thanks for the catch :)
Alex

>  
>  	t =  val * 1000 + val2 / 1000;
> -	if (t <= 0)
> +	if (t == 0)
>  		return -EINVAL;
>  
>  	/*

  reply	other threads:[~2019-09-26 11:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26  8:10 [PATCH] iio: imu: adis16480: clean up a condition Dan Carpenter
2019-09-26 11:06 ` Ardelean, Alexandru [this message]
2019-09-26 11:36   ` Dan Carpenter
2019-10-06  8:51     ` Jonathan Cameron
2019-10-06 18:14       ` Dan Carpenter
2019-10-07  9:21         ` Jonathan Cameron
2019-10-07 14:18           ` Dan Carpenter

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=9e40c550310d6f30e6481329e01061beb474bc33.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=StefanSerban.Popa@analog.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).