tools/libxc: Fix error checking for xc_get_{cpu, node}map_size() callers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 11 Dec 2013 15:47:42 +0000 (15:47 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 18 Dec 2013 11:09:58 +0000 (11:09 +0000)
c/s 2e82c18cd850592ae9a1f682eb93965a868b5f2f changed the error returns of
xc_get_{cpu,node}map_size() to now include returning -1.  This invalidated the
error checks from callers, which expected 0 to be the only error case.

Coverity ID: 1135907 1135908 1135909 1135910 1135911 1135912 1135913 1135914

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
tools/libxc/xc_cpupool.c
tools/libxc/xc_domain.c
tools/libxc/xc_misc.c

index b5e0c460ffc2845d906ff12e8fb131a15bd24374..c8c2a3379ac948a4b724a7a965d44b2553737fd5 100644 (file)
@@ -74,7 +74,7 @@ xc_cpupoolinfo_t *xc_cpupool_getinfo(xc_interface *xch,
     DECLARE_HYPERCALL_BUFFER(uint8_t, local);
 
     local_size = xc_get_cpumap_size(xch);
-    if (!local_size)
+    if (local_size <= 0)
     {
         PERROR("Could not get number of cpus");
         return NULL;
@@ -172,7 +172,7 @@ xc_cpumap_t xc_cpupool_freeinfo(xc_interface *xch)
     DECLARE_HYPERCALL_BUFFER(uint8_t, local);
 
     mapsize = xc_get_cpumap_size(xch);
-    if (mapsize == 0)
+    if (mapsize <= 0)
         return NULL;
 
     local = xc_hypercall_buffer_alloc(xch, local, mapsize);
index 1ccafc5185bce07d6c0a189882ebc6ea2cd74696..c2fdd7493161bda6b7984157f5f17fdf8fe48e3e 100644 (file)
@@ -122,7 +122,7 @@ int xc_domain_node_setaffinity(xc_interface *xch,
     int nodesize;
 
     nodesize = xc_get_nodemap_size(xch);
-    if (!nodesize)
+    if (nodesize <= 0)
     {
         PERROR("Could not get number of nodes");
         goto out;
@@ -160,7 +160,7 @@ int xc_domain_node_getaffinity(xc_interface *xch,
     int nodesize;
 
     nodesize = xc_get_nodemap_size(xch);
-    if (!nodesize)
+    if (nodesize <= 0)
     {
         PERROR("Could not get number of nodes");
         goto out;
@@ -200,7 +200,7 @@ int xc_vcpu_setaffinity(xc_interface *xch,
     int cpusize;
 
     cpusize = xc_get_cpumap_size(xch);
-    if (!cpusize)
+    if (cpusize <= 0)
     {
         PERROR("Could not get number of cpus");
         goto out;
@@ -243,7 +243,7 @@ int xc_vcpu_getaffinity(xc_interface *xch,
     int cpusize;
 
     cpusize = xc_get_cpumap_size(xch);
-    if (!cpusize)
+    if (cpusize <= 0)
     {
         PERROR("Could not get number of cpus");
         goto out;
index 00cd0d865073391a15c8d9f369b47fc9fb4cb45d..330345459176961cacc7fda506e843831fe7156a 100644 (file)
@@ -88,7 +88,7 @@ xc_cpumap_t xc_cpumap_alloc(xc_interface *xch)
     int sz;
 
     sz = xc_get_cpumap_size(xch);
-    if (sz == 0)
+    if (sz <= 0)
         return NULL;
     return calloc(1, sz);
 }
@@ -98,7 +98,7 @@ xc_nodemap_t xc_nodemap_alloc(xc_interface *xch)
     int sz;
 
     sz = xc_get_nodemap_size(xch);
-    if (sz == 0)
+    if (sz <= 0)
         return NULL;
     return calloc(1, sz);
 }