From eb6cf0c1d25837f4816e0a253a46118bfb05baef Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Fri, 5 Sep 2008 18:47:57 +0000 Subject: [PATCH] libcgroup: Change variables to *printf/*scanf to use inttypes.h Instead of using %lu and so on, use the inttype.h macro to define types. Will ensure compatibility across platforms. Please review more closely. Tested by compiling with and without -m32 on a 64 bit system. Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@176 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- wrapper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wrapper.c b/wrapper.c index 24a641da..c75552bb 100644 --- a/wrapper.c +++ b/wrapper.c @@ -145,7 +145,7 @@ int cgroup_add_value_int64(struct cgroup_controller *controller, strncpy(cntl_value->name, name, sizeof(cntl_value->name)); ret = snprintf(cntl_value->value, - sizeof(cntl_value->value), "%ld", value); + sizeof(cntl_value->value), "%" PRId64, value); if (ret >= sizeof(cntl_value->value)) return ECGINVAL; @@ -178,8 +178,8 @@ int cgroup_add_value_uint64(struct cgroup_controller *controller, return ECGCONTROLLERCREATEFAILED; strncpy(cntl_value->name, name, sizeof(cntl_value->name)); - ret = snprintf(cntl_value->value, sizeof(cntl_value->value), "%lu", - value); + ret = snprintf(cntl_value->value, sizeof(cntl_value->value), + "%" PRIu64, value); if (ret >= sizeof(cntl_value->value)) return ECGINVAL; @@ -381,7 +381,7 @@ int cgroup_get_value_int64(struct cgroup_controller *controller, if (!strcmp(val->name, name)) { - if (sscanf(val->value, "%ld", value) != 1) + if (sscanf(val->value, "%" SCNd64, value) != 1) return ECGINVAL; return 0; @@ -402,7 +402,7 @@ int cgroup_set_value_int64(struct cgroup_controller *controller, if (!strcmp(val->name, name)) { ret = snprintf(val->value, - sizeof(val->value), "%lu", value); + sizeof(val->value), "%" PRId64, value); if (ret >= sizeof(val->value) || ret < 0) return ECGINVAL; @@ -423,7 +423,7 @@ int cgroup_get_value_uint64(struct cgroup_controller *controller, struct control_value *val = controller->values[i]; if (!strcmp(val->name, name)) { - if (sscanf(val->value, "%lu", value) != 1) + if (sscanf(val->value, "%" SCNu64, value) != 1) return ECGINVAL; return 0; @@ -444,7 +444,7 @@ int cgroup_set_value_uint64(struct cgroup_controller *controller, if (!strcmp(val->name, name)) { ret = snprintf(val->value, - sizeof(val->value), "%lu", value); + sizeof(val->value), "%" PRIu64, value); if (ret >= sizeof(val->value) || ret < 0) return ECGINVAL; -- 2.47.2