1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

various: make parse_env_file error handling the same in various places

No big reason to do this, except that I was looking at all call sites
and it's nicer if the same style is used accross the codebase.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-03-10 18:45:52 +01:00 committed by Lennart Poettering
parent 592d576552
commit 40f35786b0
4 changed files with 9 additions and 19 deletions

View File

@ -269,13 +269,11 @@ _public_ int sd_uid_get_state(uid_t uid, char**state) {
return r; return r;
r = parse_env_file(NULL, p, "STATE", &s); r = parse_env_file(NULL, p, "STATE", &s);
if (r == -ENOENT) { if (r == -ENOENT)
r = free_and_strdup(&s, "offline"); r = free_and_strdup(&s, "offline");
if (r < 0) if (r < 0)
return r;
} else if (r < 0)
return r; return r;
else if (isempty(s)) if (isempty(s))
return -EIO; return -EIO;
*state = TAKE_PTR(s); *state = TAKE_PTR(s);

View File

@ -157,7 +157,6 @@ int locale_read_data(Context *c, sd_bus_message *m) {
int vconsole_read_data(Context *c, sd_bus_message *m) { int vconsole_read_data(Context *c, sd_bus_message *m) {
struct stat st; struct stat st;
usec_t t; usec_t t;
int r;
/* Do not try to re-read the file within single bus operation. */ /* Do not try to re-read the file within single bus operation. */
if (m) { if (m) {
@ -185,13 +184,9 @@ int vconsole_read_data(Context *c, sd_bus_message *m) {
c->vc_mtime = t; c->vc_mtime = t;
context_free_vconsole(c); context_free_vconsole(c);
r = parse_env_file(NULL, "/etc/vconsole.conf", return parse_env_file(NULL, "/etc/vconsole.conf",
"KEYMAP", &c->vc_keymap, "KEYMAP", &c->vc_keymap,
"KEYMAP_TOGGLE", &c->vc_keymap_toggle); "KEYMAP_TOGGLE", &c->vc_keymap_toggle);
if (r < 0)
return r;
return 0;
} }
int x11_read_data(Context *c, sd_bus_message *m) { int x11_read_data(Context *c, sd_bus_message *m) {

View File

@ -445,7 +445,6 @@ int session_load(Session *s) {
"ACTIVE", &active, "ACTIVE", &active,
"DEVICES", &devices, "DEVICES", &devices,
"IS_DISPLAY", &is_display); "IS_DISPLAY", &is_display);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to read %s: %m", s->state_file); return log_error_errno(r, "Failed to read %s: %m", s->state_file);

View File

@ -265,12 +265,10 @@ int machine_load(Machine *m) {
"REALTIME", &realtime, "REALTIME", &realtime,
"MONOTONIC", &monotonic, "MONOTONIC", &monotonic,
"NETIF", &netif); "NETIF", &netif);
if (r < 0) { if (r == -ENOENT)
if (r == -ENOENT) return 0;
return 0; if (r < 0)
return log_error_errno(r, "Failed to read %s: %m", m->state_file); return log_error_errno(r, "Failed to read %s: %m", m->state_file);
}
if (id) if (id)
sd_id128_from_string(id, &m->id); sd_id128_from_string(id, &m->id);