From 526be991f8be6ac31a46c92b4e03110728ec2519 Mon Sep 17 00:00:00 2001 From: Martin George Date: Fri, 15 Nov 2024 16:34:05 +0530 Subject: [PATCH] fabrics: update return values for dim The nvme dim command returns a zero even for failure scenarios as shown below: nvme0 DIM register command error. Status:0xffffffff - Operation not supported echo $? 0 Fix this by ensuring appropriate values are returned for success and failure scenarios. And while at it, remove a couple of superfluous braces too here. Signed-off-by: Martin George --- fabrics.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fabrics.c b/fabrics.c index eb90d98cf..4d250e99c 100644 --- a/fabrics.c +++ b/fabrics.c @@ -1430,7 +1430,7 @@ int nvmf_config(const char *desc, int argc, char **argv) return 0; } -static void dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name) +static int dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name) { static const char * const task[] = { [NVMF_DIM_TAS_REGISTER] = "register", @@ -1451,6 +1451,8 @@ static void dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name fprintf(stderr, "%s DIM %s command error. Result:0x%04x, Status:0x%04x - %s\n", name, t, result, status, nvme_status_to_string(status, false)); } + + return nvme_status_to_errno(status, true); } int nvmf_dim(const char *desc, int argc, char **argv) @@ -1530,9 +1532,8 @@ int nvmf_dim(const char *desc, int argc, char **argv) nvme_for_each_subsystem(h, s) { if (strcmp(nvme_subsystem_get_nqn(s), p)) continue; - nvme_subsystem_for_each_ctrl(s, c) { - dim_operation(c, tas, p); - } + nvme_subsystem_for_each_ctrl(s, c) + ret = dim_operation(c, tas, p); } } } @@ -1551,9 +1552,9 @@ int nvmf_dim(const char *desc, int argc, char **argv) p, nvme_strerror(errno)); return -errno; } - dim_operation(c, tas, p); + ret = dim_operation(c, tas, p); } } - return 0; + return ret; }