summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-11 05:21:42 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-12 01:19:18 +0900
commit7fb1d980aff8b035d96a34bd30efff261f3a5494 (patch)
tree9e421df1b8fabee1e55e2e9f186552ca9dbd8c90
parentbde8467a0de6fd2ec0a0738d9f3f0689ae5dd37f (diff)
downloadsystemd-7fb1d980aff8b035d96a34bd30efff261f3a5494.tar.gz
tree-wide: propagate error in xxx_from-string()
-rw-r--r--src/core/mount.c18
-rw-r--r--src/firstboot/firstboot.c6
-rw-r--r--src/udev/udevadm-trigger.c11
3 files changed, 21 insertions, 14 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index 1ad80886cd..23b558859c 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -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;
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 904612ab4a..a9cc03cc3f 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -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;
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 7a9f968128..a4588cb4e4 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -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)