Skip to contentSkip to conversation

nvme-core: fix unsigned comparison warning in nvme_wait_freeze_timeout

PATCH Superseded Maurizio Lombardi 3 participants 3 messages May 21 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 condition to !timeout.

blk_mq_freeze_queue_wait_timeout() is a wrapper for wait_event_timeout() and the latter returns 0 or a positive value.

Fixes 23b6d2cbf75f ("nvme: remove redundant timeout argument from nvme_wait_freeze_timeout")
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index 72c50d5e938d..26a65404279f 100644
@@ -5254,7 +5254,7 @@ int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
 	list_for_each_entry_srcu(ns, &ctrl->namespaces, list,
 				 srcu_read_lock_held(&ctrl->srcu)) {
 		timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout);
-		if (timeout <= 0)
+		if (!timeout)
 			break;
 	}
 	srcu_read_unlock(&ctrl->srcu, srcu_idx);
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 8 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 condition to !timeout.

blk_mq_freeze_queue_wait_timeout() is a wrapper for wait_event_timeout() and the latter returns 0 or a positive value.

It looks like it returns a signed value, but the conditions for which it may be < 0 currently don't apply since we're using the uninterruptable state. So looks fine, but I might feel more comfortable if we just used a signed type to match the API's return type.

#2 lore raw
Quoted 7 lines · Keith Busch
Quoted 6 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 condition to !timeout.

Quoted 7 lines
Quoted 2 lines

blk_mq_freeze_queue_wait_timeout() is a wrapper for wait_event_timeout() and the latter returns 0 or a positive value.

It looks like it returns a signed value, but the conditions for which it may be < 0 currently don't apply since we're using the uninterruptable state. So looks fine, but I might feel more comfortable if we just used a signed type to match the API's return type.

No problem, let me submit a V2

Maurizio