Unverified Commit bbb97736 by Serge Hallyn Committed by GitHub

Merge pull request #2409 from brauner/2018-06-15/coverity

coverity
parents 1c605abd 64b0e15a
...@@ -1541,16 +1541,11 @@ static int lxc_setup_devpts(struct lxc_conf *conf) ...@@ -1541,16 +1541,11 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
if (ret < 0 || (size_t)ret >= sizeof(devpts_mntopts)) if (ret < 0 || (size_t)ret >= sizeof(devpts_mntopts))
return -1; return -1;
/* Unmount old devpts instance. */ ret = umount2("/dev/pts", MNT_DETACH);
ret = access("/dev/pts/ptmx", F_OK); if (ret < 0)
if (!ret) { WARN("%s - Failed to unmount old devpts instance", strerror(errno));
ret = umount("/dev/pts"); else
if (ret < 0) {
SYSERROR("Failed to unmount old devpts instance");
return -1;
}
DEBUG("Unmounted old devpts instance"); DEBUG("Unmounted old devpts instance");
}
/* Create mountpoint for devpts instance. */ /* Create mountpoint for devpts instance. */
ret = mkdir("/dev/pts", 0755); ret = mkdir("/dev/pts", 0755);
......
...@@ -2625,7 +2625,10 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc ...@@ -2625,7 +2625,10 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
n = fscanf(f1, "%d", &v); n = fscanf(f1, "%d", &v);
fclose(f1); fclose(f1);
if (n == 1 && v == 0) { if (n == 1 && v == 0) {
remove(path); ret = remove(path);
if (ret < 0)
ERROR("%s - Failed to remove \"%s\"",
strerror(errno), path);
n = 0; n = 0;
} }
} }
......
...@@ -178,6 +178,7 @@ static void print_net_stats(struct lxc_container *c) ...@@ -178,6 +178,7 @@ static void print_net_stats(struct lxc_container *c)
rc = lxc_read_from_file(path, buf, sizeof(buf)); rc = lxc_read_from_file(path, buf, sizeof(buf));
if (rc > 0) { if (rc > 0) {
buf[rc - 1] = '\0';
str_chomp(buf); str_chomp(buf);
rx_bytes = str_size_humanize(buf, sizeof(buf)); rx_bytes = str_size_humanize(buf, sizeof(buf));
printf("%-15s %s\n", " TX bytes:", buf); printf("%-15s %s\n", " TX bytes:", buf);
...@@ -190,6 +191,7 @@ static void print_net_stats(struct lxc_container *c) ...@@ -190,6 +191,7 @@ static void print_net_stats(struct lxc_container *c)
rc = lxc_read_from_file(path, buf, sizeof(buf)); rc = lxc_read_from_file(path, buf, sizeof(buf));
if (rc > 0) { if (rc > 0) {
buf[rc - 1] = '\0';
str_chomp(buf); str_chomp(buf);
tx_bytes = str_size_humanize(buf, sizeof(buf)); tx_bytes = str_size_humanize(buf, sizeof(buf));
printf("%-15s %s\n", " RX bytes:", buf); printf("%-15s %s\n", " RX bytes:", buf);
......
...@@ -819,8 +819,8 @@ static void ls_print_fancy_format(struct ls *l, struct lengths *lht, ...@@ -819,8 +819,8 @@ static void ls_print_fancy_format(struct ls *l, struct lengths *lht,
strcasecmp(*s, "GROUPS") && strcasecmp(*s, "INTERFACE") && strcasecmp(*s, "GROUPS") && strcasecmp(*s, "INTERFACE") &&
strcasecmp(*s, "IPV4") && strcasecmp(*s, "IPV6") && strcasecmp(*s, "IPV4") && strcasecmp(*s, "IPV6") &&
strcasecmp(*s, "UNPRIVILEGED")) { strcasecmp(*s, "UNPRIVILEGED")) {
lxc_free_array((void **)tmp, free);
fprintf(stderr, "Invalid key: %s\n", *s); fprintf(stderr, "Invalid key: %s\n", *s);
lxc_free_array((void **)tmp, free);
return; return;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment