mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-25 23:21:33 +03:00
coverity: change a few things so that coverity doesn't show so many false positives
This commit is contained in:
parent
8ea913b2ea
commit
f8440af5fe
@ -300,7 +300,7 @@ static int bus_manager_append_tainted(DBusMessageIter *i, const char *property,
|
||||
free(p);
|
||||
|
||||
if (access("/proc/cgroups", F_OK) < 0)
|
||||
e = stpcpy(e, "cgroups-missing ");
|
||||
stpcpy(e, "cgroups-missing ");
|
||||
|
||||
t = strstrip(buf);
|
||||
|
||||
|
@ -233,7 +233,7 @@ static int write_data_other(void) {
|
||||
assert(name[p]);
|
||||
|
||||
if (isempty(data[p])) {
|
||||
l = strv_env_unset(l, name[p]);
|
||||
strv_env_unset(l, name[p]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1904,7 +1904,7 @@ int unit_file_get_list(
|
||||
} else if (r > 0) {
|
||||
f->state = UNIT_FILE_DISABLED;
|
||||
goto found;
|
||||
} else if (r == 0) {
|
||||
} else {
|
||||
f->state = UNIT_FILE_STATIC;
|
||||
goto found;
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ static bool on_tty(void) {
|
||||
}
|
||||
|
||||
static void pager_open_if_enabled(void) {
|
||||
|
||||
/* Cache result before we open the pager */
|
||||
on_tty();
|
||||
|
||||
if (!arg_no_pager)
|
||||
@ -1146,7 +1148,7 @@ finish:
|
||||
}
|
||||
|
||||
static int activate(DBusConnection *bus, char **args, unsigned n) {
|
||||
DBusMessage *m = NULL, *reply = NULL;
|
||||
DBusMessage *m = NULL;
|
||||
int ret = 0;
|
||||
DBusError error;
|
||||
unsigned i;
|
||||
@ -1157,6 +1159,8 @@ static int activate(DBusConnection *bus, char **args, unsigned n) {
|
||||
dbus_error_init(&error);
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
|
||||
m = dbus_message_new_method_call(
|
||||
"org.freedesktop.login1",
|
||||
"/org/freedesktop/login1",
|
||||
@ -1195,16 +1199,13 @@ finish:
|
||||
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;
|
||||
@ -1218,6 +1219,8 @@ static int kill_session(DBusConnection *bus, char **args, unsigned n) {
|
||||
arg_kill_who = "all";
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
|
||||
m = dbus_message_new_method_call(
|
||||
"org.freedesktop.login1",
|
||||
"/org/freedesktop/login1",
|
||||
@ -1255,16 +1258,13 @@ finish:
|
||||
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;
|
||||
@ -1278,6 +1278,7 @@ static int enable_linger(DBusConnection *bus, char **args, unsigned n) {
|
||||
b = streq(args[0], "enable-linger");
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
uint32_t u;
|
||||
uid_t uid;
|
||||
|
||||
@ -1327,16 +1328,13 @@ finish:
|
||||
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;
|
||||
@ -1349,6 +1347,7 @@ static int terminate_user(DBusConnection *bus, char **args, unsigned n) {
|
||||
for (i = 1; i < n; i++) {
|
||||
uint32_t u;
|
||||
uid_t uid;
|
||||
DBusMessage *reply;
|
||||
|
||||
m = dbus_message_new_method_call(
|
||||
"org.freedesktop.login1",
|
||||
@ -1394,16 +1393,13 @@ finish:
|
||||
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;
|
||||
@ -1417,6 +1413,7 @@ static int kill_user(DBusConnection *bus, char **args, unsigned n) {
|
||||
arg_kill_who = "all";
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
uid_t uid;
|
||||
uint32_t u;
|
||||
|
||||
@ -1465,16 +1462,13 @@ finish:
|
||||
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;
|
||||
@ -1486,6 +1480,8 @@ static int attach(DBusConnection *bus, char **args, unsigned n) {
|
||||
dbus_error_init(&error);
|
||||
|
||||
for (i = 2; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
|
||||
m = dbus_message_new_method_call(
|
||||
"org.freedesktop.login1",
|
||||
"/org/freedesktop/login1",
|
||||
@ -1523,9 +1519,6 @@ finish:
|
||||
if (m)
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
return ret;
|
||||
@ -1581,7 +1574,7 @@ finish:
|
||||
}
|
||||
|
||||
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;
|
||||
@ -1592,6 +1585,8 @@ static int terminate_seat(DBusConnection *bus, char **args, unsigned n) {
|
||||
dbus_error_init(&error);
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
DBusMessage *reply;
|
||||
|
||||
m = dbus_message_new_method_call(
|
||||
"org.freedesktop.login1",
|
||||
"/org/freedesktop/login1",
|
||||
@ -1627,9 +1622,6 @@ finish:
|
||||
if (m)
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
return ret;
|
||||
|
@ -197,8 +197,10 @@ static int mount_all(const char *dest) {
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,8 @@ void strv_free(char **l) {
|
||||
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)
|
||||
@ -198,7 +199,8 @@ char **strv_merge_concat(char **a, char **b, const char *suffix) {
|
||||
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;
|
||||
@ -324,7 +326,8 @@ char **strv_append(char **l, const char *s) {
|
||||
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++)
|
||||
|
@ -137,6 +137,8 @@ static bool on_tty(void) {
|
||||
}
|
||||
|
||||
static void pager_open_if_enabled(void) {
|
||||
|
||||
/* Cache result before we open the pager */
|
||||
on_tty();
|
||||
|
||||
if (arg_no_pager)
|
||||
@ -1055,7 +1057,7 @@ finish:
|
||||
}
|
||||
|
||||
static int load_unit(DBusConnection *bus, char **args) {
|
||||
DBusMessage *m = NULL, *reply = NULL;
|
||||
DBusMessage *m = NULL;
|
||||
DBusError error;
|
||||
int r;
|
||||
char **name;
|
||||
@ -1066,6 +1068,7 @@ static int load_unit(DBusConnection *bus, char **args) {
|
||||
assert(args);
|
||||
|
||||
STRV_FOREACH(name, args+1) {
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!(m = dbus_message_new_method_call(
|
||||
"org.freedesktop.systemd1",
|
||||
@ -1103,9 +1106,6 @@ finish:
|
||||
if (m)
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
return r;
|
||||
@ -1795,7 +1795,7 @@ finish:
|
||||
}
|
||||
|
||||
static int kill_unit(DBusConnection *bus, char **args) {
|
||||
DBusMessage *m = NULL, *reply = NULL;
|
||||
DBusMessage *m = NULL;
|
||||
int r = 0;
|
||||
DBusError error;
|
||||
char **name;
|
||||
@ -1812,6 +1812,7 @@ static int kill_unit(DBusConnection *bus, char **args) {
|
||||
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",
|
||||
@ -1851,9 +1852,6 @@ finish:
|
||||
if (m)
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
return r;
|
||||
@ -3231,7 +3229,7 @@ finish:
|
||||
}
|
||||
|
||||
static int reset_failed(DBusConnection *bus, char **args) {
|
||||
DBusMessage *m = NULL, *reply = NULL;
|
||||
DBusMessage *m = NULL;
|
||||
int r;
|
||||
DBusError error;
|
||||
char **name;
|
||||
@ -3243,6 +3241,7 @@ static int reset_failed(DBusConnection *bus, char **args) {
|
||||
return daemon_reload(bus, args);
|
||||
|
||||
STRV_FOREACH(name, args+1) {
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!(m = dbus_message_new_method_call(
|
||||
"org.freedesktop.systemd1",
|
||||
@ -3279,9 +3278,6 @@ finish:
|
||||
if (m)
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
return r;
|
||||
|
@ -782,13 +782,7 @@ int read_full_file(const char *fn, char **contents, size_t *size) {
|
||||
}
|
||||
}
|
||||
|
||||
if (buf)
|
||||
buf[l] = 0;
|
||||
else if (!(buf = calloc(1, 1))) {
|
||||
r = -errno;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
buf[l] = 0;
|
||||
*contents = buf;
|
||||
buf = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user