summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorShawn Landden <shawnlandden@gmail.com>2012-07-25 14:55:59 -0700
committerKay Sievers <kay@vrfy.org>2012-07-26 11:48:26 +0200
commit0d0f0c50d3a1d90f03972a6abb82e6413daaa583 (patch)
tree74f41c8455dbd78599f49300315a2569a8989992 /src/systemctl
parente146e4516b9ea9907852e7ad609de39dca9e8769 (diff)
log.h: new log_oom() -> int -ENOMEM, use it
also a number of minor fixups and bug fixes: spelling, oom errors that didn't print errors, not properly forwarding error codes, few more consistency issues, et cetera
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d493733761..ef8ab2dc14 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -657,10 +657,8 @@ static int list_unit_files(DBusConnection *bus, char **args) {
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) {
@@ -673,8 +671,7 @@ static int list_unit_files(DBusConnection *bus, char **args) {
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) {
@@ -2630,14 +2627,14 @@ static void show_unit_help(UnitStatusInfo *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;
}
@@ -3282,10 +3279,8 @@ static int show(DBusConnection *bus, char **args) {
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);
@@ -3298,10 +3293,8 @@ static int show(DBusConnection *bus, char **args) {
/* 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);
@@ -3974,8 +3967,7 @@ static int enable_sysv_units(char **args) {
asprintf(&p, "%s/%s", *k, name);
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
@@ -3995,8 +3987,7 @@ static int enable_sysv_units(char **args) {
else
asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
if (!p) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
@@ -4024,10 +4015,9 @@ static int enable_sysv_units(char **args) {
l = strv_join((char**)argv, " ");
if (!l) {
- log_error("Out of memory.");
free(q);
free(p);
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
@@ -4184,8 +4174,7 @@ static int enable_unit(DBusConnection *bus, char **args) {
"org.freedesktop.systemd1.Manager",
method);
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
@@ -4339,8 +4328,7 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
"org.freedesktop.systemd1.Manager",
"GetUnitFileState");
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}