All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, ian.campbell@citrix.com,
	ian.jackson@eu.citrix.com
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v2 07/13] libxc: Fix xc_tmem_control to return proper error.
Date: Wed, 18 Mar 2015 20:24:13 -0400	[thread overview]
Message-ID: <1426724659-23999-8-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1426724659-23999-1-git-send-email-konrad.wilk@oracle.com>

The API returns now negative values on error and stashes
the error in errno. Fix the user of this API.

The 'xc_hypercall_bounce_pre' can fail - and if so it will
stash its errno values - no need to over-write it.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 tools/libxc/xc_tmem.c                  | 14 ++++++++++----
 tools/xenstat/libxenstat/src/xenstat.c |  7 ++++---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c
index 3261e10..02797bf 100644
--- a/tools/libxc/xc_tmem.c
+++ b/tools/libxc/xc_tmem.c
@@ -73,11 +73,14 @@ 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;
+            return -1;
         }
     }
 
@@ -118,11 +121,14 @@ 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;
+            return -1;
         }
     }
 
diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c
index 8072a90..c1f6511 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;
+	int 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,
-				TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, NULL);
-
+	rc = 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

  parent reply	other threads:[~2015-03-19  0:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19  0:24 [PATCH v2] Fix libxc return -E misusage Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 01/13] libxc: Replaces tabs with spaces in xc_cpupool_freeinfo Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 02/13] libxc: Propagate errno from hypercall instead of anything else Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 03/13] libxc: Fix xc_domain_get_tsc_info to return -1 instead of -Exx Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 04/13] libxc: xc_physdev_map return -1 and populate errno Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 05/13] libxc: Return negative value and propagate errno for xc_offline_page API Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 06/13] libxc: Fix xc_pm API calls to return negative error and stash error in errno Konrad Rzeszutek Wilk
2015-03-19  0:24 ` Konrad Rzeszutek Wilk [this message]
2015-03-19 16:39   ` [PATCH v2 07/13] libxc: Fix xc_tmem_control to return proper error Ian Campbell
2015-03-19 18:52     ` Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 08/13] libxc: Check xc_domain_maximum_gpfn for negative return values Konrad Rzeszutek Wilk
2015-03-19 16:47   ` Ian Campbell
2015-03-19 18:54     ` Konrad Rzeszutek Wilk
2015-03-20  9:48       ` Ian Campbell
2015-03-20 14:34         ` Konrad Rzeszutek Wilk
2015-03-20 14:49           ` Konrad Rzeszutek Wilk
2015-03-20 15:00             ` Ian Campbell
2015-03-20 15:45               ` Konrad Rzeszutek Wilk
2015-03-20 17:03                 ` Ian Campbell
2015-03-26 21:07                   ` REGRESSION " Andrew Cooper
2015-03-27 10:52                     ` Ian Campbell
2015-03-27 14:14                       ` Konrad Rzeszutek Wilk
2015-03-27 19:42                     ` Konrad Rzeszutek Wilk
2015-03-27 20:04                       ` Andrew Cooper
2015-03-27 20:41                         ` Konrad Rzeszutek Wilk
2015-03-27 21:17                           ` Andrew Cooper
2015-03-30  8:49                             ` Ian Campbell
2015-03-19 20:04     ` Konrad Rzeszutek Wilk
2015-03-20  0:18       ` Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 09/13] libxc: Check xc_maximum_ram_page " Konrad Rzeszutek Wilk
2015-03-19 16:49   ` Ian Campbell
2015-03-19  0:24 ` [PATCH v2 10/13] libxc: If xc_domain_add_to_physmap fails, include errno value Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 11/13] libxc: Check xc_sharing_* for proper return values Konrad Rzeszutek Wilk
2015-03-19 16:50   ` Ian Campbell
2015-03-19  0:24 ` [PATCH v2 12/13] libxl: Don't assign return value to errno for E820 get/set xc_ calls Konrad Rzeszutek Wilk
2015-03-19  0:24 ` [PATCH v2 13/13] libxc: Fix do_memory_op to return negative value on errors Konrad Rzeszutek Wilk
2015-03-19 16:51   ` 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=1426724659-23999-8-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.