Commit 7860569a authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Christoph Hellwig

nvmet: remove local variable

In function errno_to_nvme_status() we store the value of the NVMe
status into the local variable and don't do anything useful with that
but just return.

Remove the local variable and return the value directly from switch.
This also removed extra break statements.
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 8bb6cb9b
...@@ -43,43 +43,34 @@ DECLARE_RWSEM(nvmet_ana_sem); ...@@ -43,43 +43,34 @@ DECLARE_RWSEM(nvmet_ana_sem);
inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno) inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno)
{ {
u16 status;
switch (errno) { switch (errno) {
case 0: case 0:
status = NVME_SC_SUCCESS; return NVME_SC_SUCCESS;
break;
case -ENOSPC: case -ENOSPC:
req->error_loc = offsetof(struct nvme_rw_command, length); req->error_loc = offsetof(struct nvme_rw_command, length);
status = NVME_SC_CAP_EXCEEDED | NVME_SC_DNR; return NVME_SC_CAP_EXCEEDED | NVME_SC_DNR;
break;
case -EREMOTEIO: case -EREMOTEIO:
req->error_loc = offsetof(struct nvme_rw_command, slba); req->error_loc = offsetof(struct nvme_rw_command, slba);
status = NVME_SC_LBA_RANGE | NVME_SC_DNR; return NVME_SC_LBA_RANGE | NVME_SC_DNR;
break;
case -EOPNOTSUPP: case -EOPNOTSUPP:
req->error_loc = offsetof(struct nvme_common_command, opcode); req->error_loc = offsetof(struct nvme_common_command, opcode);
switch (req->cmd->common.opcode) { switch (req->cmd->common.opcode) {
case nvme_cmd_dsm: case nvme_cmd_dsm:
case nvme_cmd_write_zeroes: case nvme_cmd_write_zeroes:
status = NVME_SC_ONCS_NOT_SUPPORTED | NVME_SC_DNR; return NVME_SC_ONCS_NOT_SUPPORTED | NVME_SC_DNR;
break;
default: default:
status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
break; break;
case -ENODATA: case -ENODATA:
req->error_loc = offsetof(struct nvme_rw_command, nsid); req->error_loc = offsetof(struct nvme_rw_command, nsid);
status = NVME_SC_ACCESS_DENIED; return NVME_SC_ACCESS_DENIED;
break;
case -EIO: case -EIO:
fallthrough; fallthrough;
default: default:
req->error_loc = offsetof(struct nvme_common_command, opcode); req->error_loc = offsetof(struct nvme_common_command, opcode);
status = NVME_SC_INTERNAL | NVME_SC_DNR; return NVME_SC_INTERNAL | NVME_SC_DNR;
} }
return status;
} }
u16 nvmet_report_invalid_opcode(struct nvmet_req *req) u16 nvmet_report_invalid_opcode(struct nvmet_req *req)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment