All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/libxl: libxl_get_scheduler should return an int
@ 2014-03-21 12:25 Julien Grall
  2014-03-21 12:43 ` Ian Campbell
  2014-03-21 14:28 ` Ian Jackson
  0 siblings, 2 replies; 12+ messages in thread
From: Julien Grall @ 2014-03-21 12:25 UTC (permalink / raw)
  To: xen-devel; +Cc: stefano.stabellini, Julien Grall, ian.jackson, ian.campbell

libxl_get_scheduler returns either a valid value in enum range or ERROR_FAIL.

As function return type is an enum, chekcing if the value is negative will
be always false. Therefore both GCC and clang will never go to the error
case.

Spotted by clang:
xl_cmdimpl.c:6709:48: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
        if ((sched = libxl_get_scheduler(ctx)) < 0) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Ian, it seems this is the only place with this such construction.

    Changes in v2:
        - Was "Correctly check if libxl_get_scheduler has failed"
---
 tools/libxl/libxl.c      |    2 +-
 tools/libxl/libxl.h      |    2 +-
 tools/libxl/xl_cmdimpl.c |    6 ++++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 30b0b06..f1adc42 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4725,7 +4725,7 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
     return rc;
 }
 
-libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
+int libxl_get_scheduler(libxl_ctx *ctx)
 {
     libxl_scheduler sched, ret;
 
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index b2c3015..a408950 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1079,7 +1079,7 @@ 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);
+int libxl_get_scheduler(libxl_ctx *ctx);
 
 /* Per-scheduler parameters */
 int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid,
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 8990020..7c73ee0 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4819,7 +4819,7 @@ int main_vcpuset(int argc, char **argv)
 static void output_xeninfo(void)
 {
     const libxl_version_info *info;
-    libxl_scheduler sched;
+    int sched;
 
     if (!(info = libxl_get_version_info(ctx))) {
         fprintf(stderr, "libxl_get_version_info failed.\n");
@@ -6706,10 +6706,12 @@ int main_cpupoolcreate(int argc, char **argv)
             goto out_cfg;
         }
     } else {
-        if ((sched = libxl_get_scheduler(ctx)) < 0) {
+
+        if ((ret = libxl_get_scheduler(ctx)) < 0) {
             fprintf(stderr, "get_scheduler sysctl failed.\n");
             goto out_cfg;
         }
+        sched = ret;
     }
 
     if (libxl_get_freecpus(ctx, &freemap)) {
-- 
1.7.10.4

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

end of thread, other threads:[~2014-03-21 16:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-21 12:25 [PATCH v2] tools/libxl: libxl_get_scheduler should return an int Julien Grall
2014-03-21 12:43 ` Ian Campbell
2014-03-21 14:31   ` Ian Jackson
2014-03-21 14:50   ` Julien Grall
2014-03-21 15:06     ` Ian Jackson
2014-03-21 14:28 ` Ian Jackson
2014-03-21 14:40   ` Julien Grall
2014-03-21 15:02     ` Ian Jackson
2014-03-21 15:14       ` Julien Grall
2014-03-21 15:21         ` Ian Jackson
2014-03-21 15:25           ` Julien Grall
2014-03-21 16:11   ` Ian Campbell

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.