xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 2/5] libxl: make GC_FREE reachable in libxl_get_scheduler()
@ 2016-01-25  0:45 Chester Lin
  2016-01-25 11:59 ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Chester Lin @ 2016-01-25  0:45 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, ian.campbell, stefano.stabellini, dario.faggioli,
	ian.jackson, Chester Lin, jtotto, hjarmstr

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@citrix.com>
Signed-off-by: Chester Lin <czylin@uwaterloo.ca>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

---
Changed return type of libxl_get_scheduler in order to return both negative
error constants and positive scheduler values.
---
 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 9c3cb3e..5a450ef 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5582,7 +5582,7 @@ out:
     return rc;
 }
 
-libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
+int libxl_get_scheduler(libxl_ctx *ctx)
 {
     int r, sched;
 
@@ -5590,8 +5590,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 7114491..09fcef3 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1711,7 +1711,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,
-- 
1.9.5.msysgit.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-02  4:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25  0:45 [PATCH v3 2/5] libxl: make GC_FREE reachable in libxl_get_scheduler() Chester Lin
2016-01-25 11:59 ` Ian Campbell
2016-01-26 16:52   ` Ian Campbell
2016-02-02  4:39     ` czylin

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).