From: Marcin Cieslak Subject: [PATCH 2/4] libxl_get_scheduler() cannot return ERROR_FAIL Date: Sat, 13 Sep 2014 21:10:23 +0000 Message-ID: <1410642625-45876-2-git-send-email-saper@saper.info> References: <1410642625-45876-1-git-send-email-saper@saper.info> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XSuaX-0004kY-Tk for xen-devel@lists.xenproject.org; Sat, 13 Sep 2014 21:10:34 +0000 In-Reply-To: <1410642625-45876-1-git-send-email-saper@saper.info> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Marcin Cieslak List-Id: xen-devel@lists.xenproject.org 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