[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] libxl: make GC_FREE reachable in libxl_get_scheduler()



commit 9937763265d9597e5f2439249b16d995842cdf0f
Author:     Chester Lin <czylin@xxxxxxxxxxxx>
AuthorDate: Sun Jan 24 19:45:51 2016 -0500
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Jan 26 16:27:01 2016 +0000

    libxl: make GC_FREE reachable in libxl_get_scheduler()
    
    Coverity CID 1343309
    
    Make GC_FREE reachable in all cases in libxl_get_scheduler() by
    eliminating the error-path return and instead storing the error code in
    the returned variable.
    
    To make this semantically consistent, change the return type of
    libxl_get_scheduler() from libxl_scheduler to int, and make a note of
    the interpretation of the return value in libxl.h.  N.B. This change
    does not change the API in a way that affects functionality.
    
    The libxl_scheduler enum is consistent with the sched_id return value
    of xc_sched_id and this must continue to be true.
    
    Suggested-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Signed-off-by: Chester Lin <czylin@xxxxxxxxxxxx>
    Reviewed-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/libxl/libxl.c | 5 ++---
 tools/libxl/libxl.h | 5 ++++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 52fefc0..94b5656 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5578,7 +5578,7 @@ out:
     return rc;
 }
 
-libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
+int libxl_get_scheduler(libxl_ctx *ctx)
 {
     int r, sched;
 
@@ -5586,8 +5586,7 @@ libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
     r = xc_sched_id(ctx->xch, &sched);
     if (r != 0) {
         LOGE(ERROR, "getting current scheduler id");
-        return ERROR_FAIL;
-        GC_FREE;
+        sched = ERROR_FAIL;
     }
     GC_FREE;
     return sched;
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 156c0d5..fa87f53 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1716,7 +1716,10 @@ int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, 
uint32_t domid,
                                   libxl_bitmap *nodemap);
 int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap);
 
-libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx);
+/* A return value less than 0 should be interpreted as a libxl_error, while a
+ * return value greater than or equal to 0 should be interpreted as a
+ * libxl_scheduler. */
+int libxl_get_scheduler(libxl_ctx *ctx);
 
 /* Per-scheduler parameters */
 int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid,
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.