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

tree-wide: propagate error in xxx_from-string()

This commit is contained in:
Yu Watanabe 2021-02-11 05:21:42 +09:00
parent bde8467a0d
commit 7fb1d980af
3 changed files with 21 additions and 14 deletions

View 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;

View 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;

View 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)