free(p);
if (access("/proc/cgroups", F_OK) < 0)
- e = stpcpy(e, "cgroups-missing ");
+ stpcpy(e, "cgroups-missing ");
t = strstrip(buf);
assert(name[p]);
if (isempty(data[p])) {
- l = strv_env_unset(l, name[p]);
+ strv_env_unset(l, name[p]);
continue;
}
} else if (r > 0) {
f->state = UNIT_FILE_DISABLED;
goto found;
- } else if (r == 0) {
+ } else {
f->state = UNIT_FILE_STATIC;
goto found;
}
}
static void pager_open_if_enabled(void) {
+
+ /* Cache result before we open the pager */
on_tty();
if (!arg_no_pager)
}
static int activate(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
dbus_error_init(&error);
for (i = 1; i < n; i++) {
+ DBusMessage *reply;
+
m = dbus_message_new_method_call(
"org.freedesktop.login1",
"/org/freedesktop/login1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int kill_session(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
arg_kill_who = "all";
for (i = 1; i < n; i++) {
+ DBusMessage *reply;
+
m = dbus_message_new_method_call(
"org.freedesktop.login1",
"/org/freedesktop/login1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int enable_linger(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
b = streq(args[0], "enable-linger");
for (i = 1; i < n; i++) {
+ DBusMessage *reply;
uint32_t u;
uid_t uid;
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int terminate_user(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
for (i = 1; i < n; i++) {
uint32_t u;
uid_t uid;
+ DBusMessage *reply;
m = dbus_message_new_method_call(
"org.freedesktop.login1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int kill_user(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
arg_kill_who = "all";
for (i = 1; i < n; i++) {
+ DBusMessage *reply;
uid_t uid;
uint32_t u;
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int attach(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
dbus_error_init(&error);
for (i = 2; i < n; i++) {
+ DBusMessage *reply;
+
m = dbus_message_new_method_call(
"org.freedesktop.login1",
"/org/freedesktop/login1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
}
static int terminate_seat(DBusConnection *bus, char **args, unsigned n) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int ret = 0;
DBusError error;
unsigned i;
dbus_error_init(&error);
for (i = 1; i < n; i++) {
+ DBusMessage *reply;
+
m = dbus_message_new_method_call(
"org.freedesktop.login1",
"/org/freedesktop/login1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return ret;
/* Fix the timezone, if possible */
if (asprintf(&where, "%s/%s", dest, "/etc/localtime") >= 0) {
- mount("/etc/localtime", where, "bind", MS_BIND, NULL);
- mount("/etc/localtime", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
+
+ if (mount("/etc/localtime", where, "bind", MS_BIND, NULL) >= 0)
+ mount("/etc/localtime", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
+
free(where);
}
char **strv_copy(char **l) {
char **r, **k;
- if (!(k = r = new(char*, strv_length(l)+1)))
+ k = r = new(char*, strv_length(l)+1);
+ if (!k)
return NULL;
if (l)
if (!b)
return strv_copy(a);
- if (!(r = new(char*, strv_length(a)+strv_length(b)+1)))
+ r = new(char*, strv_length(a) + strv_length(b) + 1);
+ if (!r)
return NULL;
k = r;
if (!s)
return strv_copy(l);
- if (!(r = new(char*, strv_length(l)+2)))
+ r = new(char*, strv_length(l)+2);
+ if (!r)
return NULL;
for (k = r; *l; k++, l++)
}
static void pager_open_if_enabled(void) {
+
+ /* Cache result before we open the pager */
on_tty();
if (arg_no_pager)
}
static int load_unit(DBusConnection *bus, char **args) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
DBusError error;
int r;
char **name;
assert(args);
STRV_FOREACH(name, args+1) {
+ DBusMessage *reply;
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return r;
}
static int kill_unit(DBusConnection *bus, char **args) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int r = 0;
DBusError error;
char **name;
arg_kill_mode = streq(arg_kill_who, "all") ? "control-group" : "process";
STRV_FOREACH(name, args+1) {
+ DBusMessage *reply;
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return r;
}
static int reset_failed(DBusConnection *bus, char **args) {
- DBusMessage *m = NULL, *reply = NULL;
+ DBusMessage *m = NULL;
int r;
DBusError error;
char **name;
return daemon_reload(bus, args);
STRV_FOREACH(name, args+1) {
+ DBusMessage *reply;
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
if (m)
dbus_message_unref(m);
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return r;
}
}
- if (buf)
- buf[l] = 0;
- else if (!(buf = calloc(1, 1))) {
- r = -errno;
- goto finish;
- }
-
+ buf[l] = 0;
*contents = buf;
buf = NULL;