2
0
mirror of git://github.com/lxc/lxc synced 2025-08-30 23:39:32 +00:00

cgroups: use %zu format specifier to print size_t

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
This commit is contained in:
Christian Brauner
2016-11-15 06:19:55 +01:00
parent 748c52b52c
commit 657f890799

View File

@@ -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;
}