Skip to content

Commit

Permalink
Merge pull request #1301 from brauner/2016-11-15/isolcpus
Browse files Browse the repository at this point in the history
cgroups: use %zu format specifier to print size_t
  • Loading branch information
stgraber committed Nov 15, 2016
2 parents a8bae55 + 657f890 commit 471a304
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -358,20 +358,21 @@ static uint32_t *lxc_cpumask(char *buf, size_t nbits)
}

/* The largest integer that can fit into long int is 2^64. This is a
* 20-digit number. */
#define LEN 21
* 20-digit number.
*/
#define __IN_TO_STR_LEN 21
/* Turn cpumask into simple, comma-separated cpulist. */
static char *lxc_cpumask_to_cpulist(uint32_t *bitarr, size_t nbits)
{
size_t i;
int ret;
char numstr[LEN] = {0};
char numstr[__IN_TO_STR_LEN] = {0};
char **cpulist = NULL;

for (i = 0; i <= nbits; i++) {
if (is_set(i, bitarr)) {
ret = snprintf(numstr, LEN, "%lu", i);
if (ret < 0 || (size_t)ret >= LEN) {
ret = snprintf(numstr, __IN_TO_STR_LEN, "%zu", i);
if (ret < 0 || (size_t)ret >= __IN_TO_STR_LEN) {
lxc_free_array((void **)cpulist, free);
return NULL;
}
Expand Down

0 comments on commit 471a304

Please sign in to comment.