diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 938fd2edd5..2a16bd0b49 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -8503,27 +8503,25 @@ zfs_do_wait(int argc, char **argv) while ((c = getopt(argc, argv, "t:")) != -1) { switch (c) { case 't': - { - static char *col_subopts[] = { "deleteq", NULL }; - char *value; - /* Reset activities array */ memset(&enabled, 0, sizeof (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_subopts[ + ZFS_WAIT_NUM_ACTIVITIES] = { "deleteq" }; - enabled[activity] = B_TRUE; + for (i = 0; i < ARRAY_SIZE(col_subopts); ++i) + if (strcmp(tok, col_subopts[i]) == 0) { + 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);