linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison
@ 2016-09-28 13:41 Ico Doornekamp
  2016-10-01 16:09 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Ico Doornekamp @ 2016-09-28 13:41 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Ico Doornekamp

reported by 'make W=2' in ad7606_oversampling_get_index()

Signed-off-by: Ico Doornekamp <ico@pruts.nl>
---
 drivers/staging/iio/adc/ad7606_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index f79ee61..681389a 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -158,7 +158,7 @@ static ssize_t ad7606_show_oversampling_ratio(struct device *dev,
 static int ad7606_oversampling_get_index(unsigned int val)
 {
 	unsigned char supported[] = {0, 2, 4, 8, 16, 32, 64};
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(supported); i++)
 		if (val == supported[i])
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison
  2016-09-28 13:41 [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison Ico Doornekamp
@ 2016-10-01 16:09 ` Jonathan Cameron
  2016-10-01 16:17   ` Ico Doornekamp
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2016-10-01 16:09 UTC (permalink / raw)
  To: Ico Doornekamp; +Cc: linux-iio

On 28/09/16 14:41, Ico Doornekamp wrote:
> reported by 'make W=2' in ad7606_oversampling_get_index()
> 
> Signed-off-by: Ico Doornekamp <ico@pruts.nl>
hmm. It's pretty much a non problem in the first place as we know
it can't cause issues (can see it is 7).   Also this really just
moves to typecasting it later when we return i.

So unless I'm missing something I'm not going to apply this one.

If Greg picks it up I don't mind though as doesn't do any harm
really.

Jonathan
> ---
>  drivers/staging/iio/adc/ad7606_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
> index f79ee61..681389a 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c
> +++ b/drivers/staging/iio/adc/ad7606_core.c
> @@ -158,7 +158,7 @@ static ssize_t ad7606_show_oversampling_ratio(struct device *dev,
>  static int ad7606_oversampling_get_index(unsigned int val)
>  {
>  	unsigned char supported[] = {0, 2, 4, 8, 16, 32, 64};
> -	int i;
> +	unsigned int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(supported); i++)
>  		if (val == supported[i])
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison
  2016-10-01 16:09 ` Jonathan Cameron
@ 2016-10-01 16:17   ` Ico Doornekamp
  2016-10-01 16:49     ` Alison Schofield
  0 siblings, 1 reply; 5+ messages in thread
From: Ico Doornekamp @ 2016-10-01 16:17 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

* On 2016-10-01 18:09:44 +0200, Jonathan Cameron wrote:
 
> On 28/09/16 14:41, Ico Doornekamp wrote:
> > reported by 'make W=2' in ad7606_oversampling_get_index()
> > 
> > Signed-off-by: Ico Doornekamp <ico@pruts.nl>
> hmm. It's pretty much a non problem in the first place as we know
> it can't cause issues (can see it is 7).   Also this really just
> moves to typecasting it later when we return i.
> 
> So unless I'm missing something I'm not going to apply this one.

Fair enough. It's one of those little penguin task things again, you
probably guessed already. 'Find a bug reported by sparse and fix it'.
But your IIO tree is simply too high-quality, sparse has nothing to
complain :)

-- 
:wq
^X^Cy^K^X^C^C^C^C

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison
  2016-10-01 16:17   ` Ico Doornekamp
@ 2016-10-01 16:49     ` Alison Schofield
  2016-10-01 17:27       ` Ico Doornekamp
  0 siblings, 1 reply; 5+ messages in thread
From: Alison Schofield @ 2016-10-01 16:49 UTC (permalink / raw)
  To: Ico Doornekamp; +Cc: Jonathan Cameron, linux-iio

On Sat, Oct 01, 2016 at 06:17:02PM +0200, Ico Doornekamp wrote:
> * On 2016-10-01 18:09:44 +0200, Jonathan Cameron wrote:
>  
> > On 28/09/16 14:41, Ico Doornekamp wrote:
> > > reported by 'make W=2' in ad7606_oversampling_get_index()
> > > 
> > > Signed-off-by: Ico Doornekamp <ico@pruts.nl>
> > hmm. It's pretty much a non problem in the first place as we know
> > it can't cause issues (can see it is 7).   Also this really just
> > moves to typecasting it later when we return i.
> > 
> > So unless I'm missing something I'm not going to apply this one.
> 
> Fair enough. It's one of those little penguin task things again, you
> probably guessed already. 'Find a bug reported by sparse and fix it'.
> But your IIO tree is simply too high-quality, sparse has nothing to
> complain :)

Hi Ico,

Flattering the maintainer, always good and so true, so true :)

Here's something found by sparse for little penguin.
See the Outreachy tasks page.  https://kernelnewbies.org/IIO_tasks

You'll see I leveraged your IIO_CHAN* patch for the first coding task.
We have a second coding task for sparse endianness patches.  There are
some remaining.  If you tell me you're grabbing one, I'll put it on
our claimed page so an applicant doesn't start on it. 

I know this one is unclaimed at the moment:
CHECK   drivers/iio/magnetometer/ak8974.c
drivers/iio/magnetometer/ak8974.c:403:16: warning: cast to restricted
__le16
drivers/iio/magnetometer/ak8974.c:480:24: warning: cast to restricted
__le16

alisons






> 
> -- 
> :wq
> ^X^Cy^K^X^C^C^C^C
> --
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison
  2016-10-01 16:49     ` Alison Schofield
@ 2016-10-01 17:27       ` Ico Doornekamp
  0 siblings, 0 replies; 5+ messages in thread
From: Ico Doornekamp @ 2016-10-01 17:27 UTC (permalink / raw)
  To: Alison Schofield; +Cc: Jonathan Cameron, linux-iio

* On 2016-10-01 18:49:33 +0200, Alison Schofield wrote:
 
> Flattering the maintainer, always good and so true, so true :)

Knowing when to flatter whom is often more imporant then cranking out
sweet code :)

> Here's something found by sparse for little penguin.
> See the Outreachy tasks page.  https://kernelnewbies.org/IIO_tasks
> 
> You'll see I leveraged your IIO_CHAN* patch for the first coding task.
> We have a second coding task for sparse endianness patches.  There are
> some remaining.  If you tell me you're grabbing one, I'll put it on
> our claimed page so an applicant doesn't start on it. 
> 
> I know this one is unclaimed at the moment:
> CHECK   drivers/iio/magnetometer/ak8974.c
> drivers/iio/magnetometer/ak8974.c:403:16: warning: cast to restricted
> __le16
> drivers/iio/magnetometer/ak8974.c:480:24: warning: cast to restricted
> __le16

Ah, great, I missed those. Patch following. Thanks,

-- 
:wq
^X^Cy^K^X^C^C^C^C

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-01 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-28 13:41 [PATCH] io: adc: ad7606_core: fix signed/unsigned number comparison Ico Doornekamp
2016-10-01 16:09 ` Jonathan Cameron
2016-10-01 16:17   ` Ico Doornekamp
2016-10-01 16:49     ` Alison Schofield
2016-10-01 17:27       ` Ico Doornekamp

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).