All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] include/linux/byteorder/generic.h: fix signed/unsigned warnings
@ 2019-10-21  9:27 Anatol Belski
  2019-10-21  9:38 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Anatol Belski @ 2019-10-21  9:27 UTC (permalink / raw)
  To: linux-kernel, Mika Westerberg, Michael Jamet, Andy Shevchenko,
	David S . Miller
  Cc: trivial

From: Anatol Belski <anbelski@microsoft.com>

This fixes the warnings like below, thrown by GCC

warning: comparison of integer expressions of different signedness: \
‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  195 |  for (i = 0; i < len; i++)
      |                ^

Signed-off-by: Anatol Belski <anbelski@microsoft.com>
---
 include/linux/byteorder/generic.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index 4b13e0a3e15b..c9a4c96c9943 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -190,7 +190,7 @@ static inline void be64_add_cpu(__be64 *var, u64 val)
 
 static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
 {
-	int i;
+	size_t i;
 
 	for (i = 0; i < len; i++)
 		dst[i] = cpu_to_be32(src[i]);
@@ -198,7 +198,7 @@ static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
 
 static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
 {
-	int i;
+	size_t i;
 
 	for (i = 0; i < len; i++)
 		dst[i] = be32_to_cpu(src[i]);
-- 
2.20.1


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

* Re: [PATCH v2] include/linux/byteorder/generic.h: fix signed/unsigned warnings
  2019-10-21  9:27 [PATCH v2] include/linux/byteorder/generic.h: fix signed/unsigned warnings Anatol Belski
@ 2019-10-21  9:38 ` Andy Shevchenko
  2019-10-21 10:08   ` Anatol Belski
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2019-10-21  9:38 UTC (permalink / raw)
  To: Anatol Belski
  Cc: linux-kernel, Mika Westerberg, Michael Jamet, David S . Miller,
	trivial, Masahiro Yamada, Nick Desaulniers

On Mon, Oct 21, 2019 at 09:27:37AM +0000, Anatol Belski wrote:
> From: Anatol Belski <anbelski@microsoft.com>
> 
> This fixes the warnings like below, thrown by GCC
> 
> warning: comparison of integer expressions of different signedness: \
> ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
>   195 |  for (i = 0; i < len; i++)
>       |                ^

We have explicitly disabled this warnings in the kernel Makefile.
How did you achieve this? (yes, I know the possible answer, perhaps
this has to be mentioned as well)

Now I see some inconsistency with this warning between GCC and Clang. Add
related people to the discussion.

> Signed-off-by: Anatol Belski <anbelski@microsoft.com>
> ---

Changelog is missing.
(No need to resend just for this, it's for your future contributions)

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] include/linux/byteorder/generic.h: fix signed/unsigned warnings
  2019-10-21  9:38 ` Andy Shevchenko
@ 2019-10-21 10:08   ` Anatol Belski
  0 siblings, 0 replies; 3+ messages in thread
From: Anatol Belski @ 2019-10-21 10:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Mika Westerberg, Michael Jamet, David S . Miller,
	trivial, Masahiro Yamada, Nick Desaulniers

On Mon, 2019-10-21 at 12:38 +0300, Andy Shevchenko wrote:
> We have explicitly disabled this warnings in the kernel Makefile.
> How did you achieve this? (yes, I know the possible answer, perhaps
> this has to be mentioned as well)
Added W=12 to the make command, used GCC 9.1.0. There are quite some
warnings of this art yet, so this is just a first shot.

Additional issue i'd see in this particular case also, that iterating
through an array should use some unsigned to ensure there's no signed
overflow. But otherwise, it's better to fix similar cases to reduce the
noise.

> > Signed-off-by: Anatol Belski <anbelski@microsoft.com>
> > ---
> 
> Changelog is missing.
> (No need to resend just for this, it's for your future contributions)
> 
Thanks for pointing to this. I also probably should have added a Cc:.
Will go through the submitting patches document more carefully.

Thanks!

anatol


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

end of thread, other threads:[~2019-10-21 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  9:27 [PATCH v2] include/linux/byteorder/generic.h: fix signed/unsigned warnings Anatol Belski
2019-10-21  9:38 ` Andy Shevchenko
2019-10-21 10:08   ` Anatol Belski

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.