]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
kmod: build: cure compiler warnings showing up externally
authorJan Engelhardt <jengelh@inai.de>
Sat, 16 Jun 2018 06:45:20 +0000 (08:45 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 18 Jun 2018 16:46:56 +0000 (09:46 -0700)
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

index f9e33c6cde90d713abb071c334100472c445ab18..352627e5d018cff7db77cd8b0a862906c97d89f3 100644 (file)
@@ -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);