linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] nvmet: fix comparison of a u16 with -1
@ 2018-12-14 18:31 Colin King
  2018-12-16 16:26 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-12-14 18:31 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, linux-nvme
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the u16 req->error_loc is being compared to -1 which
will always be false.  Fix this by casting -1 to u16 to fix this.

Detected by clang:
  warning: result of comparison of constant -1 with expression of
  type 'u16' (aka 'unsigned short') is always false
  [-Wtautological-constant-out-of-range-compare]

Fixes: 76574f37bf4c ("nvmet: add interface to update error-log page")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/nvme/target/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index cc81d0231587..b9c219c931eb 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -663,7 +663,7 @@ static void nvmet_set_error(struct nvmet_req *req, u16 status)
 
 	req->rsp->status = cpu_to_le16(status << 1);
 
-	if (!ctrl || req->error_loc == -1)
+	if (!ctrl || req->error_loc == (u16)-1)
 		return;
 
 	spin_lock_irqsave(&ctrl->error_lock, flags);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] nvmet: fix comparison of a u16 with -1
  2018-12-14 18:31 [PATCH][next] nvmet: fix comparison of a u16 with -1 Colin King
@ 2018-12-16 16:26 ` Christoph Hellwig
  2018-12-17 18:04   ` Chaitanya Kulkarni
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2018-12-16 16:26 UTC (permalink / raw)
  To: Colin King
  Cc: Christoph Hellwig, Sagi Grimberg, linux-nvme, kernel-janitors,
	linux-kernel, chaitanya.kulkarni

Thanks, applied.

Maybe it might be worth adding a NVME_NO_ERR_LOC defintion to clean
this up a bit more.  Chaitanya, can you look into that?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] nvmet: fix comparison of a u16 with -1
  2018-12-16 16:26 ` Christoph Hellwig
@ 2018-12-17 18:04   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2018-12-17 18:04 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, linux-nvme, kernel-janitors, linux-kernel


Will send out a path.

On 12/16/18, 8:26 AM, "Christoph Hellwig" <hch@lst.de> wrote:

    Thanks, applied.
    
    Maybe it might be worth adding a NVME_NO_ERR_LOC defintion to clean
    this up a bit more.  Chaitanya, can you look into that?
    


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-17 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 18:31 [PATCH][next] nvmet: fix comparison of a u16 with -1 Colin King
2018-12-16 16:26 ` Christoph Hellwig
2018-12-17 18:04   ` Chaitanya Kulkarni

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