linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yskelg@gmail.com
To: Lucas De Marchi <lucas.de.marchi@gmail.com>,
	Michal Suchanek <msuchanek@suse.de>
Cc: Austin Kim <austindh.kim@gmail.com>,
	shjy180909@gmail.com, linux-modules@vger.kernel.org,
	Yunseong Kim <yskelg@gmail.com>
Subject: [PATCH] libkmod: fix result of comparison of unsigned enum in kmod_dump_index()
Date: Sat, 22 Jun 2024 15:13:22 +0900	[thread overview]
Message-ID: <20240622061321.9005-2-yskelg@gmail.com> (raw)

From: Yunseong Kim <yskelg@gmail.com>

This patch fix compiler warning in kmod_dump_index()

libkmod/libkmod.c:989:11: warning: result of comparison of unsigned enum
expression < 0 is always false [-Wtautological-unsigned-enum-zero-compare]
  989 |         if (type < 0 || type >= _KMOD_INDEX_MODULES_SIZE)
      |             ~~~~ ^ ~

My compiler version.

$ clang -v
clang version 18.1.6 (Fedora 18.1.6-3.fc40)

Signed-off-by: Yunseong Kim <yskelg@gmail.com>
---
 libkmod/libkmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 213b424..fcb619b 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -986,7 +986,7 @@ KMOD_EXPORT int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type,
 	if (ctx == NULL)
 		return -ENOSYS;
 
-	if (type < 0 || type >= _KMOD_INDEX_MODULES_SIZE)
+	if (type >= KMOD_INDEX_MODULES_DEP || type >= _KMOD_INDEX_MODULES_SIZE)
 		return -ENOENT;
 
 	if (ctx->indexes[type] != NULL) {
-- 
2.45.2


             reply	other threads:[~2024-06-22  6:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-22  6:13 yskelg [this message]
2024-06-24  7:49 ` [PATCH] libkmod: fix result of comparison of unsigned enum in kmod_dump_index() Michal Suchánek
2024-06-24 17:40   ` Yunseong Kim
2024-06-24 18:46     ` Michal Suchánek
2024-06-28 22:08       ` Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240622061321.9005-2-yskelg@gmail.com \
    --to=yskelg@gmail.com \
    --cc=austindh.kim@gmail.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --cc=msuchanek@suse.de \
    --cc=shjy180909@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).