[libvirt] [PATCH 08/10] xenapi: Use virStrToLong_i instead of sscanf for CPU map parsing

Matthias Bolte matthias.bolte at googlemail.com
Tue Mar 30 16:20:32 UTC 2010


---
 src/xenapi/xenapi_utils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 697ad39..790eebf 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -309,7 +309,8 @@ getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen)
     bzero(cpumap, maplen);
     num = strtok_r(mask, ",", &bp);
     while (num != NULL) {
-        if (sscanf(num, "%d", &pos) != 1)
+        num += strspn(num, " \t");
+        if (virStrToLong_i(num, NULL, 10, &pos) < 0)
             return;
         if (pos < 0 || pos > max_bits - 1)
             VIR_WARN ("number in str %d exceeds cpumap's max bits %d", pos, max_bits);
-- 
1.6.3.3




More information about the libvir-list mailing list