From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: [PATCH] tools/libxc: Fix error checking for xc_get_{cpu, node}map_size() callers
Date: Wed, 11 Dec 2013 15:47:42 +0000 [thread overview]
Message-ID: <1386776862-19921-1-git-send-email-andrew.cooper3@citrix.com> (raw)
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>
CC: 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 | 4 ++--
tools/libxc/xc_domain.c | 8 ++++----
tools/libxc/xc_misc.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/libxc/xc_cpupool.c b/tools/libxc/xc_cpupool.c
index b5e0c46..c8c2a33 100644
--- a/tools/libxc/xc_cpupool.c
+++ b/tools/libxc/xc_cpupool.c
@@ -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);
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 1ccafc5..c2fdd74 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -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;
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 00cd0d8..3303454 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -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);
}
--
1.7.10.4
next reply other threads:[~2013-12-11 15:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 15:47 Andrew Cooper [this message]
2013-12-12 14:24 ` [PATCH] tools/libxc: Fix error checking for xc_get_{cpu, node}map_size() callers Ian Campbell
2013-12-12 14:56 ` Dario Faggioli
2013-12-12 21:05 ` Andrew Cooper
2013-12-12 23:59 ` Dario Faggioli
2013-12-13 0:35 ` Andrew Cooper
2013-12-13 10:13 ` Dario Faggioli
2013-12-18 11:10 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386776862-19921-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).