]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: silence autological compare warning
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 9 Oct 2024 04:20:32 +0000 (23:20 -0500)
Clang will detect that the enum cannot be zero, thus triggering a
warning. Since this is an external (public API) function, the end-user
can provide any input so we want to keep the check.

Note: include the pragmas in a if defined(__clang__) guard, otherwise
we'll trigger -Wunknown_pragma which will become an error in CI and
developer builds.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/172
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod.c

index d1e5a82cf47bde21c8d652de54b8b8ac9bb2be5d..e79fbf630afc7fa24b63a5f852e3c90b9921f70d 100644 (file)
@@ -802,8 +802,15 @@ KMOD_EXPORT int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type, int
        if (ctx == NULL)
                return -ENOSYS;
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-unsigned-enum-zero-compare"
+#endif
        if (type < 0 || type >= _KMOD_INDEX_MODULES_SIZE)
                return -ENOENT;
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
 
        if (ctx->indexes[type] != NULL) {
                DBG(ctx, "use mmapped index '%s'\n", index_files[type].fn);