mirror of
https://github.com/systemd/systemd.git
synced 2025-03-11 20:58:27 +03:00
pid1: normalize oom error handling a bit
This commit is contained in:
parent
06ffa66a5b
commit
cf7d0a2d2e
@ -117,10 +117,9 @@ int exec_context_put_load_credential(ExecContext *c, const char *id, const char
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = hashmap_ensure_put(&c->load_credentials, &exec_load_credential_hash_ops, lc->id, lc);
|
r = hashmap_ensure_put(&c->load_credentials, &exec_load_credential_hash_ops, lc->id, lc);
|
||||||
if (r < 0) {
|
assert(r != -EEXIST);
|
||||||
assert(r != -EEXIST);
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
TAKE_PTR(lc);
|
TAKE_PTR(lc);
|
||||||
}
|
}
|
||||||
@ -167,10 +166,9 @@ int exec_context_put_set_credential(
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = hashmap_ensure_put(&c->set_credentials, &exec_set_credential_hash_ops, sc->id, sc);
|
r = hashmap_ensure_put(&c->set_credentials, &exec_set_credential_hash_ops, sc->id, sc);
|
||||||
if (r < 0) {
|
assert(r != -EEXIST);
|
||||||
assert(r != -EEXIST);
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
TAKE_PTR(sc);
|
TAKE_PTR(sc);
|
||||||
}
|
}
|
||||||
@ -193,19 +191,22 @@ int exec_context_put_import_credential(ExecContext *c, const char *glob, const c
|
|||||||
|
|
||||||
*ic = (ExecImportCredential) {
|
*ic = (ExecImportCredential) {
|
||||||
.glob = strdup(glob),
|
.glob = strdup(glob),
|
||||||
.rename = rename ? strdup(rename) : NULL,
|
|
||||||
};
|
};
|
||||||
if (!ic->glob || (rename && !ic->rename))
|
if (!ic->glob)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
if (rename) {
|
||||||
|
ic->rename = strdup(rename);
|
||||||
|
if (!ic->rename)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
if (ordered_set_contains(c->import_credentials, ic))
|
if (ordered_set_contains(c->import_credentials, ic))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = ordered_set_ensure_put(&c->import_credentials, &exec_import_credential_hash_ops, ic);
|
r = ordered_set_ensure_put(&c->import_credentials, &exec_import_credential_hash_ops, ic);
|
||||||
if (r < 0) {
|
assert(r != -EEXIST);
|
||||||
assert(r != -EEXIST);
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
TAKE_PTR(ic);
|
TAKE_PTR(ic);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user