xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Marcin Cieslak <saper@saper.info>
Cc: xen-devel@lists.xenproject.org, Julien Grall <julien.grall@linaro.org>
Subject: Re: [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL
Date: Tue, 16 Sep 2014 17:27:26 +0100	[thread overview]
Message-ID: <1410884846.23505.5.camel@citrix.com> (raw)
In-Reply-To: <1410642625-45876-2-git-send-email-saper@saper.info>

On Sat, 2014-09-13 at 21:10 +0000, Marcin Cieslak wrote:
> ERROR_FAIL (-3) is not a proper value for
> libxl_scheduler enum.
> Use LIBXL_SCHEDULER_UNKNOWN (0) instead.

This came up before, see [0,1] we decided instead that this function
should return an int, I think Julien simply hasn't found the time to
revisit that after the comments on the v2 patch.

[0] http://lists.xen.org/archives/html/xen-devel/2014-03/msg02476.html
[1] http://lists.xen.org/archives/html/xen-devel/2014-03/msg02759.html
> 
> 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;
>          }

  reply	other threads:[~2014-09-16 16:27 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 ` [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL Marcin Cieslak
2014-09-16 16:27   ` Ian Campbell [this message]
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=1410884846.23505.5.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=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).