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