[lxc-devel] [lxc/master] cgroups: use %zu format specifier to print size_t

brauner on Github lxc-bot at linuxcontainers.org
Tue Nov 15 05:21:31 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 537 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161115/7c72c367/attachment.bin>
-------------- next part --------------
From 657f890799ad5809ad83a77c69ede2e335835ec4 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Tue, 15 Nov 2016 06:19:55 +0100
Subject: [PATCH] cgroups: use %zu format specifier to print size_t

Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
 src/lxc/cgroups/cgfsng.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 1e38335..57a13dc 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -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;
 			}


More information about the lxc-devel mailing list