char line[LINE_MAX];
const char *val, *l;
+ errno = 0;
if (!fgets(line, sizeof(line), f)) {
- if (feof(f))
- r = 0;
- else
- r = -errno;
-
- goto finish;
+ if (!feof(f))
+ return -errno ?: -EIO;
+ return 0;
}
char_array_0(line);
} else if (startswith(l, "env=")) {
r = deserialize_environment(&m->environment, l);
if (r == -ENOMEM)
- goto finish;
+ return r;
if (r < 0)
log_notice_errno(r, "Failed to parse environment entry: \"%s\", ignoring: %m", l);
}
} else if ((val = startswith(l, "notify-socket="))) {
- char *n;
-
- n = strdup(val);
- if (!n) {
- r = -ENOMEM;
- goto finish;
- }
-
- free(m->notify_socket);
- m->notify_socket = n;
+ r = free_and_strdup(&m->notify_socket, val);
+ if (r < 0)
+ return r;
} else if ((val = startswith(l, "cgroups-agent-fd="))) {
int fd;
exec_runtime_deserialize_one(m, val, fds);
else if ((val = startswith(l, "subscribed="))) {
- if (strv_extend(&m->deserialized_subscribed, val) < 0) {
- r = -ENOMEM;
- goto finish;
- }
+ if (strv_extend(&m->deserialized_subscribed, val) < 0)
+ return -ENOMEM;
} else {
ManagerTimestamp q;
const char* unit_name;
/* Start marker */
+ errno = 0;
if (!fgets(name, sizeof(name), f)) {
- if (feof(f))
- r = 0;
- else
- r = -errno;
-
- goto finish;
+ if (!feof(f))
+ return -errno ?: -EIO;
+ return 0;
}
char_array_0(name);
r = manager_load_unit(m, unit_name, NULL, NULL, &u);
if (r < 0) {
if (r == -ENOMEM)
- goto finish;
+ return r;
log_notice_errno(r, "Failed to load unit \"%s\", skipping deserialization: %m", unit_name);
unit_deserialize_skip(f);
r = unit_deserialize(u, f, fds);
if (r < 0) {
if (r == -ENOMEM)
- goto finish;
+ return r;
log_notice_errno(r, "Failed to deserialize unit \"%s\": %m", unit_name);
}
}
-finish:
- if (ferror(f))
- r = -EIO;
-
- return r;
+ return 0;
}
static void manager_flush_finished_jobs(Manager *m) {