Skip to contentSkip to conversation

nvmet: fix comparison of a u16 with -1

PATCH Applied Colin King 3 participants 4 messages Dec 14, 2018 – Dec 18, 2018

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 nvmet: fix comparison of a u16 with -1

From: Colin Ian King <[email protected]>

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")
---
 drivers/nvme/target/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
index cc81d0231587..b9c219c931eb 100644
@@ -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);
Signature · 1 line
2.19.1
maintainer Applied
#1 lore raw

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?

#2 lore raw

DQpXaWxsIHNlbmQgb3V0IGEgcGF0aC4NCg0K77u/T24gMTIvMTYvMTgsIDg6MjYgQU0sICJDaHJp c3RvcGggSGVsbHdpZyIgPGhjaEBsc3QuZGU+IHdyb3RlOg0KDQogICAgVGhhbmtzLCBhcHBsaWVk Lg0KICAgIA0KICAgIE1heWJlIGl0IG1pZ2h0IGJlIHdvcnRoIGFkZGluZyBhIE5WTUVfTk9fRVJS X0xPQyBkZWZpbnRpb24gdG8gY2xlYW4NCiAgICB0aGlzIHVwIGEgYml0IG1vcmUuICBDaGFpdGFu eWEsIGNhbiB5b3UgbG9vayBpbnRvIHRoYXQ/DQogICAgDQoNCg=

#3 lore raw

PATCH 1/1 nvmet: fix comparison of a u16 with -1

In reply to Christoph Hellwig

Sent out the cleanup patch.

?On 12/16/18, 8:26 AM, "Christoph Hellwig" <[email protected]> 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?