Skip to contentSkip to conversation

ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()

PATCH Superseded QI Fuli 2 participants 3 messages Apr 25, 2018 – Apr 26, 2018 libnvdimm: non-volatile memory device

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

QI Fuli

author
#0 lore raw

PATCH 1/1 ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()

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.

---
 util/filter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
util/filter.c +12 -0
index 0d3cc02..9081a6d 100644
@@ -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;
Signature · 7 lines
2.17.0.140.g0b0cc9f86


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 16 lines · QI Fuli

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.

---
 util/filter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
util/filter.c +0 -0
index 0d3cc02..9081a6d 100644

util/filter.c struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident) · line 45

Quoted 6 lines
util/filter.c +3 -0
@@ -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;
+

Let's also remove the strcmp(__ident, "all") at the top of each of these routines to keep the check for "all" centralized.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#2 lore raw
Quoted 29 lines

-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Wednesday, April 25, 2018 11:11 PM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH] ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()

Quoted 19 lines · QI Fuli

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.

---
 util/filter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
util/filter.c index 0d3cc02..9081a6d renamed from util/filter.c +0 -0

100644

util/filter.c +0 -0
@@ -40,6 +40,9 @@ struct ndctl_bus *util_bus_filter(struct ndctl_bus
 *bus, const char *__ident)
 
Quoted 9 lines

util/filter.c struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident) · line 45

Quoted 5 lines
util/filter.c +3 -0
        for (name = strtok_r(ident, " ", &save); name;
                        name = strtok_r(NULL, " ", &save)) {
+               if (strcmp(ident, "all") == 0)
+                       break;
+

Let's also remove the strcmp(__ident, "all") at the top of each of these routines to keep the check for "all" centralized.

OK, Thank you!
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm