a = hashmap_new(string_hash_func, string_compare_func);
b = hashmap_new(string_hash_func, string_compare_func);
if (!a || !b) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
/* We need a new root cgroup */
m->cgroup_hierarchy = NULL;
if (asprintf(&m->cgroup_hierarchy, "%s%s", streq(current, "/") ? "" : current, suffix) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
}
dbus_connection_set_exit_on_disconnect(bus, FALSE);
if (!dbus_connection_set_watch_functions(bus, bus_add_watch, bus_remove_watch, bus_toggle_watch, m, NULL) ||
- !dbus_connection_set_timeout_functions(bus, bus_add_timeout, bus_remove_timeout, bus_toggle_timeout, m, NULL)) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ !dbus_connection_set_timeout_functions(bus, bus_add_timeout, bus_remove_timeout, bus_toggle_timeout, m, NULL))
+ return log_oom();
- if (set_put(m->bus_connections_for_dispatch, bus) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (set_put(m->bus_connections_for_dispatch, bus) < 0)
+ return log_oom();
dbus_connection_set_dispatch_status_function(bus, bus_dispatch_status, m, NULL);
return 0;
!dbus_connection_register_fallback(new_connection, "/org/freedesktop/systemd1/unit", &bus_unit_vtable, m) ||
!dbus_connection_register_fallback(new_connection, "/org/freedesktop/systemd1/job", &bus_job_vtable, m) ||
!dbus_connection_add_filter(new_connection, private_bus_message_filter, m, NULL)) {
- log_error("Out of memory.");
+ log_oom();
return;
}
static int init_registered_system_bus(Manager *m) {
char *id;
- if (!dbus_connection_add_filter(m->system_bus, system_bus_message_filter, m, NULL)) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!dbus_connection_add_filter(m->system_bus, system_bus_message_filter, m, NULL))
+ return log_oom();
if (m->running_as != MANAGER_SYSTEM) {
DBusError error;
if (!dbus_connection_register_object_path(m->api_bus, "/org/freedesktop/systemd1", &bus_manager_vtable, m) ||
!dbus_connection_register_fallback(m->api_bus, "/org/freedesktop/systemd1/unit", &bus_unit_vtable, m) ||
!dbus_connection_register_fallback(m->api_bus, "/org/freedesktop/systemd1/job", &bus_job_vtable, m) ||
- !dbus_connection_add_filter(m->api_bus, api_bus_message_filter, m, NULL)) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ !dbus_connection_add_filter(m->api_bus, api_bus_message_filter, m, NULL))
+ return log_oom();
/* Get NameOwnerChange messages */
dbus_bus_add_match(m->api_bus,
return 0;
if (asprintf(&p, "unix:path=%s/systemd/private", e) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
if (!dbus_server_set_auth_mechanisms(m->private_bus, (const char**) external_only) ||
!dbus_server_set_watch_functions(m->private_bus, bus_add_watch, bus_remove_watch, bus_toggle_watch, m, NULL) ||
!dbus_server_set_timeout_functions(m->private_bus, bus_add_timeout, bus_remove_timeout, bus_toggle_timeout, m, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
return 0;
oom:
- log_error("Out of memory.");
- return -ENOMEM;
+ return log_oom();
}
static void shutdown_connection(Manager *m, DBusConnection *c) {
message = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartupFinished");
if (!message) {
- log_error("Out of memory.");
+ log_oom();
return;
}
DBUS_TYPE_UINT64, &userspace_usec,
DBUS_TYPE_UINT64, &total_usec,
DBUS_TYPE_INVALID)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
if (bus_broadcast(m, message) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
}
if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
if (m->running_as == MANAGER_SYSTEM && getpid() == 1) {
p = strappend("/run/systemd/", name);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
r = mkdir_p_label(p, 0755);
if (r < 0) {
}
} else {
p = strjoin("/tmp/systemd-", name, ".XXXXXX", NULL);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
if (!mkdtemp(p)) {
free(p);
t = strv_append(arg_proc_cmdline_disks, word + 10);
if (!t) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
strv_free(arg_proc_cmdline_disks);
t = strv_append(arg_proc_cmdline_disks, word + 13);
if (!t) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
strv_free(arg_proc_cmdline_disks);
device = strappend("UUID=", *i);
if (!name || !device) {
- log_error("Out of memory.");
+ log_oom();
r = EXIT_FAILURE;
free(name);
free(device);
l = strcspn(opt_cipher, "-");
if (!(truncated_cipher = strndup(opt_cipher, l))) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
char **p;
if (asprintf(&text, "Please enter passphrase for disk %s!", name) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
assert(strv_length(passwords) == 1);
if (asprintf(&text, "Please enter passphrase for disk %s! (verification)", name) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
/* Pad password if necessary */
if (!(c = new(char, opt_key_size))) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
}
if (!(udev = udev_new())) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
p = unit_name_from_path(path, ".device");
if (!p)
- return -ENOMEM;
+ return log_oom();
*unit = p;
return 1;
name = unit_name_from_path(what, ".swap");
if (!name) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
unit = strjoin(arg_dest, "/", name, NULL);
if (!unit) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (!noauto) {
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
if (!lnk) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
}
r = device_name(what, &device);
- if (r < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ if (r < 0)
goto finish;
- }
if (r > 0) {
free(lnk);
lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
if (!lnk) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
}
name = unit_name_from_path(where, ".mount");
- if (!name) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ if (!name) {
+ r = log_oom();
goto finish;
}
unit = strjoin(arg_dest, "/", name, NULL);
if (!unit) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (!noauto) {
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
if (!lnk) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
!path_equal(where, "/")) {
r = device_name(what, &device);
- if (r < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ if (r < 0)
goto finish;
- }
if (r > 0) {
free(lnk);
lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
if (!lnk) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
- log_error("Failed to creat symlink: %m");
+ log_error("Failed to create symlink: %m");
r = -errno;
goto finish;
}
if (automount && !path_equal(where, "/")) {
automount_name = unit_name_from_path(where, ".automount");
if (!name) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
automount_unit = strjoin(arg_dest, "/", automount_name, NULL);
if (!automount_unit) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
free(lnk);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
if (!lnk) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
what = fstab_node_to_udev_node(me->mnt_fsname);
if (!what) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
where = strdup(me->mnt_dir);
if (!where) {
- log_error("Out of memory.");
+ r = log_oom();
free(what);
- r = -ENOMEM;
goto finish;
}
word = strndup(w, l);
if (!word) {
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
to = strjoin(arg_dest,"/getty.target.wants/", tservice, NULL);
if (!from || !to) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
log_debug("Automatically adding serial getty for /dev/%s.", tty);
n = unit_name_replace_instance("serial-getty@.service", tty);
- if (!n) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!n)
+ return log_oom();
r = add_symlink("serial-getty@.service", n);
free(n);
int k;
if (asprintf(&p, "/sys/class/tty/%s", j) < 0) {
- log_error("Out of memory.");
+ log_oom();
r = EXIT_FAILURE;
goto finish;
}
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/hostname1", &hostname_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
arg_identifier = NULL;
else {
arg_identifier = strdup(optarg);
- if (!arg_identifier) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!arg_identifier)
+ return log_oom();
}
break;
p = malloc(9 + COREDUMP_MAX);
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
t = strappend("_EXE=", path);
if (!t) {
free(p);
- log_error("Out of memory.");
- return -ENOMEM;
+ return log_oom();
}
r = sd_journal_add_match(j, t, 0);
if (s->system_journal) {
if (asprintf(&p, "/var/log/journal/%s", ids) < 0) {
- log_error("Out of memory.");
+ log_oom();
return;
}
if (s->runtime_journal) {
if (asprintf(&p, "/run/log/journal/%s", ids) < 0) {
- log_error("Out of memory.");
+ log_oom();
return;
}
u = MAX((n+N_IOVEC_META_FIELDS+1) * 2U, 4U);
c = realloc(iovec, u * sizeof(struct iovec));
if (!c) {
- log_error("Out of memory.");
+ log_oom();
break;
}
k = malloc((e - p) + 1 + l);
if (!k) {
- log_error("Out of memory.");
+ log_oom();
break;
}
p = malloc(st.st_size);
if (!p) {
- log_error("Out of memory.");
+ log_oom();
return;
}
s->identifier = NULL;
else {
s->identifier = strdup(p);
- if (!s->identifier) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!s->identifier)
+ return log_oom();
}
s->state = STDOUT_STREAM_UNIT_ID;
s->unit_id = NULL;
else {
s->unit_id = strdup(p);
- if (!s->unit_id) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!s->unit_id)
+ return log_oom();
}
}
stream = new0(StdoutStream, 1);
if (!stream) {
- log_error("Out of memory.");
close_nointr_nofail(fd);
- return -ENOMEM;
+ return log_oom();
}
stream->fd = fd;
server_parse_proc_cmdline(s);
s->user_journals = hashmap_new(trivial_hash_func, trivial_compare_func);
- if (!s->user_journals) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!s->user_journals)
+ return log_oom();
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
l_set = new0(char*, _PROP_MAX);
l_unset = new0(char*, _PROP_MAX);
if (!l_set || !l_unset) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
char *s;
if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
dbus_message_iter_init_append(m, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
STRV_FOREACH(t, l_unset)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub) ||
!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
STRV_FOREACH(t, l_set)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub)) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
}
p = strappend("/dev/input/", b->name);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
free(p);
k = strspn(s->display+1, "0123456789");
f = new(char, sizeof("/tmp/.X11-unix/X") + k);
- if (!f) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!f)
+ return log_oom();
c = stpcpy(f, "/tmp/.X11-unix/X");
memcpy(c, s->display+1, k);
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
- log_error("Out of memory.");
free(f);
- return -ENOMEM;
+ return log_oom();
}
if (link(f, t) < 0) {
assert(s->user->cgroup_path);
if (!s->cgroup_path) {
- if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0)
+ return log_oom();
} else
p = s->cgroup_path;
s->user->display = NULL;
t = strappend(s->user->runtime_path, "/X11-display");
- if (!t) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!t)
+ return log_oom();
r = unlink(t);
free(t);
}
if (!u->runtime_path) {
- if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0)
+ return log_oom();
} else
p = u->runtime_path;
assert(u);
if (!u->cgroup_path) {
- if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0)
+ return log_oom();
} else
p = u->cgroup_path;
}
p = strdup(cgroup);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
for (;;) {
char *e;
}
p = strdup(cgroup);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
for (;;) {
char *e;
!dbus_connection_register_fallback(m->bus, "/org/freedesktop/login1/session", &bus_session_vtable, m) ||
!dbus_connection_register_fallback(m->bus, "/org/freedesktop/login1/user", &bus_user_vtable, m) ||
!dbus_connection_add_filter(m->bus, bus_message_filter, m, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
m = manager_new();
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
device_node = strdup(dn);
if (!device_node) {
udev_device_unref(d);
- log_error("Out of memory.");
+ log_oom();
goto fail;
}
}
path = strappend("/run/systemd/multi-session-x/", seat);
if (!path) {
- log_error("Out of memory.");
+ log_oom();
goto fail;
}
char **t, **k;
k = strv_split(p, ",");
- if (!k) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!k)
+ return log_oom();
t = strv_merge(arg_proc_cmdline_modules, k);
strv_free(k);
- if (!t) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!t)
+ return log_oom();
strv_free(arg_proc_cmdline_modules);
arg_proc_cmdline_modules = t;
char *t;
t = strndup(word, length);
- if (!t) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!t)
+ return log_oom();
if (cap_from_name(t, &cap) < 0) {
log_error("Failed to parse capability %s.", t);
int t;
if (asprintf(&where, "%s/%s", dest, mount_table[k].where) < 0) {
- log_error("Out of memory.");
+ log_oom();
if (r == 0)
r = -ENOMEM;
assert(dest);
/* Fix the timezone, if possible */
- if (asprintf(&where, "%s/etc/localtime", dest) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&where, "%s/etc/localtime", dest) < 0)
+ return log_oom();
if (mount("/etc/localtime", where, "bind", MS_BIND, NULL) >= 0)
mount("/etc/localtime", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
free(where);
- if (asprintf(&where, "%s/etc/timezone", dest) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&where, "%s/etc/timezone", dest) < 0)
+ return log_oom();
if (mount("/etc/timezone", where, "bind", MS_BIND, NULL) >= 0)
mount("/etc/timezone", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
/* Fix resolv.conf, if possible */
if (asprintf(&where, "%s/etc/resolv.conf", dest) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
+ return log_oom();
}
if (mount("/etc/resolv.conf", where, "bind", MS_BIND, NULL) >= 0)
}
if (asprintf(&to, "%s/dev/console", dest) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
* avoid any problems with containers deadlocking due to this
* we simply make /dev/kmsg unavailable to the container. */
if (asprintf(&from, "%s/dev/kmsg", dest) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (asprintf(&to, "%s/proc/kmsg", dest) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
p = strappend(directory, "/etc/machine-id");
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
p = strappend("/var/log/journal/", l);
q = strjoin(directory, "/var/log/journal/", l, NULL);
if (!p || !q) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if ((asprintf((char**)(envp + 3), "HOME=%s", home ? home: "/root") < 0) ||
(asprintf((char**)(envp + 4), "USER=%s", arg_user ? arg_user : "root") < 0) ||
(asprintf((char**)(envp + 5), "LOGNAME=%s", arg_user ? arg_user : "root") < 0)) {
- log_error("Out of memory.");
+ log_oom();
goto child_fail;
}
if (arg_uuid) {
if (asprintf((char**)(envp + 6), "container_uuid=%s", arg_uuid) < 0) {
- log_error("Out of memory.");
+ log_oom();
goto child_fail;
}
}
asprintf(&to, "%s/%s.wants/%s", arg_dest, where, service);
if (!from || !to) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
assert(root);
if (asprintf(&pack_fn, "%s/.readahead", root) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
log_debug("On btrfs: %s", yes_no(on_btrfs));
if (asprintf(&pack_fn_new, "%s/.readahead.new", root) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
n = hashmap_size(files);
if (!(ordered = new(struct item, n))) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
block_bump_request_nr(root);
if (asprintf(&pack_fn, "%s/.readahead", root) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
s = strdup(me->mnt_dir);
if (!s) {
- log_error("Out of memory.");
+ log_oom();
ret = EXIT_FAILURE;
continue;
}
}
if (!(c = strdup(sa.un.sun_path))) {
- r = -ENOMEM;
- log_error("Out of memory.");
+ r = log_oom();
goto fail;
}
return;
oom:
- log_error("Out of memory.");
+ log_oom();
if (pending) {
dbus_pending_call_cancel(pending);
#include <syslog.h>
#include <stdbool.h>
#include <stdarg.h>
+#include <errno.h>
#include "macro.h"
#define log_warning(...) log_meta(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define log_error(...) log_meta(LOG_ERR, __FILE__, __LINE__, __func__, __VA_ARGS__)
+static inline int log_oom(void) {
+ log_error("Out of memory.");
+ return -ENOMEM;
+}
+
/* This modifies the buffer passed! */
#define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)
buf = malloc(nl+1);
memcpy(buf, (const char*) data + fl, nl);
((char*)buf)[nl] = 0;
- if (!buf) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!buf)
+ return log_oom();
free(*target);
*target = buf;
continue;
if (!(u = normalize_env_assignment(p))) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
free(u);
if (!t) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
continue;
if (asprintf(&path, "%s/%s", directory, de->d_name) < 0) {
- log_error("Out of memory.");
+ log_oom();
continue;
}
}
t = cescape(c->wall_message);
- if (!t) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!t)
+ return log_oom();
r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path);
if (r < 0) {
log_debug("Setting '%s' to '%s'", property, value);
p = new(char, sizeof(PROC_SYS_PREFIX) + strlen(property));
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
n = stpcpy(p, PROC_SYS_PREFIX);
strcpy(n, property);
*p = '/';
l = strv_append(arg_prefixes, optarg);
- if (!l) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!l)
+ return log_oom();
strv_free(arg_prefixes);
arg_prefixes = l;
}
p = strappend(arg_dest, "/default.target");
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0) {
free(p);
Iterator i;
h = hashmap_new(string_hash_func, string_compare_func);
- if (!h) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!h)
+ return log_oom();
r = unit_file_get_list(arg_scope, arg_root, h);
if (r < 0) {
units = new(UnitFileList, n_units);
if (!units) {
unit_file_list_free(h);
- log_error("Out of memory.");
- return -ENOMEM;
+ return log_oom();
}
HASHMAP_FOREACH(u, h, i) {
if (e) {
page = strndup((*p) + 4, e - *p - 4);
if (!page) {
- log_error("Out of memory.");
+ log_oom();
return;
}
section = strndup(e + 1, *p + k - e - 2);
if (!section) {
free(page);
- log_error("Out of memory.");
+ log_oom();
return;
}
n = unit_name_mangle(*name);
p = unit_dbus_path_from_name(n ? n : *name);
free(n);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
r = show_one(args[0], bus, p, show_properties, &new_line);
free(p);
/* Interpret as job id */
char *p;
- if (asprintf(&p, "/org/freedesktop/systemd1/job/%u", id) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "/org/freedesktop/systemd1/job/%u", id) < 0)
+ return log_oom();
r = show_one(args[0], bus, p, show_properties, &new_line);
free(p);
asprintf(&p, "%s/%s", *k, name);
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
else
asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
l = strv_join((char**)argv, " ");
if (!l) {
- log_error("Out of memory.");
free(q);
free(p);
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
"org.freedesktop.systemd1.Manager",
method);
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
"org.freedesktop.systemd1.Manager",
"GetUnitFileState");
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
p = strappend("/usr/share/zoneinfo/", tz.zone);
if (!p) {
- log_error("Out of memory.");
+ log_oom();
return;
}
}
p = strappend("/usr/share/zoneinfo/", tz.zone);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
r = symlink_or_copy_atomic(p, "/etc/localtime");
free(p);
q = strv_append(r, l);
if (!q) {
- log_error("Out of memory.");
+ log_oom();
break;
}
"org.freedesktop.systemd1.Manager",
"GetUnitFileState");
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (!dbus_message_append_args(m,
DBUS_TYPE_STRING, i,
DBUS_TYPE_INVALID)) {
- log_error("Could not append arguments to message.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/timedate1", &timedate_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
sub_path = NULL;
if (asprintf(&sub_path, "%s/%s", p, dent->d_name) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
assert(buffer);
i = new0(Item, 1);
- if (!i) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!i)
+ return log_oom();
if (sscanf(buffer,
"%c "
n += strspn(buffer+n, WHITESPACE);
if (buffer[n] != 0 && (buffer[n] != '-' || buffer[n+1] != 0)) {
i->argument = unquote(buffer+n, "\"");
- if (!i->argument) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!i->argument)
+ return log_oom();
}
}
STRV_FOREACH(p, search_paths) {
resolved_path = strjoin(*p, "/", fragment, NULL);
if (resolved_path == NULL) {
- log_error("Out of memory.");
+ log_oom();
return NULL;
}
globs = hashmap_new(string_hash_func, string_compare_func);
if (!items || !globs) {
- log_error("Out of memory.");
+ log_oom();
r = EXIT_FAILURE;
goto finish;
}
*wall ? "\r\n\r\n" : "",
message,
pid) < 0) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
continue;
if (!(p = strappend("/run/systemd/ask-password/", de->d_name))) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
buffer = malloc(MAX_BUFFER_LEN);
if (!buffer) {
fclose(fd);
- log_error("Out of memory.");
- return -1;
+ return log_oom();
}
*newargv = NULL;
if (str1 && strcasecmp(str1, "VENDOR") == 0) {
str1 = get_value(&buf);
if (!str1) {
- retval = -1;
+ retval = log_oom();
break;
}
vendor_in = str1;
if (str1 && strcasecmp(str1, "MODEL") == 0) {
str1 = get_value(&buf);
if (!str1) {
- retval = -1;
+ retval = log_oom();
break;
}
model_in = str1;
if (str1 && strcasecmp(str1, "OPTIONS") == 0) {
str1 = get_value(&buf);
if (!str1) {
- retval = -1;
+ retval = log_oom();
break;
}
options_in = str1;
c = argc_count(buffer) + 2;
*newargv = calloc(c, sizeof(**newargv));
if (!*newargv) {
- log_error("Out of memory.");
- retval = -1;
+ retval = log_oom();
} else {
*argc = c;
c = 0;
t = strdup("/etc/sysconfig/console/default.kmap");
if (!t) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
free(vc_keytable);
if (!vc_keymap) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
}
t = strdup("/etc/sysconfig/console/default.kmap");
if (!t) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}