nvme-core: fix unsigned comparison warning in nvme_wait_freeze_timeout
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.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -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
Keith Busch
maintainerQuoted 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 forwait_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.
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 forwait_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