diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 233058d5d661..4257dd73db0e 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -481,12 +481,18 @@ md_list(const char *units, int opt, const char *fflag) printf("\n"); /* XXX: Check if it's enough to clean everything. */ geom_stats_snapshot_free(sq); - if (((opt & OPT_UNIT) && (fflag == NULL) && ufound) || - ((opt & OPT_UNIT) == 0 && (fflag != NULL) && ffound) || - ((opt & OPT_UNIT) && (fflag != NULL) && ufound && ffound)) - return (0); - else - return (-1); + if (opt & OPT_UNIT) { + if (((fflag == NULL) && ufound) || + ((fflag == NULL) && (units != NULL) && ufound) || + ((fflag != NULL) && ffound) || + ((fflag != NULL) && (units != NULL) && ufound && ffound)) + return (0); + } else if (opt & OPT_LIST) { + if ((fflag == NULL) || + ((fflag != NULL) && ffound)) + return (0); + } + return (-1); } /*