1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-26 10:03:40 +03:00

tree-wide: use error codes in xxx_from_string()

This commit is contained in:
Yu Watanabe 2021-02-11 04:21:46 +09:00
parent 0cbb768aba
commit b98680b2b8
12 changed files with 36 additions and 29 deletions

View File

@ -660,7 +660,7 @@ int config_parse_kill_mode(
m = kill_mode_from_string(rvalue);
if (m < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, m,
"Failed to parse kill mode specification, ignoring: %s", rvalue);
return 0;
}
@ -990,7 +990,7 @@ int config_parse_exec_input(
} else {
ei = exec_input_from_string(rvalue);
if (ei < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse input specifier, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, ei, "Failed to parse input specifier, ignoring: %s", rvalue);
return 0;
}
}
@ -1219,7 +1219,7 @@ int config_parse_exec_output(
} else {
eo = exec_output_from_string(rvalue);
if (eo < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output specifier, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, eo, "Failed to parse output specifier, ignoring: %s", rvalue);
return 0;
}
}
@ -1278,7 +1278,7 @@ int config_parse_exec_io_class(const char *unit,
x = ioprio_class_from_string(rvalue);
if (x < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse IO scheduling class, ignoring: %s", rvalue);
return 0;
}
@ -1353,7 +1353,7 @@ int config_parse_exec_cpu_sched_policy(const char *unit,
x = sched_policy_from_string(rvalue);
if (x < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
return 0;
}
@ -1527,7 +1527,8 @@ int config_parse_root_image_options(
partition_designator = partition_designator_from_string(partition);
if (partition_designator < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition);
log_syntax(unit, LOG_WARNING, filename, line, partition_designator,
"Invalid partition name %s, ignoring", partition);
continue;
}
r = unit_full_printf(u, mount_options, &mount_options_resolved);
@ -2015,7 +2016,7 @@ int config_parse_trigger_unit(
type = unit_name_to_type(p);
if (type < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unit type not valid, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, type, "Unit type not valid, ignoring: %s", rvalue);
return 0;
}
if (unit_has_name(u, p)) {
@ -2062,7 +2063,7 @@ int config_parse_path_spec(const char *unit,
b = path_type_from_string(lvalue);
if (b < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse path type, ignoring: %s", lvalue);
log_syntax(unit, LOG_WARNING, filename, line, b, "Failed to parse path type, ignoring: %s", lvalue);
return 0;
}
@ -3386,8 +3387,12 @@ int config_parse_syscall_errno(
}
e = parse_errno(rvalue);
if (e <= 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue);
if (e < 0) {
log_syntax(unit, LOG_WARNING, filename, line, e, "Failed to parse error number, ignoring: %s", rvalue);
return 0;
}
if (e == 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid error number, ignoring: %s", rvalue);
return 0;
}
@ -3857,7 +3862,7 @@ int config_parse_managed_oom_mode(
m = managed_oom_mode_from_string(rvalue);
if (m < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, m, "Invalid syntax, ignoring: %s", rvalue);
return 0;
}
*mode = m;
@ -4668,7 +4673,7 @@ int config_parse_set_status(
} else {
r = signal_from_string(word);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse value, ignoring: %s", word);
continue;
}
@ -5085,7 +5090,8 @@ int config_parse_mount_images(
partition_designator = partition_designator_from_string(partition);
if (partition_designator < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition);
log_syntax(unit, LOG_WARNING, filename, line, partition_designator,
"Invalid partition name %s, ignoring", partition);
continue;
}
r = unit_full_printf(u, mount_options, &mount_options_resolved);
@ -5774,7 +5780,7 @@ int config_parse_output_restricted(
} else {
t = exec_output_from_string(rvalue);
if (t < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, t, "Failed to parse output type, ignoring: %s", rvalue);
return 0;
}

View File

@ -577,7 +577,7 @@ int config_parse_l2tp_session_l2spec(
spec = l2tp_l2spec_type_from_string(rvalue);
if (spec < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, spec,
"Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
return 0;
}

View File

@ -139,7 +139,7 @@ int config_parse_netdev_kind(
k = netdev_kind_from_string(rvalue);
if (k < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, k, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
return 0;
}

View File

@ -581,7 +581,8 @@ int config_parse_tunnel_key(const char *unit,
if (r < 0) {
r = safe_atou32(rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse tunnel key ignoring assignment: %s", rvalue);
return 0;
}
} else

View File

@ -93,7 +93,7 @@ int config_parse_duid_type(
type = duid_type_from_string(type_string);
if (type < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, type,
"Failed to parse DUID type '%s', ignoring.", type_string);
return 0;
}

View File

@ -671,7 +671,7 @@ int config_parse_dhcp_send_option(
type = dhcp_option_data_type_from_string(word);
if (type < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, type,
"Invalid DHCP option data type, ignoring assignment: %s", p);
return 0;
}

View File

@ -445,7 +445,7 @@ int config_parse_lldp_emit(
else {
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse LLDP emission setting, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse LLDP emission setting, ignoring: %s", rvalue);
return 0;
}

View File

@ -948,7 +948,7 @@ int config_parse_router_prefix_delegation(
/* For backward compatibility */
val = radv_prefix_delegation_from_string(rvalue);
if (val < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, val,
"Invalid %s= setting, ignoring assignment: %s", lvalue, rvalue);
return 0;
}

View File

@ -1909,7 +1909,7 @@ int config_parse_route_scope(
r = route_scope_from_string(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown route scope: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Unknown route scope: %s", rvalue);
return 0;
}
@ -2124,7 +2124,7 @@ int config_parse_route_type(
t = route_type_from_string(rvalue);
if (t < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse route type \"%s\", ignoring assignment: %m", rvalue);
return 0;
}

View File

@ -1422,7 +1422,7 @@ int config_parse_routing_policy_rule_family(
a = routing_policy_rule_address_family_from_string(rvalue);
if (a < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, a,
"Invalid address family '%s', ignoring.", rvalue);
return 0;
}
@ -1547,7 +1547,7 @@ int config_parse_routing_policy_rule_type(
t = fr_act_type_from_string(rvalue);
if (t < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, t,
"Could not parse FIB rule type \"%s\", ignoring assignment: %m", rvalue);
return 0;
}

View File

@ -874,7 +874,7 @@ int config_parse_log_facility(
x = log_facility_unshifted_from_string(rvalue);
if (x < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log facility, ignoring: %s", rvalue);
return 0;
}
@ -904,7 +904,7 @@ int config_parse_log_level(
x = log_level_from_string(rvalue);
if (x < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log level, ignoring: %s", rvalue);
return 0;
}
@ -937,7 +937,7 @@ int config_parse_signal(
r = signal_from_string(rvalue);
if (r <= 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse signal name, ignoring: %s", rvalue);
return 0;
}

View File

@ -1092,7 +1092,7 @@ int config_parse_advertise(const char *unit,
/* We reuse the kernel provided enum which does not contain negative value. So, the cast
* below is mandatory. Otherwise, the check below always passes and access an invalid address. */
if ((int) mode < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, mode,
"Failed to parse advertise mode, ignoring: %s", w);
continue;
}