X Tutup
Skip to content

Commit 7fb1d98

Browse files
committed
tree-wide: propagate error in xxx_from-string()
1 parent bde8467 commit 7fb1d98

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/core/mount.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,9 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
12491249
if (streq(key, "state")) {
12501250
MountState state;
12511251

1252-
if ((state = mount_state_from_string(value)) < 0)
1253-
log_unit_debug(u, "Failed to parse state value: %s", value);
1252+
state = mount_state_from_string(value);
1253+
if (state < 0)
1254+
log_unit_debug_errno(u, state, "Failed to parse state value: %s", value);
12541255
else
12551256
m->deserialized_state = state;
12561257

@@ -1259,7 +1260,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
12591260

12601261
f = mount_result_from_string(value);
12611262
if (f < 0)
1262-
log_unit_debug(u, "Failed to parse result value: %s", value);
1263+
log_unit_debug_errno(u, f, "Failed to parse result value: %s", value);
12631264
else if (f != MOUNT_SUCCESS)
12641265
m->result = f;
12651266

@@ -1268,27 +1269,28 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
12681269

12691270
f = mount_result_from_string(value);
12701271
if (f < 0)
1271-
log_unit_debug(u, "Failed to parse reload result value: %s", value);
1272+
log_unit_debug_errno(u, f, "Failed to parse reload result value: %s", value);
12721273
else if (f != MOUNT_SUCCESS)
12731274
m->reload_result = f;
12741275

12751276
} else if (streq(key, "n-retry-umount")) {
12761277

12771278
r = safe_atou(value, &m->n_retry_umount);
12781279
if (r < 0)
1279-
log_unit_debug(u, "Failed to parse n-retry-umount value: %s", value);
1280+
log_unit_debug_errno(u, r, "Failed to parse n-retry-umount value: %s", value);
12801281

12811282
} else if (streq(key, "control-pid")) {
12821283

1283-
if (parse_pid(value, &m->control_pid) < 0)
1284-
log_unit_debug(u, "Failed to parse control-pid value: %s", value);
1284+
r = parse_pid(value, &m->control_pid);
1285+
if (r < 0)
1286+
log_unit_debug_errno(u, r, "Failed to parse control-pid value: %s", value);
12851287

12861288
} else if (streq(key, "control-command")) {
12871289
MountExecCommand id;
12881290

12891291
id = mount_exec_command_from_string(value);
12901292
if (id < 0)
1291-
log_unit_debug(u, "Failed to parse exec-command value: %s", value);
1293+
log_unit_debug_errno(u, id, "Failed to parse exec-command value: %s", value);
12921294
else {
12931295
m->control_command_id = id;
12941296
m->control_command = m->exec_command + id;

src/firstboot/firstboot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,9 @@ static int parse_argv(int argc, char *argv[]) {
11461146
break;
11471147

11481148
case ARG_MACHINE_ID:
1149-
if (sd_id128_from_string(optarg, &arg_machine_id) < 0)
1150-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
1151-
"Failed to parse machine id %s.", optarg);
1149+
r = sd_id128_from_string(optarg, &arg_machine_id);
1150+
if (r < 0)
1151+
return log_error_errno(r, "Failed to parse machine id %s.", optarg);
11521152

11531153
break;
11541154

src/udev/udevadm-trigger.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,21 @@ int trigger_main(int argc, char *argv[], void *userdata) {
210210
else
211211
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
212212
break;
213-
case 'c':
213+
case 'c': {
214+
DeviceAction a;
215+
214216
if (streq(optarg, "help")) {
215217
dump_device_action_table();
216218
return 0;
217219
}
218-
if (device_action_from_string(optarg) < 0)
219-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg);
220+
221+
a = device_action_from_string(optarg);
222+
if (a < 0)
223+
return log_error_errno(a, "Unknown action '%s'", optarg);
220224

221225
action = optarg;
222226
break;
227+
}
223228
case 's':
224229
r = sd_device_enumerator_add_match_subsystem(e, optarg, true);
225230
if (r < 0)

0 commit comments

Comments
 (0)
X Tutup