[lxc-devel] [lxc/master] tree-wide: bugfixes
brauner on Github
lxc-bot at linuxcontainers.org
Sat Oct 20 09:51:14 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181020/df10fdfa/attachment.bin>
-------------- next part --------------
From f1028c6ca904edaed018acb398cfa080a72b298d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:03:41 +0200
Subject: [PATCH 01/16] confile: do not overwrite global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/confile.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 5f1485a79..68d36489e 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -156,7 +156,7 @@ lxc_config_define(uts_name);
lxc_config_define(sysctl);
lxc_config_define(proc);
-static struct lxc_config_t config[] = {
+static struct lxc_config_t config_jump_table[] = {
{ "lxc.arch", set_config_personality, get_config_personality, clr_config_personality, },
{ "lxc.apparmor.profile", set_config_apparmor_profile, get_config_apparmor_profile, clr_config_apparmor_profile, },
{ "lxc.apparmor.allow_incomplete", set_config_apparmor_allow_incomplete, get_config_apparmor_allow_incomplete, clr_config_apparmor_allow_incomplete, },
@@ -246,15 +246,15 @@ static struct lxc_config_t config[] = {
{ "lxc.proc", set_config_proc, get_config_proc, clr_config_proc, },
};
-static const size_t config_size = sizeof(config) / sizeof(struct lxc_config_t);
+static const size_t config_jump_table_size = sizeof(config_jump_table) / sizeof(struct lxc_config_t);
struct lxc_config_t *lxc_get_config(const char *key)
{
size_t i;
- for (i = 0; i < config_size; i++)
- if (!strncmp(config[i].name, key, strlen(config[i].name)))
- return &config[i];
+ for (i = 0; i < config_jump_table_size; i++)
+ if (!strncmp(config_jump_table[i].name, key, strlen(config_jump_table[i].name)))
+ return &config_jump_table[i];
return NULL;
}
@@ -5190,8 +5190,8 @@ int lxc_list_config_items(char *retv, int inlen)
else
memset(retv, 0, inlen);
- for (i = 0; i < config_size; i++) {
- char *s = config[i].name;
+ for (i = 0; i < config_jump_table_size; i++) {
+ char *s = config_jump_table[i].name;
if (s[strlen(s) - 1] == '.')
continue;
From 0886ebd54b3f729a15241c1e09e4fc74fa1d2711 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:09:54 +0200
Subject: [PATCH 02/16] commands: simplify
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/commands.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index 5c2ce04fe..1d3c2eaef 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -299,14 +299,9 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
SYSTRACE("Command \"%s\" failed to connect command socket",
lxc_cmd_str(cmd->req.cmd));
- if (errno == ECONNREFUSED)
+ if (errno == ECONNREFUSED || errno == EPIPE)
*stopped = 1;
- if (errno == EPIPE) {
- *stopped = 1;
- client_fd = 0;
- }
-
return -1;
}
@@ -314,12 +309,12 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
if (ret < 0 && errno == ECONNRESET)
*stopped = 1;
- if (!stay_connected || ret <= 0)
- if (client_fd >= 0) {
- saved_errno = errno;
- close(client_fd);
- errno = saved_errno;
- }
+ if (!stay_connected || ret <= 0) {
+ saved_errno = errno;
+ close(client_fd);
+ errno = saved_errno;
+ return ret;
+ }
if (stay_connected && ret > 0)
cmd->rsp.ret = client_fd;
From 907c33f58044a266129697afb4f3ba13235cdea1 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:13:59 +0200
Subject: [PATCH 03/16] cgfsng: move increment out of branch
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/cgroups/cgfsng.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 1a722ae2f..43403ce42 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2133,7 +2133,8 @@ static int __cg_unified_attach(const struct hierarchy *h, const char *name,
if (errno != EBUSY)
goto on_error;
- } while (++idx > 0 && idx < 1000);
+ idx++;
+ } while (idx < 1000);
on_success:
if (idx < 1000)
From b59a81cd76219f5c056193c41f4a3c22a7b006af Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:22:02 +0200
Subject: [PATCH 04/16] monitord: do not hide global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/cmd/lxc_monitord.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/lxc/cmd/lxc_monitord.c b/src/lxc/cmd/lxc_monitord.c
index 13158d7b2..f8312998b 100644
--- a/src/lxc/cmd/lxc_monitord.c
+++ b/src/lxc/cmd/lxc_monitord.c
@@ -80,7 +80,7 @@ struct lxc_monitor {
struct lxc_epoll_descr descr;
};
-static struct lxc_monitor mon;
+static struct lxc_monitor monitor;
static int quit;
static int lxc_monitord_fifo_create(struct lxc_monitor *mon)
@@ -349,7 +349,7 @@ static int lxc_monitord_mainloop_add(struct lxc_monitor *mon)
static void lxc_monitord_cleanup(void)
{
- lxc_monitord_delete(&mon);
+ lxc_monitord_delete(&monitor);
}
static void lxc_monitord_sig_handler(int sig)
@@ -415,15 +415,15 @@ int main(int argc, char *argv[])
ret = EXIT_FAILURE;
- memset(&mon, 0, sizeof(mon));
- mon.lxcpath = lxcpath;
- if (lxc_mainloop_open(&mon.descr)) {
+ memset(&monitor, 0, sizeof(monitor));
+ monitor.lxcpath = lxcpath;
+ if (lxc_mainloop_open(&monitor.descr)) {
ERROR("Failed to create mainloop");
goto on_error;
}
mainloop_opened = true;
- if (lxc_monitord_create(&mon))
+ if (lxc_monitord_create(&monitor))
goto on_error;
monitord_created = true;
@@ -437,22 +437,22 @@ int main(int argc, char *argv[])
;
close(pipefd);
- if (lxc_monitord_mainloop_add(&mon)) {
+ if (lxc_monitord_mainloop_add(&monitor)) {
ERROR("Failed to add mainloop handlers");
goto on_error;
}
NOTICE("lxc-monitord with pid %d is now monitoring lxcpath %s",
- lxc_raw_getpid(), mon.lxcpath);
+ lxc_raw_getpid(), monitor.lxcpath);
for (;;) {
- ret = lxc_mainloop(&mon.descr, 1000 * 30);
+ ret = lxc_mainloop(&monitor.descr, 1000 * 30);
if (ret) {
ERROR("mainloop returned an error");
break;
}
- if (mon.clientfds_cnt <= 0) {
+ if (monitor.clientfds_cnt <= 0) {
NOTICE("No remaining clients. lxc-monitord is exiting");
break;
}
@@ -471,7 +471,7 @@ int main(int argc, char *argv[])
lxc_monitord_cleanup();
if (mainloop_opened)
- lxc_mainloop_close(&mon.descr);
+ lxc_mainloop_close(&monitor.descr);
exit(ret);
}
From c298384054adf2c08f2955b92c953d43de93e696 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:23:55 +0200
Subject: [PATCH 05/16] tools/lxc_copy: do not hide global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_copy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c
index 3492be99f..76af22646 100644
--- a/src/lxc/tools/lxc_copy.c
+++ b/src/lxc/tools/lxc_copy.c
@@ -87,7 +87,7 @@ static const struct option my_longopts[] = {
};
/* mount keys */
-static char *const keys[] = {
+static char *const mount_keys[] = {
[LXC_MNT_BIND] = "bind",
[LXC_MNT_OVL] = "overlay",
NULL
@@ -568,7 +568,7 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
break;
case 'm':
subopts = optarg;
- if (parse_mntsubopts(subopts, keys, mntparameters) < 0)
+ if (parse_mntsubopts(subopts, mount_keys, mntparameters) < 0)
return -1;
break;
case 'B':
From 659bc68abe878202ab2a0cb5136a26b966ea591e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:28:11 +0200
Subject: [PATCH 06/16] tools/lxc_top: do not hide global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_top.c | 58 ++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/lxc/tools/lxc_top.c b/src/lxc/tools/lxc_top.c
index 9fad3a433..41ff10139 100644
--- a/src/lxc/tools/lxc_top.c
+++ b/src/lxc/tools/lxc_top.c
@@ -73,7 +73,7 @@ struct stats {
struct blkio_stats io_serviced;
};
-struct ct {
+struct container_stats {
struct lxc_container *c;
struct stats *stats;
};
@@ -84,7 +84,7 @@ static int delay = 3;
static char sort_by = 'n';
static int sort_reverse = 0;
static struct termios oldtios;
-static struct ct *ct = NULL;
+static struct container_stats *container_stats = NULL;
static int ct_alloc_cnt = 0;
static int my_parser(struct lxc_arguments *args, int c, char *arg)
@@ -336,7 +336,7 @@ static void stat_get_blk_stats(struct lxc_container *c, const char *item,
return;
}
-static void stats_get(struct lxc_container *c, struct ct *ct, struct stats *total)
+static void stats_get(struct lxc_container *c, struct container_stats *ct, struct stats *total)
{
ct->c = c;
ct->stats->mem_used = stat_get_int(c, "memory.usage_in_bytes");
@@ -448,8 +448,8 @@ static void stats_print(const char *name, const struct stats *stats,
static int cmp_name(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return strncmp(ct2->c->name, ct1->c->name, strlen(ct2->c->name));
@@ -459,8 +459,8 @@ static int cmp_name(const void *sct1, const void *sct2)
static int cmp_cpuuse(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return ct2->stats->cpu_use_nanos < ct1->stats->cpu_use_nanos;
@@ -470,8 +470,8 @@ static int cmp_cpuuse(const void *sct1, const void *sct2)
static int cmp_blkio(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return ct2->stats->io_service_bytes.total < ct1->stats->io_service_bytes.total;
@@ -481,8 +481,8 @@ static int cmp_blkio(const void *sct1, const void *sct2)
static int cmp_memory(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return ct2->stats->mem_used < ct1->stats->mem_used;
@@ -492,8 +492,8 @@ static int cmp_memory(const void *sct1, const void *sct2)
static int cmp_memorysw(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return ct2->stats->memsw_used < ct1->stats->memsw_used;
@@ -503,8 +503,8 @@ static int cmp_memorysw(const void *sct1, const void *sct2)
static int cmp_kmemory(const void *sct1, const void *sct2)
{
- const struct ct *ct1 = sct1;
- const struct ct *ct2 = sct2;
+ const struct container_stats *ct1 = sct1;
+ const struct container_stats *ct2 = sct2;
if (sort_reverse)
return ct2->stats->kmem_used < ct1->stats->kmem_used;
@@ -526,7 +526,7 @@ static void ct_sort(int active)
case 'k': cmp_func = cmp_kmemory; break;
}
- qsort(ct, active, sizeof(*ct), (int (*)(const void *,const void *))cmp_func);
+ qsort(container_stats, active, sizeof(*container_stats), (int (*)(const void *,const void *))cmp_func);
}
static void ct_free(void)
@@ -534,13 +534,13 @@ static void ct_free(void)
int i;
for (i = 0; i < ct_alloc_cnt; i++) {
- if (ct[i].c) {
- lxc_container_put(ct[i].c);
- ct[i].c = NULL;
+ if (container_stats[i].c) {
+ lxc_container_put(container_stats[i].c);
+ container_stats[i].c = NULL;
}
- free(ct[i].stats);
- ct[i].stats = NULL;
+ free(container_stats[i].stats);
+ container_stats[i].stats = NULL;
}
}
@@ -551,15 +551,15 @@ static void ct_realloc(int active_cnt)
ct_free();
- ct = realloc(ct, sizeof(*ct) * active_cnt);
- if (!ct) {
+ container_stats = realloc(container_stats, sizeof(*container_stats) * active_cnt);
+ if (!container_stats) {
fprintf(stderr, "Cannot alloc mem\n");
exit(EXIT_FAILURE);
}
for (i = 0; i < active_cnt; i++) {
- ct[i].stats = malloc(sizeof(*ct[0].stats));
- if (!ct[i].stats) {
+ container_stats[i].stats = malloc(sizeof(*container_stats[0].stats));
+ if (!container_stats[i].stats) {
fprintf(stderr, "Cannot alloc mem\n");
exit(EXIT_FAILURE);
}
@@ -640,7 +640,7 @@ int main(int argc, char *argv[])
memset(&total, 0, sizeof(total));
for (i = 0; i < active_cnt; i++)
- stats_get(active[i], &ct[i], &total);
+ stats_get(active[i], &container_stats[i], &total);
ct_sort(active_cnt);
@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
}
for (i = 0; i < active_cnt && i < ct_print_cnt; i++) {
- stats_print(ct[i].c->name, ct[i].stats, &total);
+ stats_print(container_stats[i].c->name, container_stats[i].stats, &total);
printf("\n");
}
@@ -661,8 +661,8 @@ int main(int argc, char *argv[])
fflush(stdout);
for (i = 0; i < active_cnt; i++) {
- lxc_container_put(ct[i].c);
- ct[i].c = NULL;
+ lxc_container_put(container_stats[i].c);
+ container_stats[i].c = NULL;
}
in_char = '\0';
From c35f17f32912e468c423b4136eb6000d8bd69ac9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:30:12 +0200
Subject: [PATCH 07/16] tools/lxc_info: do not hide global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_info.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c
index 07303366c..138a3060b 100644
--- a/src/lxc/tools/lxc_info.c
+++ b/src/lxc/tools/lxc_info.c
@@ -48,7 +48,7 @@ static bool pid;
static bool stats;
static bool humanize = true;
static char **key = NULL;
-static int keys = 0;
+static int nr_keys = 0;
static int filter_count = 0;
static int my_parser(struct lxc_arguments *args, int c, char *arg)
@@ -57,13 +57,13 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
switch (c) {
case 'c':
- newk = realloc(key, (keys + 1) * sizeof(key[0]));
+ newk = realloc(key, (nr_keys + 1) * sizeof(key[0]));
if (!newk)
return -1;
key = newk;
- key[keys] = arg;
- keys++;
+ key[nr_keys] = arg;
+ nr_keys++;
break;
case 'i': ips = true; filter_count += 1; break;
case 's': state = true; filter_count += 1; break;
@@ -341,7 +341,7 @@ static int print_info(const char *name, const char *lxcpath)
return -1;
}
- if (!state && !pid && !ips && !stats && keys <= 0) {
+ if (!state && !pid && !ips && !stats && nr_keys <= 0) {
state = pid = ips = stats = true;
print_info_msg_str("Name:", c->name);
}
@@ -380,7 +380,7 @@ static int print_info(const char *name, const char *lxcpath)
print_net_stats(c);
}
- for(i = 0; i < keys; i++) {
+ for(i = 0; i < nr_keys; i++) {
int len = c->get_config_item(c, key[i], NULL, 0);
if (len > 0) {
@@ -389,7 +389,7 @@ static int print_info(const char *name, const char *lxcpath)
if (c->get_config_item(c, key[i], val, len + 1) != len) {
fprintf(stderr, "unable to read %s from configuration\n", key[i]);
} else {
- if (!humanize && keys == 1)
+ if (!humanize && nr_keys == 1)
printf("%s\n", val);
else
printf("%s = %s\n", key[i], val);
@@ -397,7 +397,7 @@ static int print_info(const char *name, const char *lxcpath)
free(val);
} else if (len == 0) {
- if (!humanize && keys == 1)
+ if (!humanize && nr_keys == 1)
printf("\n");
else
printf("%s =\n", key[i]);
From 848e1f79c9304f2401faa20dcf190baba0f15909 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:32:04 +0200
Subject: [PATCH 08/16] state: remove tautological check
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/state.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/lxc/state.c b/src/lxc/state.c
index b3e6f83f8..0fb0e2d64 100644
--- a/src/lxc/state.c
+++ b/src/lxc/state.c
@@ -135,11 +135,6 @@ int lxc_wait(const char *lxcname, const char *states, int timeout,
(void)nanosleep(&onesec, NULL);
}
- if (state < 0) {
- ERROR("Failed to retrieve state from monitor");
- return -1;
- }
-
TRACE("Retrieved state of container %s", lxc_state2str(state));
if (!s[state])
return -1;
From 73b5dab605fcd2c3765b49da41a53d8ba3c9f5d1 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:34:35 +0200
Subject: [PATCH 09/16] conf: remove tautological check
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e822e90d3..d1783aebd 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1494,7 +1494,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs)
*/
static int lxc_pivot_root(const char *rootfs)
{
- int newroot = -1, oldroot = -1, ret = -1;
+ int oldroot;
+ int newroot = -1, ret = -1;
oldroot = open("/", O_DIRECTORY | O_RDONLY);
if (oldroot < 0) {
@@ -1564,9 +1565,9 @@ static int lxc_pivot_root(const char *rootfs)
TRACE("pivot_root(\"%s\") successful", rootfs);
on_error:
- if (oldroot != -1)
- close(oldroot);
- if (newroot != -1)
+ close(oldroot);
+
+ if (newroot >= 0)
close(newroot);
return ret;
From df1f1ba9454210050bad0f6819e1adc60c28274b Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:35:41 +0200
Subject: [PATCH 10/16] conf: use O_CLOEXEC in lxc_pivot_root()
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index d1783aebd..c3358b2fe 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1497,13 +1497,13 @@ static int lxc_pivot_root(const char *rootfs)
int oldroot;
int newroot = -1, ret = -1;
- oldroot = open("/", O_DIRECTORY | O_RDONLY);
+ oldroot = open("/", O_DIRECTORY | O_RDONLY | O_CLOEXEC);
if (oldroot < 0) {
SYSERROR("Failed to open old root directory");
return -1;
}
- newroot = open(rootfs, O_DIRECTORY | O_RDONLY);
+ newroot = open(rootfs, O_DIRECTORY | O_RDONLY | O_CLOEXEC);
if (newroot < 0) {
SYSERROR("Failed to open new root directory");
goto on_error;
From 3b9bd45aadb1cc08b81aacb21d67a84e46944d5d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:36:26 +0200
Subject: [PATCH 11/16] conf: remove tautological check
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index c3358b2fe..7307770a8 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2420,10 +2420,6 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount,
TRACE("Created temporary mount file");
}
- if (fd < 0) {
- SYSERROR("Could not create temporary mount file");
- return NULL;
- }
lxc_list_for_each (iterator, mount) {
size_t len;
From cbb32d2477caad8182b2c1c2716e0e64ba644f87 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:37:39 +0200
Subject: [PATCH 12/16] lxccontainer: remove check from goto target
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/lxccontainer.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 9941d646a..8c26769b4 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -1935,8 +1935,7 @@ static bool do_lxcapi_create(struct lxc_container *c, const char *t,
out_unlock:
umask(mask);
- if (partial_fd >= 0)
- remove_partial(c, partial_fd);
+ remove_partial(c, partial_fd);
out:
if (!ret)
From 1995c4c12b8e693a8f319032595308553284678b Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:39:28 +0200
Subject: [PATCH 13/16] start: prevent values smaller 0
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/start.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/start.c b/src/lxc/start.c
index f0401f5fb..173e04354 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1460,10 +1460,10 @@ int resolve_clone_flags(struct lxc_handler *handler)
struct lxc_conf *conf = handler->conf;
for (i = 0; i < LXC_NS_MAX; i++) {
- if (conf->ns_keep != 0) {
+ if (conf->ns_keep > 0) {
if ((conf->ns_keep & ns_info[i].clone_flag) == 0)
handler->ns_clone_flags |= ns_info[i].clone_flag;
- } else if (conf->ns_clone != 0) {
+ } else if (conf->ns_clone > 0) {
if ((conf->ns_clone & ns_info[i].clone_flag) > 0)
handler->ns_clone_flags |= ns_info[i].clone_flag;
} else {
From 04aaa30d3afd6d4bdba1ac518cb5fddc2868102b Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:45:30 +0200
Subject: [PATCH 14/16] cmd/lxc_init: remove tautological check
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/cmd/lxc_init.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/lxc/cmd/lxc_init.c b/src/lxc/cmd/lxc_init.c
index d50868a13..2dbd75724 100644
--- a/src/lxc/cmd/lxc_init.c
+++ b/src/lxc/cmd/lxc_init.c
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
pid_t pid;
struct sigaction act;
sigset_t mask, omask;
- int have_status = 0, exit_with = 1, shutdown = 0;
+ int have_status = 0, exit_with = EXIT_FAILURE, shutdown = 0;
if (arguments_parse(&my_args, argc, argv))
exit(EXIT_FAILURE);
@@ -416,10 +416,9 @@ int main(int argc, char *argv[])
break;
}
default:
- ret = kill(pid, was_interrupted);
+ (void)kill(pid, was_interrupted);
break;
}
- ret = EXIT_SUCCESS;
was_interrupted = 0;
waited_pid = wait(&status);
@@ -447,9 +446,9 @@ int main(int argc, char *argv[])
have_status = 1;
}
}
+
out:
- if (ret < 0)
- exit(EXIT_FAILURE);
+
exit(exit_with);
}
From 0fe260299aa9360c1eb4784978ef6446c9d8c003 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:48:06 +0200
Subject: [PATCH 15/16] tools/lxc_stop: use correct check
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_stop.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c
index 1267fd11e..62ca465b8 100644
--- a/src/lxc/tools/lxc_stop.c
+++ b/src/lxc/tools/lxc_stop.c
@@ -205,8 +205,7 @@ int main(int argc, char *argv[])
/* reboot */
if (my_args.reboot) {
- ret = c->reboot2(c, my_args.timeout);
- if (ret < 0)
+ if (!c->reboot2(c, my_args.timeout))
ret = EXIT_FAILURE;
else
ret = EXIT_SUCCESS;
From 456d11b14b469c22e14f770be322274c423e73d9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 20 Oct 2018 11:49:47 +0200
Subject: [PATCH 16/16] cmd/lxc_init: do not hide global variable
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/cmd/lxc_init.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lxc/cmd/lxc_init.c b/src/lxc/cmd/lxc_init.c
index 2dbd75724..c7c4f2784 100644
--- a/src/lxc/cmd/lxc_init.c
+++ b/src/lxc/cmd/lxc_init.c
@@ -182,17 +182,17 @@ static void kill_children(pid_t pid)
}
while (!feof(f)) {
- pid_t pid;
+ pid_t find_pid;
- if (fscanf(f, "%d ", &pid) != 1) {
+ if (fscanf(f, "%d ", &find_pid) != 1) {
if (my_args.quiet)
fprintf(stderr, "Failed to retrieve pid\n");
fclose(f);
return;
}
- kill_children(pid);
- kill(pid, SIGKILL);
+ (void)kill_children(find_pid);
+ (void)kill(find_pid, SIGKILL);
}
fclose(f);
More information about the lxc-devel
mailing list