From: Emil Velikov Date: Thu, 3 Oct 2024 16:02:45 +0000 (+0100) Subject: libkmod: silence autological compare warning X-Git-Tag: v34~256 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98f38c5d80ed639f2c4b7f286cade5fa6a68cdec;p=thirdparty%2Fkmod.git libkmod: silence autological compare warning 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 Link: https://github.com/kmod-project/kmod/pull/172 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index d1e5a82c..e79fbf63 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -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);