From: Konrad Rzeszutek Wilk Subject: [PATCH RFC 07/14] libxl: Fix xc_tmem_control to return proper error. Date: Fri, 13 Mar 2015 15:31:16 -0400 Message-ID: <1426275083-8454-8-git-send-email-konrad.wilk@oracle.com> References: <1426275083-8454-1-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YWVJN-0006h1-AX for xen-devel@lists.xenproject.org; Fri, 13 Mar 2015 19:31:57 +0000 In-Reply-To: <1426275083-8454-1-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, wei.liu2@citrix.com Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org The API returns now negative values on error and stashes the error in errno. Fix the user of this API. Signed-off-by: Konrad Rzeszutek Wilk --- tools/libxc/xc_tmem.c | 16 ++++++++++++---- tools/xenstat/libxenstat/src/xenstat.c | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c index 3261e10..3e3246e 100644 --- a/tools/libxc/xc_tmem.c +++ b/tools/libxc/xc_tmem.c @@ -73,11 +73,15 @@ int xc_tmem_control(xc_interface *xch, if ( subop == TMEMC_LIST && arg1 != 0 ) { if ( buf == NULL ) - return -EINVAL; + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, buf) ) { PERROR("Could not bounce buffer for tmem control hypercall"); - return -ENOMEM; + errno = ENOMEM; + return -1; } } @@ -118,11 +122,15 @@ int xc_tmem_control_oid(xc_interface *xch, if ( subop == TMEMC_LIST && arg1 != 0 ) { if ( buf == NULL ) - return -EINVAL; + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, buf) ) { PERROR("Could not bounce buffer for tmem control (OID) hypercall"); - return -ENOMEM; + errno = ENOMEM; + return -1; } } diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c index 8072a90..bf257ef 100644 --- a/tools/xenstat/libxenstat/src/xenstat.c +++ b/tools/xenstat/libxenstat/src/xenstat.c @@ -166,6 +166,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE]; int new_domains; unsigned int i; + long rc; /* Create the node */ node = (xenstat_node *) calloc(1, sizeof(xenstat_node)); @@ -189,9 +190,9 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) node->free_mem = ((unsigned long long)physinfo.free_pages) * handle->page_size; - node->freeable_mb = (long)xc_tmem_control(handle->xc_handle, -1, + rc = (long)xc_tmem_control(handle->xc_handle, -1, TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, NULL); - + node->freeable_mb = (rc < 0) ? 0 : rc; /* malloc(0) is not portable, so allocate a single domain. This will * be resized below. */ node->domains = malloc(sizeof(xenstat_domain)); -- 2.1.0