]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Change variables to *printf/*scanf to use inttypes.h
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Fri, 5 Sep 2008 18:47:57 +0000 (18:47 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Fri, 5 Sep 2008 18:47:57 +0000 (18:47 +0000)
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 <dhaval@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@176 4f4bb910-9a46-0410-90c8-c897d4f1cd53

wrapper.c

index 24a641da866975365c76ecd8eb802571b8c5ecb4..c75552bb1b75296b81f079b716cdf3ace7a22190 100644 (file)
--- 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;