]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: workaround gcc-7 bug 1714/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 27 Jul 2017 18:49:58 +0000 (20:49 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 27 Jul 2017 19:04:59 +0000 (21:04 +0200)
Also: LOL

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 5ad24d1e5c8cface17ab434d508d06738981f9ad..c5a9fb32f5cb46f15e7d2a1db98ce007572f2107 100644 (file)
@@ -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,18 @@ again:
                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) {
+                       FILE *f = fopen("/dev/null", "w");
+                       if (f >= 0) {
+                               fprintf(f, "Workaround for GCC7 bug: "
+                                          "https://gcc.gnu.org/bugzilla/"
+                                          "show_bug.cgi?id=78969");
+                               fclose(f);
+                       }
+               }
+       }
        for (i = 0; hierarchies[i]; i++) {
                if (!create_path_for_hierarchy(hierarchies[i], cgname)) {
                        int j;