From: Yu Watanabe Date: Wed, 10 Feb 2021 19:21:46 +0000 (+0900) Subject: tree-wide: use error codes in xxx_from_string() X-Git-Tag: v248-rc1~152^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b98680b2b83c441915d09e7f394bb838abe48696;p=thirdparty%2Fsystemd.git tree-wide: use error codes in xxx_from_string() --- diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 06b71aaf157..b791156097d 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -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; } diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c index da23db947fe..e302a2cf3be 100644 --- a/src/network/netdev/l2tp-tunnel.c +++ b/src/network/netdev/l2tp-tunnel.c @@ -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; } diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 81e8fd7cf14..b26064297b2 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -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; } diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index 66e88682848..fdaec488a21 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -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 diff --git a/src/network/networkd-conf.c b/src/network/networkd-conf.c index bf51624ec48..c413f167394 100644 --- a/src/network/networkd-conf.c +++ b/src/network/networkd-conf.c @@ -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; } diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c index cec7bb63699..e50f4bb70f0 100644 --- a/src/network/networkd-dhcp-common.c +++ b/src/network/networkd-dhcp-common.c @@ -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; } diff --git a/src/network/networkd-lldp-tx.c b/src/network/networkd-lldp-tx.c index b03d948bd89..de61e5119bf 100644 --- a/src/network/networkd-lldp-tx.c +++ b/src/network/networkd-lldp-tx.c @@ -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; } diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index 35bf68cd7e0..39246498e4c 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -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; } diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index a98394c1cae..d0ebb4c3208 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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; } diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index da8778dd1e8..7802a1e55aa 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -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; } diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index f838d4513d6..615782862bc 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -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; } diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index 3b3d37cccca..654d36a83a2 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -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; }