]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use error codes in xxx_from_string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Feb 2021 19:21:46 +0000 (04:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Feb 2021 16:17:13 +0000 (01:17 +0900)
12 files changed:
src/core/load-fragment.c
src/network/netdev/l2tp-tunnel.c
src/network/netdev/netdev.c
src/network/netdev/tunnel.c
src/network/networkd-conf.c
src/network/networkd-dhcp-common.c
src/network/networkd-lldp-tx.c
src/network/networkd-radv.c
src/network/networkd-route.c
src/network/networkd-routing-policy-rule.c
src/shared/conf-parser.c
src/shared/ethtool-util.c

index 06b71aaf1575a10b5132eeefc4fd9660f031b76f..b791156097d57b7b0b1000cffacb0bbeee16a8dd 100644 (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;
                 }
 
index da23db947fe09be60bfcf232e9072fec6e7e8e12..e302a2cf3be2bb7759872123d305acdb9df547c3 100644 (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;
         }
index 81e8fd7cf14934910c128ea6b7a985eb581d8af6..b26064297b296c5ae7f1d138acbfe0859c2283bc 100644 (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;
         }
 
index 66e8868284829fcdb6ae0f39ac814c173d5bb477..fdaec488a2196c2a8cfc9a022468d04cd900f336 100644 (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
index bf51624ec489984b3dd8a8428a2fd328d9c7a46a..c413f167394e811da0c9f308434fefa897b2e0f3 100644 (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;
         }
index cec7bb6369996efcbb48b4c483ef50b650b6fa70..e50f4bb70f01542174db04fc9c24816287607cfd 100644 (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;
         }
index b03d948bd89565496c77aaac6ba736340754fabd..de61e5119bfdaac1e48f5c2f56503ac83315d15b 100644 (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;
                 }
 
index 35bf68cd7e0b09f7eba9921b75eae101d7335a00..39246498e4c21045478e92cec8f8dddbc2a8532f 100644 (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;
         }
index a98394c1caee37c2f8ce0dbecb0466efe68cf793..d0ebb4c32082856e73a34140308ff3030c389ac9 100644 (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;
         }
index da8778dd1e80b0f2d245e4a581be7449851f1b7f..7802a1e55aa380337e730df5ea68a172f306fae2 100644 (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;
         }
index f838d4513d65dd92e59a04c2613ab000157ae81a..615782862bccb0f5e725d16ae0f5a5a73e403336 100644 (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;
         }
 
index 3b3d37ccccac1f87a424375c9a02e8297c8c1228..654d36a83a24fb0adb952050dbe5534b92f05380 100644 (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;
                 }