[CRIU] [PATCH 16/23] cr: generalized format strings

Alexander Kartashov alekskartashov at parallels.com
Mon Jan 14 02:25:58 EST 2013


This patch replaces the format specifier %ld with PRIx64
in the following places:

* the format string argument of the function scanf(),
* in the macros GEN_SYSCTL_*_FUNC.

We need explicit specification of the integer size there.

Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 proc_parse.c |    6 +++---
 sysctl.c     |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index df32317..ee115f0 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -879,7 +879,7 @@ int parse_fdinfo(int fd, int type,
 
 			if (type != FD_TYPES__EVENTFD)
 				goto parse_err;
-			ret = sscanf(str, "eventfd-count: %lx",
+			ret = sscanf(str, "eventfd-count: %"PRIx64,
 					&entry.efd.counter);
 			if (ret != 1)
 				goto parse_err;
@@ -895,7 +895,7 @@ int parse_fdinfo(int fd, int type,
 
 			if (type != FD_TYPES__EVENTPOLL)
 				goto parse_err;
-			ret = sscanf(str, "tfd: %d events: %x data: %lx",
+			ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64,
 					&entry.epl.tfd, &entry.epl.events, &entry.epl.data);
 			if (ret != 3)
 				goto parse_err;
@@ -932,7 +932,7 @@ int parse_fdinfo(int fd, int type,
 			if (type != FD_TYPES__INOTIFY)
 				goto parse_err;
 			ret = sscanf(str,
-					"inotify wd:%x ino:%lx sdev:%x "
+					"inotify wd:%x ino:%"PRIx64" sdev:%x "
 					"mask:%x ignored_mask:%x "
 					"fhandle-bytes:%x fhandle-type:%x "
 					"f_handle: %n",
diff --git a/sysctl.c b/sysctl.c
index 0a791e1..62236db 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -134,14 +134,14 @@ GEN_SYSCTL_READ_FUNC(u32, strtoul);
 GEN_SYSCTL_READ_FUNC(u64, strtoull);
 
 GEN_SYSCTL_WRITE_FUNC(u32, "%u ");
-GEN_SYSCTL_WRITE_FUNC(u64, "%lu ");
+GEN_SYSCTL_WRITE_FUNC(u64, "%"PRIu64" ");
 
 GEN_SYSCTL_PRINT_FUNC(u32, "%u ");
-GEN_SYSCTL_PRINT_FUNC(u64, "%lu ");
+GEN_SYSCTL_PRINT_FUNC(u64, "%"PRIu64" ");
 GEN_SYSCTL_PRINT_FUNC(char, "%c");
 
 GEN_SYSCTL_SHOW_FUNC(u32, "%u ");
-GEN_SYSCTL_SHOW_FUNC(u64, "%lu ");
+GEN_SYSCTL_SHOW_FUNC(u64, "%"PRIu64" ");
 GEN_SYSCTL_SHOW_FUNC(char, "%c");
 
 static int
-- 
1.7.10.4



More information about the CRIU mailing list