From patchwork Mon Jan 25 00:45:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 8102741 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C45979F6DA for ; Mon, 25 Jan 2016 00:48:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB83E20386 for ; Mon, 25 Jan 2016 00:48:32 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0CA420382 for ; Mon, 25 Jan 2016 00:48:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aNVII-00059A-4C; Mon, 25 Jan 2016 00:46:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aNVIF-00057y-MY for xen-devel@lists.xen.org; Mon, 25 Jan 2016 00:46:07 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 13/D1-13905-94075A65; Mon, 25 Jan 2016 00:46:01 +0000 X-Env-Sender: czylin@uwaterloo.ca X-Msg-Ref: server-12.tower-206.messagelabs.com!1453682760!17819774!1 X-Originating-IP: [129.97.128.141] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29561 invoked from network); 25 Jan 2016 00:46:01 -0000 Received: from mailservices.uwaterloo.ca (HELO minos.uwaterloo.ca) (129.97.128.141) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Jan 2016 00:46:01 -0000 Received: from ubuntu1204-004.student.cs.uwaterloo.ca (ubuntu1204-004.student.cs.uwaterloo.ca [129.97.167.42]) (authenticated bits=0) by minos.uwaterloo.ca (8.14.4/8.14.4) with ESMTP id u0P0jqML029260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 24 Jan 2016 19:45:56 -0500 From: Chester Lin To: xen-devel@lists.xen.org Date: Sun, 24 Jan 2016 19:45:51 -0500 Message-Id: <1453682751-34615-1-git-send-email-czylin@uwaterloo.ca> X-Mailer: git-send-email 1.7.9.5 X-UUID: cd50a97e-fd07-4a04-b86d-59924818f941 Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Chester Lin , jtotto@uwaterloo.ca, hjarmstr@uwaterloo.ca Subject: [Xen-devel] [PATCH v3 2/5] libxl: make GC_FREE reachable in libxl_get_scheduler() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Coverity CID 1343309 Make GC_FREE reachable in all cases in libxl_get_scheduler() by eliminating the error-path return and instead storing the error code in the returned variable. To make this semantically consistent, change the return type of libxl_get_scheduler() from libxl_scheduler to int, and make a note of the interpretation of the return value in libxl.h. N.B. This change does not change the API in a way that affects functionality. The libxl_scheduler enum is consistent with the sched_id return value of xc_sched_id and this must continue to be true. Suggested-by: Ian Campbell Signed-off-by: Chester Lin Reviewed-by: Dario Faggioli Acked-by: Ian Campbell --- Changed return type of libxl_get_scheduler in order to return both negative error constants and positive scheduler values. --- tools/libxl/libxl.c | 5 ++--- tools/libxl/libxl.h | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 9c3cb3e..5a450ef 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5582,7 +5582,7 @@ out: return rc; } -libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx) +int libxl_get_scheduler(libxl_ctx *ctx) { int r, sched; @@ -5590,8 +5590,7 @@ libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx) r = xc_sched_id(ctx->xch, &sched); if (r != 0) { LOGE(ERROR, "getting current scheduler id"); - return ERROR_FAIL; - GC_FREE; + sched = ERROR_FAIL; } GC_FREE; return sched; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 7114491..09fcef3 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1711,7 +1711,10 @@ 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); +/* A return value less than 0 should be interpreted as a libxl_error, while a + * return value greater than or equal to 0 should be interpreted as a + * libxl_scheduler. */ +int libxl_get_scheduler(libxl_ctx *ctx); /* Per-scheduler parameters */ int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid,