From: Eduardo Augusto <[email protected]> nvme_directive_receive() rejects unsupported directive types and operations before reaching the switch statement.
Remove the redundant switch blocks and keep the valid identify return parameters path directly. Signed-off-by: Eduardo Augusto <[email protected]> --- hw/nvme/ctrl.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 815f39173c..175daf8a5d 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7554,25 +7554,13 @@ static uint16_t nvme_directive_receive(NvmeCtrl *n, NvmeRequest *req) return NVME_INVALID_FIELD | NVME_DNR; } - switch (dtype) { - case NVME_DIRECTIVE_IDENTIFY: - switch (doper) { - case NVME_DIRECTIVE_RETURN_PARAMS: - if (ns->endgrp && ns->endgrp->fdp.enabled) { - id.supported |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; - id.enabled |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; - id.persistent |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; - } - - return nvme_c2h(n, (uint8_t *)&id, trans_len, req); - - default: - return NVME_INVALID_FIELD | NVME_DNR; - } - - default: - return NVME_INVALID_FIELD; + if (ns->endgrp && ns->endgrp->fdp.enabled) { + id.supported |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; + id.enabled |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; + id.persistent |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; } + + return nvme_c2h(n, (uint8_t *)&id, trans_len, req); } static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req) -- 2.34.1
