Skip to content

Commit

Permalink
cgfsng: s/25/INTTYPE_TO_STRLEN(pid_t)/g
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Sep 26, 2018
1 parent 5ce03bc commit a3650c0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit a3650c0

Please sign in to comment.