ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()
PATCH v2 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.
Change log since v1:
- Removing the strcmp(__ident, "all") == 0 at the top of util_<obj>_filter()
- Changing the strcmp(ident, "all") == 0 to strcmp(name, "all") == 0
--- util/filter.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
util/filter.c +16 -4
@@ -31,7 +31,7 @@ struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident)unsigned long bus_id, id;const char *provider, *devname, *name; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return bus; ident =strdup (__ident);
@@ -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 (name,"all" ) ==0 ) +break ; + bus_id =strtoul (ident, &end,0 );if (end == ident || end[0 ]) bus_id =ULONG_MAX ;
@@ -69,7 +72,7 @@ struct ndctl_region *util_region_filter(struct ndctl_region *region,const char *name, *region_name;unsigned long region_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return region; ident =strdup (__ident);
@@ -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 (name,"all" ) ==0 ) +break ; + region_id =strtoul (ident, &end,0 );if (end == ident || end[0 ]) region_id =ULONG_MAX ;
@@ -106,7 +112,7 @@ struct ndctl_namespace *util_namespace_filter(struct ndctl_namespace *ndns,const char *name;char *ident, *save; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return ndns; ident =strdup (__ident);
@@ -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 (name,"all" ) ==0 ) +break ; +if (strcmp (name,ndctl_namespace_get_devname (ndns)) ==0 )break ;
@@ -137,7 +146,7 @@ struct ndctl_dimm *util_dimm_filter(struct ndctl_dimm *dimm,const char *name, *dimm_name;unsigned long dimm_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return dimm; ident =strdup (__ident);
@@ -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 (name,"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
Quoted 7 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.Signed-off-by QI Fuli <[email protected]>
Looks good,
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 10 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.Signed-off-by QI Fuli <[email protected]>
Quoted 8 lines
Change log since v1:
- Removing thestrcmp(__ident, "all")== 0 at the top of
util_<obj>_filter()
- Changing thestrcmp(ident, "all")== 0 tostrcmp(name, "all")== 0--- util/filter.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
Thanks, applied. Just as a future note, you should have the "changes since v1" notes below the '---' marker (between the --- and the first file diffstat). This prevents it from being picked up as part of the commit message.
Thanks,
-Vishal
Quoted 89 lines
util/filter.c +1
-1@@ -31,7 +31,7 @@ struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident)unsigned long bus_id, id;const char *provider, *devname, *name; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return bus;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; + bus_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])util/filter.c +1
-1bus_id =ULONG_MAX ;@@ -69,7 +72,7 @@ struct ndctl_region *util_region_filter(structndctl_region *region, const char *name, *region_name;unsigned long region_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return region;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; + region_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])util/filter.c +1
-1region_id =ULONG_MAX ;@@ -106,7 +112,7 @@ struct ndctl_namespace *util_namespace_filter(structndctl_namespace *ndns, const char *name;char *ident, *save; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return ndns;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; +if (strcmp (name,ndctl_namespace_get_devname (ndns)) ==0 )util/filter.c +1
-1break ;@@ -137,7 +146,7 @@ struct ndctl_dimm *util_dimm_filter(struct ndctl_dimm *dimm, const char *name, *dimm_name;unsigned long dimm_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return dimm;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; + dimm_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])
Quoted 1 line
dimm_id=ULONG_MAX;
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 27 lines
-----Original Message-----
From: Verma, Vishal L [mailto:[email protected]]
Sent: Thursday, May 3, 2018 6:38 AM
To: [email protected]; Qi, Fuli/斉 福利 <[email protected]>
Subject: Re: [PATCH v2] ndctl, filter: fix "keyword 'all' is ignored" in util_<obj>_filter()Quoted 10 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.Signed-off-by QI Fuli <[email protected]>Quoted 8 lines
Change log since v1:
- Removing thestrcmp(__ident, "all")== 0 at the top of
util_<obj>_filter()
- Changing thestrcmp(ident, "all")== 0 tostrcmp(name, "all")== 0--- util/filter.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
Quoted 7 lines
Thanks, applied. Just as a future note, you should have the "changes since v1" notes below the '---' marker (between the --- and the first file diffstat). This prevents it from being picked up as part of the commit message.
Thanks,
-Vishal
Thank you for your comment.
I will take an eye on it.
Best,
- Qi
Quoted 82 lines
Quoted 82 lines
util/filter.c index 0d3cc02..1734bce renamed from util/filter.c +0
-0100644
util/filter.c +1
-1@@ -31,7 +31,7 @@ struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident)unsigned long bus_id, id;const char *provider, *devname, *name; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return bus;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; + bus_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])util/filter.c +1
-1bus_id =ULONG_MAX ;@@ -69,7 +72,7 @@ struct ndctl_region *util_region_filter(structndctl_region *region, const char *name, *region_name;unsigned long region_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return region;util/filter.c +3
-0ident =strdup (__ident);@@ -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 (name,"all" ) ==0 ) +break ; + region_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])util/filter.c +1
-1region_id =ULONG_MAX ;@@ -106,7 +112,7 @@ struct ndctl_namespace *util_namespace_filter(struct ndctl_namespace *ndns, const char *name;char *ident, *save; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return ndns;util/filter.c +3
-0ident =strdup (__ident);@@ -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(name, "all") == 0) + break; + if (strcmp(name, ndctl_namespace_get_devname(ndns)) == 0)util/filter.c +1
-1break ;@@ -137,7 +146,7 @@ struct ndctl_dimm *util_dimm_filter(structndctl_dimm *dimm, const char *name, *dimm_name;unsigned long dimm_id, id; -if (!__ident ||strcmp (__ident,"all" ) ==0 ) +if (!__ident)return dimm;util/filter.c +0
-0ident =strdup (__ident);@@ -146,6 +155,9 @@ struct ndctl_dimm *util_dimm_filter(struct ndctl_dimm *dimm,
Quoted 8 lines
Quoted 8 lines
util/filter.c +3
-0for (name =strtok_r (ident," " , &save); name; name =strtok_r (NULL ," " , &save)) { +if (strcmp (name,"all" ) ==0 ) +break ; + dimm_id =strtoul (ident, &end,0 );if (end == ident || end[0 ])
dimm_id=ULONG_MAX;
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm