]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: propagate error in xxx_from-string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Feb 2021 20:21:42 +0000 (05:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Feb 2021 16:19:18 +0000 (01:19 +0900)
src/core/mount.c
src/firstboot/firstboot.c
src/udev/udevadm-trigger.c

index 1ad80886cd0802ca8a5964895eae731120c2d695..23b558859c2fef6eb21dea7379b40104c1a235b2 100644 (file)
@@ -1249,8 +1249,9 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
         if (streq(key, "state")) {
                 MountState state;
 
-                if ((state = mount_state_from_string(value)) < 0)
-                        log_unit_debug(u, "Failed to parse state value: %s", value);
+                state = mount_state_from_string(value);
+                if (state < 0)
+                        log_unit_debug_errno(u, state, "Failed to parse state value: %s", value);
                 else
                         m->deserialized_state = state;
 
@@ -1259,7 +1260,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
 
                 f = mount_result_from_string(value);
                 if (f < 0)
-                        log_unit_debug(u, "Failed to parse result value: %s", value);
+                        log_unit_debug_errno(u, f, "Failed to parse result value: %s", value);
                 else if (f != MOUNT_SUCCESS)
                         m->result = f;
 
@@ -1268,7 +1269,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
 
                 f = mount_result_from_string(value);
                 if (f < 0)
-                        log_unit_debug(u, "Failed to parse reload result value: %s", value);
+                        log_unit_debug_errno(u, f, "Failed to parse reload result value: %s", value);
                 else if (f != MOUNT_SUCCESS)
                         m->reload_result = f;
 
@@ -1276,19 +1277,20 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
 
                 r = safe_atou(value, &m->n_retry_umount);
                 if (r < 0)
-                        log_unit_debug(u, "Failed to parse n-retry-umount value: %s", value);
+                        log_unit_debug_errno(u, r, "Failed to parse n-retry-umount value: %s", value);
 
         } else if (streq(key, "control-pid")) {
 
-                if (parse_pid(value, &m->control_pid) < 0)
-                        log_unit_debug(u, "Failed to parse control-pid value: %s", value);
+                r = parse_pid(value, &m->control_pid);
+                if (r < 0)
+                        log_unit_debug_errno(u, r, "Failed to parse control-pid value: %s", value);
 
         } else if (streq(key, "control-command")) {
                 MountExecCommand id;
 
                 id = mount_exec_command_from_string(value);
                 if (id < 0)
-                        log_unit_debug(u, "Failed to parse exec-command value: %s", value);
+                        log_unit_debug_errno(u, id, "Failed to parse exec-command value: %s", value);
                 else {
                         m->control_command_id = id;
                         m->control_command = m->exec_command + id;
index 904612ab4a61c39a9c49949805fe511a28b8db0d..a9cc03cc3f2beec74a057067725b5fc9e0e2a523 100644 (file)
@@ -1146,9 +1146,9 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_MACHINE_ID:
-                        if (sd_id128_from_string(optarg, &arg_machine_id) < 0)
-                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                                       "Failed to parse machine id %s.", optarg);
+                        r = sd_id128_from_string(optarg, &arg_machine_id);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to parse machine id %s.", optarg);
 
                         break;
 
index 7a9f968128950364f2f38d39374d11123ae70d18..a4588cb4e4f5097c68268de8a052b366ff534c3a 100644 (file)
@@ -210,16 +210,21 @@ int trigger_main(int argc, char *argv[], void *userdata) {
                         else
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
                         break;
-                case 'c':
+                case 'c': {
+                        DeviceAction a;
+
                         if (streq(optarg, "help")) {
                                 dump_device_action_table();
                                 return 0;
                         }
-                        if (device_action_from_string(optarg) < 0)
-                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg);
+
+                        a = device_action_from_string(optarg);
+                        if (a < 0)
+                                return log_error_errno(a, "Unknown action '%s'", optarg);
 
                         action = optarg;
                         break;
+                }
                 case 's':
                         r = sd_device_enumerator_add_match_subsystem(e, optarg, true);
                         if (r < 0)