parse-util: add parse_tristate() and use it everywhere

We parse tristates all the time, let's add an explicit parser for them.
This commit is contained in:
Lennart Poettering
2023-11-02 04:52:16 +09:00
committed by Yu Watanabe
parent 6a4d0efa00
commit b71a721fbc
11 changed files with 47 additions and 84 deletions
+3 -8
View File
@@ -830,14 +830,9 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case ARG_CHECK_INHIBITORS:
if (streq(optarg, "auto"))
arg_check_inhibitors = -1;
else {
r = parse_boolean(optarg);
if (r < 0)
return log_error_errno(r, "Failed to parse --check-inhibitors= argument: %s", optarg);
arg_check_inhibitors = r;
}
r = parse_tristate_full(optarg, "auto", &arg_check_inhibitors);
if (r < 0)
return log_error_errno(r, "Failed to parse --check-inhibitors= argument: %s", optarg);
break;
case ARG_PLAIN: