From patchwork Fri Mar 21 12:25:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 26826 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D68CE20143 for ; Fri, 21 Mar 2014 12:26:50 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j7sf4716008qaq.10 for ; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=gI+ewWYVt/oHmxvwP15bNakBUwpU4GT+Bfkp/Be9Cjg=; b=WLt8scRmpOIXOPK7ZqgvHOcn4xJA/grm44sMOrTBUH1xchkJvpgj4h+Bup3nhvp3Co RgYKvyP5lof6QQzITFSrm0uoOmTf/xdpiQIBkz+gfKnZYXktrCDDFhrOwrToDNbocfP2 ifrWQk3wsrpJ5aG9FjVltLmS5hd+UlOGLiaEJsnKG6Sr9fZ4uKz81j4lLSDcCmfdmjut HKwWK2HdPX9ixyAHZgXbjyETVXiQoT0CV5OlurWkiMH3S824RG3YHoYTMxEN7M3cH6AP Hh7q80MdTPxhYOZ+SDq397SLapfDTeqJhNz5p1wkCxn7ipJkFO2XtS6IgR0TV2MARsNM 11AQ== X-Gm-Message-State: ALoCoQmw52d9ZhiwGfuxv26FD/9rUCCXeAmFLZSfGjW1uMbGtGzT/rLhYAKRMD2k7YBPRML8jFVE X-Received: by 10.236.86.67 with SMTP id v43mr11596283yhe.41.1395404810662; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.213 with SMTP id 79ls617177qgl.35.gmail; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-Received: by 10.58.221.102 with SMTP id qd6mr630165vec.47.1395404810498; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id ys15si14488vcb.178.2014.03.21.05.26.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 05:26:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so2398168veb.25 for ; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-Received: by 10.52.180.98 with SMTP id dn2mr177308vdc.58.1395404810416; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp26759vck; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) X-Received: by 10.140.102.2 with SMTP id v2mr55276015qge.27.1395404810039; Fri, 21 Mar 2014 05:26:50 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u89si894208qga.83.2014.03.21.05.26.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Mar 2014 05:26:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WQyWE-0003eB-Ag; Fri, 21 Mar 2014 12:25:50 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WQyWC-0003e4-UR for xen-devel@lists.xenproject.org; Fri, 21 Mar 2014 12:25:49 +0000 Received: from [85.158.137.68:62362] by server-13.bemta-3.messagelabs.com id 70/CA-18692-CCF2C235; Fri, 21 Mar 2014 12:25:48 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1395404747!2114112!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24029 invoked from network); 21 Mar 2014 12:25:47 -0000 Received: from mail-ee0-f41.google.com (HELO mail-ee0-f41.google.com) (74.125.83.41) by server-14.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 21 Mar 2014 12:25:47 -0000 Received: by mail-ee0-f41.google.com with SMTP id t10so1764206eei.0 for ; Fri, 21 Mar 2014 05:25:46 -0700 (PDT) X-Received: by 10.14.218.193 with SMTP id k41mr47470307eep.16.1395404746801; Fri, 21 Mar 2014 05:25:46 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id w6sm11268699eex.9.2014.03.21.05.25.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Mar 2014 05:25:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 21 Mar 2014 12:25:43 +0000 Message-Id: <1395404743-13833-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 Cc: stefano.stabellini@citrix.com, Julien Grall , ian.jackson@eu.citrix.com, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v2] tools/libxl: libxl_get_scheduler should return an int X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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 --- 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)) {