Skip to content

Commit 98b34e4

Browse files
martin-gpyigaw
authored andcommitted
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 <[email protected]>
1 parent a3d887e commit 98b34e4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fabrics.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ int nvmf_config(const char *desc, int argc, char **argv)
14301430
return 0;
14311431
}
14321432

1433-
static void dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name)
1433+
static int dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name)
14341434
{
14351435
static const char * const task[] = {
14361436
[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
14511451
fprintf(stderr, "%s DIM %s command error. Result:0x%04x, Status:0x%04x - %s\n",
14521452
name, t, result, status, nvme_status_to_string(status, false));
14531453
}
1454+
1455+
return nvme_status_to_errno(status, true);
14541456
}
14551457

14561458
int nvmf_dim(const char *desc, int argc, char **argv)
@@ -1530,9 +1532,8 @@ int nvmf_dim(const char *desc, int argc, char **argv)
15301532
nvme_for_each_subsystem(h, s) {
15311533
if (strcmp(nvme_subsystem_get_nqn(s), p))
15321534
continue;
1533-
nvme_subsystem_for_each_ctrl(s, c) {
1534-
dim_operation(c, tas, p);
1535-
}
1535+
nvme_subsystem_for_each_ctrl(s, c)
1536+
ret = dim_operation(c, tas, p);
15361537
}
15371538
}
15381539
}
@@ -1551,9 +1552,9 @@ int nvmf_dim(const char *desc, int argc, char **argv)
15511552
p, nvme_strerror(errno));
15521553
return -errno;
15531554
}
1554-
dim_operation(c, tas, p);
1555+
ret = dim_operation(c, tas, p);
15551556
}
15561557
}
15571558

1558-
return 0;
1559+
return ret;
15591560
}

0 commit comments

Comments
 (0)