2020-07-21 21:33:31

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v4 16/17] crypto: sun8i-ce: fix comparison of integer expressions of different signedness

On Tue, 2020-07-21 at 19:06 +0000, Corentin Labbe wrote:
> This patch fixes the warning:
> warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]

I think these do not really need conversion.
Are these useful compiler warnings ?

> Signed-off-by: Corentin Labbe <[email protected]>
> ---
> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> index 3901e3401c6b..7b2a142c9b8d 100644
> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> @@ -566,7 +566,7 @@ static struct sun8i_ce_alg_template ce_algs[] = {
> static int sun8i_ce_dbgfs_read(struct seq_file *seq, void *v)
> {
> struct sun8i_ce_dev *ce = seq->private;
> - int i;
> + unsigned int i;
>
> for (i = 0; i < MAXFLOW; i++)
> seq_printf(seq, "Channel %d: nreq %lu\n", i, ce->chanlist[i].stat_req);
> @@ -778,7 +778,8 @@ static int sun8i_ce_get_clks(struct sun8i_ce_dev *ce)
>
> static int sun8i_ce_register_algs(struct sun8i_ce_dev *ce)
> {
> - int ce_method, err, id, i;
> + int ce_method, err, id;
> + unsigned int i;
>
> for (i = 0; i < ARRAY_SIZE(ce_algs); i++) {
> ce_algs[i].ce = ce;
> @@ -858,7 +859,7 @@ static int sun8i_ce_register_algs(struct sun8i_ce_dev *ce)
>
> static void sun8i_ce_unregister_algs(struct sun8i_ce_dev *ce)
> {
> - int i;
> + unsigned int i;
>
> for (i = 0; i < ARRAY_SIZE(ce_algs); i++) {
> if (!ce_algs[i].ce)


2020-07-22 04:58:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH] Makefile.extrawarn: Move sign-compare from W=2 to W=3

This -Wsign-compare compiler warning can be very noisy
and most of the suggested conversions are unnecessary.

Make the warning W=3 so it's described under the
"can most likely be ignored" block.

Signed-off-by: Joe Perches <[email protected]>
---
On Tue, 2020-07-21 at 14:32 -0700, Joe Perches wrote:
> On Tue, 2020-07-21 at 19:06 +0000, Corentin Labbe wrote:
> > This patch fixes the warning:
> > warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
>
> I think these do not really need conversion.
> Are these useful compiler warnings ?

Perhaps move the warning from W=2 to W=3 so
it's described as "can most likely be ignored"

scripts/Makefile.extrawarn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 62c275685b75..95e4cdb94fe9 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -66,7 +66,6 @@ KBUILD_CFLAGS += -Wnested-externs
KBUILD_CFLAGS += -Wshadow
KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
KBUILD_CFLAGS += -Wmissing-field-initializers
-KBUILD_CFLAGS += -Wsign-compare
KBUILD_CFLAGS += -Wtype-limits
KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
@@ -87,6 +86,7 @@ KBUILD_CFLAGS += -Wpacked
KBUILD_CFLAGS += -Wpadded
KBUILD_CFLAGS += -Wpointer-arith
KBUILD_CFLAGS += -Wredundant-decls
+KBUILD_CFLAGS += -Wsign-compare
KBUILD_CFLAGS += -Wswitch-default
KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)



2020-07-22 06:24:21

by Corentin LABBE

[permalink] [raw]
Subject: Re: [PATCH v4 16/17] crypto: sun8i-ce: fix comparison of integer expressions of different signedness

On Tue, Jul 21, 2020 at 02:32:15PM -0700, Joe Perches wrote:
> On Tue, 2020-07-21 at 19:06 +0000, Corentin Labbe wrote:
> > This patch fixes the warning:
> > warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
>
> I think these do not really need conversion.
> Are these useful compiler warnings ?
>

Since ARRAY_SIZE(ce_algs) will never greater than MAX(int), the conversion does not fix a bug.
But at least the code is more proper.
So I think the patch is still usefull.

2020-07-27 04:56:54

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] Makefile.extrawarn: Move sign-compare from W=2 to W=3

On Wed, Jul 22, 2020 at 1:57 PM Joe Perches <[email protected]> wrote:
>
> This -Wsign-compare compiler warning can be very noisy
> and most of the suggested conversions are unnecessary.
>
> Make the warning W=3 so it's described under the
> "can most likely be ignored" block.
>
> Signed-off-by: Joe Perches <[email protected]>
> ---

Applied to linux-kbuild. Thanks.



> On Tue, 2020-07-21 at 14:32 -0700, Joe Perches wrote:
> > On Tue, 2020-07-21 at 19:06 +0000, Corentin Labbe wrote:
> > > This patch fixes the warning:
> > > warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
> >
> > I think these do not really need conversion.
> > Are these useful compiler warnings ?
>
> Perhaps move the warning from W=2 to W=3 so
> it's described as "can most likely be ignored"
>
> scripts/Makefile.extrawarn | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 62c275685b75..95e4cdb94fe9 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -66,7 +66,6 @@ KBUILD_CFLAGS += -Wnested-externs
> KBUILD_CFLAGS += -Wshadow
> KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
> KBUILD_CFLAGS += -Wmissing-field-initializers
> -KBUILD_CFLAGS += -Wsign-compare
> KBUILD_CFLAGS += -Wtype-limits
> KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
> KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
> @@ -87,6 +86,7 @@ KBUILD_CFLAGS += -Wpacked
> KBUILD_CFLAGS += -Wpadded
> KBUILD_CFLAGS += -Wpointer-arith
> KBUILD_CFLAGS += -Wredundant-decls
> +KBUILD_CFLAGS += -Wsign-compare
> KBUILD_CFLAGS += -Wswitch-default
> KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
>
>
>


--
Best Regards
Masahiro Yamada