Skip to contentSkip to conversation

nvme-core: fix unsigned comparison warning in nvme_wait_freeze_timeout

PATCH Applied Maurizio Lombardi 3 participants 3 messages May 21 – May 27 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme-core: fix unsigned comparison warning in nvme_wait_freeze_timeout

The timeout variable in nvme_wait_freeze_timeout() is an unsigned type. Checking if it is <= 0 triggers a compiler warning because an unsigned variable can never be negative.

Fix this warning by changing the type to long.

Fixes 23b6d2cbf75f ("nvme: remove redundant timeout argument from nvme_wait_freeze_timeout")

---

v2: keep the <= comparison, change the type from unsigned to signed long

 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index 72c50d5e938d..554649ffe430 100644
@@ -5246,7 +5246,7 @@ EXPORT_SYMBOL_GPL(nvme_unfreeze);
 
 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
 {
-	unsigned long timeout = ctrl->io_timeout;
+	long timeout = ctrl->io_timeout;
 	struct nvme_ns *ns;
 	int srcu_idx;
 
Signature · 1 line
2.54.0
#1 lore raw
Quoted 23 lines · Maurizio Lombardi

The timeout variable in nvme_wait_freeze_timeout() is an unsigned type. Checking if it is <= 0 triggers a compiler warning because an unsigned variable can never be negative.

Fix this warning by changing the type to long.

Fixes 23b6d2cbf75f ("nvme: remove redundant timeout argument from nvme_wait_freeze_timeout")

---

v2: keep the <= comparison, change the type from unsigned to signed long

 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +0 -0
index 72c50d5e938d..554649ffe430 100644

drivers/nvme/host/core.c EXPORT_SYMBOL_GPL(nvme_unfreeze); · line 5252

Quoted 8 lines
drivers/nvme/host/core.c +1 -1
@@ -5246,7 +5246,7 @@ EXPORT_SYMBOL_GPL(nvme_unfreeze);
 
 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
 {
-	unsigned long timeout = ctrl->io_timeout;
+	long timeout = ctrl->io_timeout;
 	struct nvme_ns *ns;
 	int srcu_idx;
 

Keith?

Does this one look better to you?

Maurizio

maintainer Applied
#2 lore raw
In reply to Maurizio Lombardi
Quoted 5 lines · Maurizio Lombardi

The timeout variable in nvme_wait_freeze_timeout() is an unsigned type. Checking if it is <= 0 triggers a compiler warning because an unsigned variable can never be negative.

Fix this warning by changing the type to long.

Thanks, applied to nvme-7.2.