linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kmod: build: cure compiler warnings showing up externally
@ 2018-06-16  6:45 Jan Engelhardt
  2018-06-18 16:49 ` Lucas De Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Engelhardt @ 2018-06-16  6:45 UTC (permalink / raw)
  To: lucas.demarchi; +Cc: jengelh, linux-modules

When building a C source file with gcc-7 -Wshift-overflow=2, this warning
springs up:

libkmod.h: warning: result of "1 << 31" requires 33 bits to
represent, but "int" only has 32 bits [-Wshift-overflow=]

Change the two _KMOD_* identifiers to fit into 32 bits.
---
 libkmod/libkmod.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index f9e33c6..352627e 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -72,7 +72,7 @@ enum kmod_index {
 	KMOD_INDEX_MODULES_SYMBOL,
 	KMOD_INDEX_MODULES_BUILTIN,
 	/* Padding to make sure enum is not mapped to char */
-	_KMOD_INDEX_PAD = (1 << 31),
+	_KMOD_INDEX_PAD = 1U << 31,
 };
 int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type, int fd);
 
@@ -211,7 +211,7 @@ enum kmod_module_initstate {
 	KMOD_MODULE_COMING,
 	KMOD_MODULE_GOING,
 	/* Padding to make sure enum is not mapped to char */
-	_KMOD_MODULE_PAD = (1 << 31),
+	_KMOD_MODULE_PAD = 1U << 31,
 };
 const char *kmod_module_initstate_str(enum kmod_module_initstate state);
 int kmod_module_get_initstate(const struct kmod_module *mod);
-- 
2.17.1


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

* Re: [PATCH] kmod: build: cure compiler warnings showing up externally
  2018-06-16  6:45 [PATCH] kmod: build: cure compiler warnings showing up externally Jan Engelhardt
@ 2018-06-18 16:49 ` Lucas De Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2018-06-18 16:49 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Lucas De Marchi, Jan Engelhardt, linux-modules

On Fri, Jun 15, 2018 at 11:53 PM Jan Engelhardt <jengelh@inai.de> wrote:
>
> When building a C source file with gcc-7 -Wshift-overflow=2, this warning
> springs up:
>
> libkmod.h: warning: result of "1 << 31" requires 33 bits to
> represent, but "int" only has 32 bits [-Wshift-overflow=]
>
> Change the two _KMOD_* identifiers to fit into 32 bits.
> ---
>  libkmod/libkmod.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Lucas De Marchi

>
> diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
> index f9e33c6..352627e 100644
> --- a/libkmod/libkmod.h
> +++ b/libkmod/libkmod.h
> @@ -72,7 +72,7 @@ enum kmod_index {
>         KMOD_INDEX_MODULES_SYMBOL,
>         KMOD_INDEX_MODULES_BUILTIN,
>         /* Padding to make sure enum is not mapped to char */
> -       _KMOD_INDEX_PAD = (1 << 31),
> +       _KMOD_INDEX_PAD = 1U << 31,
>  };
>  int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type, int fd);
>
> @@ -211,7 +211,7 @@ enum kmod_module_initstate {
>         KMOD_MODULE_COMING,
>         KMOD_MODULE_GOING,
>         /* Padding to make sure enum is not mapped to char */
> -       _KMOD_MODULE_PAD = (1 << 31),
> +       _KMOD_MODULE_PAD = 1U << 31,
>  };
>  const char *kmod_module_initstate_str(enum kmod_module_initstate state);
>  int kmod_module_get_initstate(const struct kmod_module *mod);
> --
> 2.17.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-modules" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Lucas De Marchi

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

end of thread, other threads:[~2018-06-18 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-16  6:45 [PATCH] kmod: build: cure compiler warnings showing up externally Jan Engelhardt
2018-06-18 16:49 ` Lucas De Marchi

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