[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv2 04/10] cgroup: Replace sscanf with virStrToLong_ll



The switch from %lli to %lld in virCgroupGetValueI64 is intended,
as virCgroupGetValueU64 uses base 10 too, and virCgroupSetValueI64
uses %lld to format the number to string.

Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
---
 src/util/cgroup.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 496d9d3..4cb09b6 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -12,7 +12,6 @@
 
 #include <stdio.h>
 #include <stdint.h>
-#include <inttypes.h>
 #ifdef HAVE_MNTENT_H
 # include <mntent.h>
 #endif
@@ -374,7 +373,7 @@ static int virCgroupGetValueI64(virCgroupPtr group,
     if (rc != 0)
         goto out;
 
-    if (sscanf(strval, "%" SCNi64, value) != 1)
+    if (virStrToLong_ll(strval, NULL, 10, value) < 0)
         rc = -EINVAL;
 out:
     VIR_FREE(strval);
-- 
1.6.3.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]