This is a follow up patch for commit c70adc3cf6bf ("ndctl, filter: refactor
util_<obj>_filter() to support multiple space-seperated arguments")
refactored util_<obj>_filter() to support multiple space-seperated arguments.
But, when the keyword "all" is included in space-seperated arguments,
it will be treaded as <object>'s name. This patch fixes it.
Signed-off-by: QI Fuli <qi.fuli(a)jp.fujitsu.com>
---
util/filter.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/util/filter.c b/util/filter.c
index 0d3cc02..9081a6d 100644
--- a/util/filter.c
+++ b/util/filter.c
@@ -40,6 +40,9 @@ struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char
*__ident)
for (name = strtok_r(ident, " ", &save); name;
name = strtok_r(NULL, " ", &save)) {
+ if (strcmp(ident, "all") == 0)
+ break;
+
bus_id = strtoul(ident, &end, 0);
if (end == ident || end[0])
bus_id = ULONG_MAX;
@@ -78,6 +81,9 @@ struct ndctl_region *util_region_filter(struct ndctl_region *region,
for (name = strtok_r(ident, " ", &save); name;
name = strtok_r(NULL, " ", &save)) {
+ if (strcmp(ident, "all") == 0)
+ break;
+
region_id = strtoul(ident, &end, 0);
if (end == ident || end[0])
region_id = ULONG_MAX;
@@ -115,6 +121,9 @@ struct ndctl_namespace *util_namespace_filter(struct ndctl_namespace
*ndns,
for (name = strtok_r(ident, " ", &save); name;
name = strtok_r(NULL, " ", &save)) {
+ if (strcmp(ident, "all") == 0)
+ break;
+
if (strcmp(name, ndctl_namespace_get_devname(ndns)) == 0)
break;
@@ -146,6 +155,9 @@ struct ndctl_dimm *util_dimm_filter(struct ndctl_dimm *dimm,
for (name = strtok_r(ident, " ", &save); name;
name = strtok_r(NULL, " ", &save)) {
+ if (strcmp(ident, "all") == 0)
+ break;
+
dimm_id = strtoul(ident, &end, 0);
if (end == ident || end[0])
dimm_id = ULONG_MAX;
--
2.17.0.140.g0b0cc9f86