@@ -191,16 +191,16 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
usage_with_options(u, options);
for (i = 0; i < argc; i++) {
if (strcmp(argv[i], "all") == 0) {
- argv[0] = "all";
argc = 1;
break;
}
+ if (sscanf(argv[i], "mem%lu", &id) == 1)
+ continue;
+ if (sscanf(argv[i], "%lu", &id) == 1)
+ continue;
- if (sscanf(argv[i], "mem%lu", &id) != 1) {
- log_err(&ml, "'%s' is not a valid memdev name\n",
- argv[i]);
- err++;
- }
+ log_err(&ml, "'%s' is not a valid memdev name\n", argv[i]);
+ err++;
}
if (err == argc) {
@@ -243,11 +243,7 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
count = 0;
for (i = 0; i < argc; i++) {
- if (sscanf(argv[i], "mem%lu", &id) != 1
- && strcmp(argv[i], "all") != 0)
- continue;
-
- cxl_memdev_foreach (ctx, memdev) {
+ cxl_memdev_foreach(ctx, memdev) {
if (!util_cxl_memdev_filter(memdev, argv[i], NULL))
continue;
util_cxl_memdev_filter() already handles the difference between 'mem%d', '%d', and 'all' for the identifier format. Drop the duplicate / incomplete format checking. If the checking for bad formats was dropped too then this command could support "0,1,2" syntax in addition to "0 1 2" like 'cxl list'. However, it is not clear that's worthwhile since 'list' is ok to be imprecise, but memdev commands need to be stricter. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- cxl/memdev.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)