diff mbox

[13/24] libxc: improve error handling of xc Credit1 and Credit2 helpers

Message ID 147145434473.25877.8095947074334048832.stgit@Solace.fritz.box (mailing list archive)
State New, archived
Headers show

Commit Message

Dario Faggioli Aug. 17, 2016, 5:19 p.m. UTC
In fact, libxc wrappers should, on error, set errno and
return -1.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxc/xc_csched.c  |   27 +++++++++++++++------------
 tools/libxc/xc_csched2.c |   15 +++++++++------
 2 files changed, 24 insertions(+), 18 deletions(-)

Comments

Wei Liu Sept. 20, 2016, 3:10 p.m. UTC | #1
On Wed, Aug 17, 2016 at 07:19:04PM +0200, Dario Faggioli wrote:
> In fact, libxc wrappers should, on error, set errno and
> return -1.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>
diff mbox

Patch

diff --git a/tools/libxc/xc_csched.c b/tools/libxc/xc_csched.c
index bf03bfc..139fc16 100644
--- a/tools/libxc/xc_csched.c
+++ b/tools/libxc/xc_csched.c
@@ -37,7 +37,10 @@  xc_sched_credit_domain_set(
     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo;
     domctl.u.scheduler_op.u.credit = *sdom;
 
-    return do_domctl(xch, &domctl);
+    if ( do_domctl(xch, &domctl) )
+        return -1;
+
+    return 0;
 }
 
 int
@@ -47,18 +50,18 @@  xc_sched_credit_domain_get(
     struct xen_domctl_sched_credit *sdom)
 {
     DECLARE_DOMCTL;
-    int err;
 
     domctl.cmd = XEN_DOMCTL_scheduler_op;
     domctl.domain = (domid_t) domid;
     domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT;
     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
 
-    err = do_domctl(xch, &domctl);
-    if ( err == 0 )
-        *sdom = domctl.u.scheduler_op.u.credit;
+    if ( do_domctl(xch, &domctl) )
+        return -1;
+
+    *sdom = domctl.u.scheduler_op.u.credit;
 
-    return err;
+    return 0;
 }
 
 int
@@ -67,7 +70,6 @@  xc_sched_credit_params_set(
     uint32_t cpupool_id,
     struct xen_sysctl_credit_schedule *schedule)
 {
-    int rc;
     DECLARE_SYSCTL;
 
     sysctl.cmd = XEN_SYSCTL_scheduler_op;
@@ -77,11 +79,12 @@  xc_sched_credit_params_set(
 
     sysctl.u.scheduler_op.u.sched_credit = *schedule;
 
-    rc = do_sysctl(xch, &sysctl);
+    if ( do_sysctl(xch, &sysctl) )
+        return -1;
 
     *schedule = sysctl.u.scheduler_op.u.sched_credit;
 
-    return rc;
+    return 0;
 }
 
 int
@@ -90,7 +93,6 @@  xc_sched_credit_params_get(
     uint32_t cpupool_id,
     struct xen_sysctl_credit_schedule *schedule)
 {
-    int rc;
     DECLARE_SYSCTL;
 
     sysctl.cmd = XEN_SYSCTL_scheduler_op;
@@ -98,9 +100,10 @@  xc_sched_credit_params_get(
     sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT;
     sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo;
 
-    rc = do_sysctl(xch, &sysctl);
+    if ( do_sysctl(xch, &sysctl) )
+        return -1;
 
     *schedule = sysctl.u.scheduler_op.u.sched_credit;
 
-    return rc;
+    return 0;
 }
diff --git a/tools/libxc/xc_csched2.c b/tools/libxc/xc_csched2.c
index 5b62a5f..12c95e6 100644
--- a/tools/libxc/xc_csched2.c
+++ b/tools/libxc/xc_csched2.c
@@ -37,7 +37,10 @@  xc_sched_credit2_domain_set(
     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo;
     domctl.u.scheduler_op.u.credit2 = *sdom;
 
-    return do_domctl(xch, &domctl);
+    if ( do_domctl(xch, &domctl) )
+        return -1;
+
+    return 0;
 }
 
 int
@@ -47,18 +50,18 @@  xc_sched_credit2_domain_get(
     struct xen_domctl_sched_credit2 *sdom)
 {
     DECLARE_DOMCTL;
-    int err;
 
     domctl.cmd = XEN_DOMCTL_scheduler_op;
     domctl.domain = (domid_t) domid;
     domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2;
     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
 
-    err = do_domctl(xch, &domctl);
-    if ( err == 0 )
-        *sdom = domctl.u.scheduler_op.u.credit2;
+    if ( do_domctl(xch, &domctl) )
+        return -1;
+
+    *sdom = domctl.u.scheduler_op.u.credit2;
 
-    return err;
+    return 0;
 }
 
 int