udev: use parse_sec() to parse --event-timeout option

This commit is contained in:
Yu Watanabe 2018-10-25 18:06:44 +09:00
parent 389f9bf2cf
commit 9d9264ba39
1 changed files with 7 additions and 11 deletions

View File

@ -1461,11 +1461,9 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
r = safe_atou64(value, &arg_event_timeout_usec);
if (r >= 0) {
arg_event_timeout_usec *= USEC_PER_SEC;
arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
}
r = parse_sec(value, &arg_event_timeout_usec);
if (r >= 0)
arg_event_timeout_warn_usec = DIV_ROUND_UP(arg_event_timeout_usec, 3);
} else if (proc_cmdline_key_streq(key, "udev.children_max")) {
@ -1554,13 +1552,11 @@ static int parse_argv(int argc, char *argv[]) {
log_warning_errno(r, "Failed to parse --exec-delay= value '%s', ignoring: %m", optarg);
break;
case 't':
r = safe_atou64(optarg, &arg_event_timeout_usec);
r = parse_sec(optarg, &arg_event_timeout_usec);
if (r < 0)
log_warning("Invalid --event-timeout ignored: %s", optarg);
else {
arg_event_timeout_usec *= USEC_PER_SEC;
arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
}
log_warning_errno(r, "Failed to parse --event-timeout= value '%s', ignoring: %m", optarg);
arg_event_timeout_warn_usec = DIV_ROUND_UP(arg_event_timeout_usec, 3);
break;
case 'D':
arg_debug = true;