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

Re: [Xen-devel] [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL



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;
>          }



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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