]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgfsng: s/25/INTTYPE_TO_STRLEN(pid_t)/g
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 26 Sep 2018 12:13:05 +0000 (14:13 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 26 Sep 2018 12:13:05 +0000 (14:13 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 5d7effcba9909b66c4b9588c51973be9ce56653d..7388ad7675525a4a2fc112f9499c42b5b9f4cf71 100644 (file)
@@ -1465,10 +1465,10 @@ __cgfsng_ops static bool __do_cgroup_enter(struct cgroup_ops *ops, pid_t pid,
                                             bool monitor)
 {
        int len;
-       char pidstr[25];
+       char pidstr[INTTYPE_TO_STRLEN(pid_t)];
 
-       len = snprintf(pidstr, 25, "%d", pid);
-       if (len < 0 || len >= 25)
+       len = snprintf(pidstr, sizeof(pidstr), "%d", pid);
+       if (len < 0 || (size_t)len >= sizeof(pidstr))
                return false;
 
        for (int i = 0; ops->hierarchies[i]; i++) {
@@ -2097,10 +2097,10 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char *name,
                                         const char *lxcpath, pid_t pid)
 {
        int i, len, ret;
-       char pidstr[25];
+       char pidstr[INTTYPE_TO_STRLEN(pid_t)];
 
-       len = snprintf(pidstr, 25, "%d", pid);
-       if (len < 0 || len >= 25)
+       len = snprintf(pidstr, sizeof(pidstr), "%d", pid);
+       if (len < 0 || (size_t)len >= sizeof(pidstr))
                return false;
 
        for (i = 0; ops->hierarchies[i]; i++) {