[lxc-devel] [lxc/master] cgroups: workaround gcc-7 bug

brauner on Github lxc-bot at linuxcontainers.org
Thu Jul 27 18:50:53 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 377 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170727/b7b42f9a/attachment.bin>
-------------- next part --------------
From 32f603989a8c6c6600407877d4d1f33c76e173f5 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 27 Jul 2017 20:49:58 +0200
Subject: [PATCH] cgroups: workaround gcc-7 bug

Also: LOL

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 5ad24d1e5..3a6c70caa 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1315,7 +1315,8 @@ static inline bool cgfsng_create(void *hdata)
 {
 	struct cgfsng_handler_data *d = hdata;
 	char *tmp, *cgname, *offset;
-	int i, idx = 0;
+	int i, ret;
+	int idx = 0;
 	size_t len;
 
 	if (!d)
@@ -1341,8 +1342,11 @@ static inline bool cgfsng_create(void *hdata)
 		ERROR("Too many conflicting cgroup names");
 		goto out_free;
 	}
-	if (idx)
-		snprintf(offset, 5, "-%d", idx);
+	if (idx) {
+		ret = snprintf(offset, 5, "-%d", idx);
+		if (ret < 0 || (size_t)ret >= 5)
+			INFO("Shut up gcc-7");
+	}
 	for (i = 0; hierarchies[i]; i++) {
 		if (!create_path_for_hierarchy(hierarchies[i], cgname)) {
 			int j;


More information about the lxc-devel mailing list