xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Marcin Cieslak <saper@saper.info>
To: xen-devel@lists.xenproject.org
Cc: Marcin Cieslak <saper@saper.info>
Subject: [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL
Date: Sat, 13 Sep 2014 21:10:23 +0000	[thread overview]
Message-ID: <1410642625-45876-2-git-send-email-saper@saper.info> (raw)
In-Reply-To: <1410642625-45876-1-git-send-email-saper@saper.info>

ERROR_FAIL (-3) is not a proper value for
libxl_scheduler enum.
Use LIBXL_SCHEDULER_UNKNOWN (0) instead.

Clang complains otherwise:

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

C99 does not guarantee that enums are ints (they
can be unsigned).
---
 tools/libxl/libxl.c      | 2 +-
 tools/libxl/xl_cmdimpl.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index ad3495a..785a1e7 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4957,7 +4957,7 @@ libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
 
     if ((ret = xc_sched_id(ctx->xch, (int *)&sched)) != 0) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
-        return ERROR_FAIL;
+        return LIBXL_SCHEDULER_UNKNOWN;
     }
     return sched;
 }
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 8a38077..86daf8e 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4821,7 +4821,7 @@ static void output_xeninfo(void)
         return;
     }
 
-    if ((sched = libxl_get_scheduler(ctx)) < 0) {
+    if ((sched = libxl_get_scheduler(ctx)) == LIBXL_SCHEDULER_UNKNOWN) {
         fprintf(stderr, "get_scheduler sysctl failed.\n");
         return;
     }
@@ -6702,7 +6702,7 @@ int main_cpupoolcreate(int argc, char **argv)
             goto out_cfg;
         }
     } else {
-        if ((sched = libxl_get_scheduler(ctx)) < 0) {
+        if ((sched = libxl_get_scheduler(ctx)) == LIBXL_SCHEDULER_UNKNOWN) {
             fprintf(stderr, "get_scheduler sysctl failed.\n");
             goto out_cfg;
         }
-- 
2.0.2

  reply	other threads:[~2014-09-13 21:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-13 21:10 [PATCH 1/4] Use proper header guard for <ufs/ufs.h> Marcin Cieslak
2014-09-13 21:10 ` Marcin Cieslak [this message]
2014-09-16 16:27   ` [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL Ian Campbell
2014-09-13 21:10 ` [PATCH 3/4] libxl: shutdown_reason cannot be unsigned Marcin Cieslak
2014-09-16 18:43   ` Julien Grall
2014-09-13 21:10 ` [PATCH 4/4] libxl: Use yajl_gen_status_ok where appropriate Marcin Cieslak
2014-09-16 16:29   ` Ian Campbell
2014-09-16 16:23 ` [PATCH 1/4] Use proper header guard for <ufs/ufs.h> Ian Campbell
2014-09-16 16:28   ` 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=1410642625-45876-2-git-send-email-saper@saper.info \
    --to=saper@saper.info \
    --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 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).