Re: [PATCH] byteorder: fix warning due to type mismatch in be32 array code
From: Geert Uytterhoeven
Date: Fri Nov 15 2019 - 05:51:25 EST
Hi Ben,
CC Arnd.
On Mon, Nov 4, 2019 at 7:25 PM Ben Dooks (Codethink)
<ben.dooks@xxxxxxxxxxxxxxx> wrote:
> The loop should use a "size_t" as the len parameter is a size_t which
> should silence the following warning:
>
> ./include/linux/byteorder/generic.h:195:16: warning: comparison of integer expressions of different signedness: âintâ and âsize_tâ {aka âunsigned intâ} [-Wsign-compare]
> ./include/linux/byteorder/generic.h:203:16: warning: comparison of integer expressions of different signedness: âintâ and âsize_tâ {aka âunsigned intâ} [-Wsign-compare]
>
> Signed-off-by: Ben Dooks (Codethink) <ben.dooks@xxxxxxxxxxxxxxx>
Thanks for your patch!
> --- 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]);
Alternatively, you can follow the approach a few lines above:
while (len--)
*dst++ = cpu_to_be32(*src++);
Regardless:
Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds