diff mbox

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

Message ID 20180425073843.19900-1-qi.fuli@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

QI Fuli April 25, 2018, 7:38 a.m. UTC
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@jp.fujitsu.com>
---
 util/filter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Dan Williams April 25, 2018, 2:10 p.m. UTC | #1
On Wed, Apr 25, 2018 at 12:38 AM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
> 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@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;
> +

Let's also remove the strcmp(__ident, "all") at the top of each of
these routines to keep the check for "all" centralized.
QI Fuli April 26, 2018, 12:25 a.m. UTC | #2
> -----Original Message-----

> From: Dan Williams [mailto:dan.j.williams@intel.com]

> Sent: Wednesday, April 25, 2018 11:11 PM

> To: Qi, Fuli/斉 福利 <qi.fuli@jp.fujitsu.com>

> Cc: linux-nvdimm <linux-nvdimm@lists.01.org>

> Subject: Re: [PATCH] ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()

> 

> On Wed, Apr 25, 2018 at 12:38 AM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:

> > 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@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;

> > +

> 

> 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!
diff mbox

Patch

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;