diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index c1413241f..de36c4af1 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -10672,9 +10671,7 @@ int zpool_do_wait(int argc, char **argv) { boolean_t verbose = B_FALSE; - int c; - char *value; - int i; + int c, i; unsigned long count; pthread_t status_thr; int error = 0; @@ -10708,28 +10705,26 @@ zpool_do_wait(int argc, char **argv) get_timestamp_arg(*optarg); break; case 't': - { - static char *col_subopts[] = { "discard", "free", - "initialize", "replace", "remove", "resilver", - "scrub", "trim", NULL }; - /* Reset activities array */ memset(&wd.wd_enabled, 0, sizeof (wd.wd_enabled)); - while (*optarg != '\0') { - int activity = getsubopt(&optarg, col_subopts, - &value); - if (activity < 0) { - (void) fprintf(stderr, - gettext("invalid activity '%s'\n"), - value); - usage(B_FALSE); - } + for (char *tok; (tok = strsep(&optarg, ",")); ) { + static const char *const col_opts[] = { + "discard", "free", "initialize", "replace", + "remove", "resilver", "scrub", "trim" }; - wd.wd_enabled[activity] = B_TRUE; + for (i = 0; i < ARRAY_SIZE(col_opts); ++i) + if (strcmp(tok, col_opts[i]) == 0) { + wd.wd_enabled[i] = B_TRUE; + goto found; + } + + (void) fprintf(stderr, + gettext("invalid activity '%s'\n"), tok); + usage(B_FALSE); +found:; } break; - } case '?': (void) fprintf(stderr, gettext("invalid option '%c'\n"), optopt);