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:
parent
592d576552
commit
40f35786b0
@ -269,13 +269,11 @@ _public_ int sd_uid_get_state(uid_t uid, char**state) {
|
||||
return r;
|
||||
|
||||
r = parse_env_file(NULL, p, "STATE", &s);
|
||||
if (r == -ENOENT) {
|
||||
if (r == -ENOENT)
|
||||
r = free_and_strdup(&s, "offline");
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (r < 0)
|
||||
if (r < 0)
|
||||
return r;
|
||||
else if (isempty(s))
|
||||
if (isempty(s))
|
||||
return -EIO;
|
||||
|
||||
*state = TAKE_PTR(s);
|
||||
|
@ -157,7 +157,6 @@ int locale_read_data(Context *c, sd_bus_message *m) {
|
||||
int vconsole_read_data(Context *c, sd_bus_message *m) {
|
||||
struct stat st;
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
/* Do not try to re-read the file within single bus operation. */
|
||||
if (m) {
|
||||
@ -185,13 +184,9 @@ int vconsole_read_data(Context *c, sd_bus_message *m) {
|
||||
c->vc_mtime = t;
|
||||
context_free_vconsole(c);
|
||||
|
||||
r = parse_env_file(NULL, "/etc/vconsole.conf",
|
||||
"KEYMAP", &c->vc_keymap,
|
||||
"KEYMAP_TOGGLE", &c->vc_keymap_toggle);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
return parse_env_file(NULL, "/etc/vconsole.conf",
|
||||
"KEYMAP", &c->vc_keymap,
|
||||
"KEYMAP_TOGGLE", &c->vc_keymap_toggle);
|
||||
}
|
||||
|
||||
int x11_read_data(Context *c, sd_bus_message *m) {
|
||||
|
@ -445,7 +445,6 @@ int session_load(Session *s) {
|
||||
"ACTIVE", &active,
|
||||
"DEVICES", &devices,
|
||||
"IS_DISPLAY", &is_display);
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to read %s: %m", s->state_file);
|
||||
|
||||
|
@ -265,12 +265,10 @@ int machine_load(Machine *m) {
|
||||
"REALTIME", &realtime,
|
||||
"MONOTONIC", &monotonic,
|
||||
"NETIF", &netif);
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to read %s: %m", m->state_file);
|
||||
}
|
||||
|
||||
if (id)
|
||||
sd_id128_from_string(id, &m->id);
|
||||
|
Loading…
Reference in New Issue
Block a user