From patchwork Tue Jan 19 05:58:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 8058281 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EEFC0BEEE5 for ; Tue, 19 Jan 2016 06:01:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2614D203FB for ; Tue, 19 Jan 2016 06:01:09 +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 4F1E7203F3 for ; Tue, 19 Jan 2016 06:01:08 +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 1aLPJP-000635-J2; Tue, 19 Jan 2016 05:58:39 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLPJO-00062o-5j for xen-devel@lists.xen.org; Tue, 19 Jan 2016 05:58:38 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 6F/62-07165-D80DD965; Tue, 19 Jan 2016 05:58:37 +0000 X-Env-Sender: czylin@uwaterloo.ca X-Msg-Ref: server-14.tower-27.messagelabs.com!1453183115!17698447!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 61650 invoked from network); 19 Jan 2016 05:58:36 -0000 Received: from mailservices.uwaterloo.ca (HELO minos.uwaterloo.ca) (129.97.128.141) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Jan 2016 05:58:36 -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 u0J5wNqf022179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jan 2016 00:58:27 -0500 From: Chester Lin To: xen-devel@lists.xen.org Date: Tue, 19 Jan 2016 00:58:20 -0500 Message-Id: <1453183100-50700-1-git-send-email-czylin@uwaterloo.ca> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1451925649.13361.193.camel@citrix.com> References: <1451925649.13361.193.camel@citrix.com> X-UUID: dbc7d674-51b5-48ff-a9c3-02186fa11fae Cc: ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, george.dunlap@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Chester Lin , jtotto@uwaterloo.ca, hjarmstr@uwaterloo.ca Subject: [Xen-devel] [PATCH v2 5/5] libxl: Add explicit cast to libxl_psr_cat_set_cbm 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 Fixes Coverity CID 1343299. The call to xc_psr_cat_set_domain_data() expects type xc_psr_cat_type but is provided libxl_psr_cbm_type which is defined in IDL. The two enums are deliberately identical and IDL only exists so that libxl clients don't need to include libxc headers directly. This change adds an explicit cast to fix the Coverity warning, and tweaks the surrounding code to more closely conform to the guidelines in CODING_STYLE. No functional changes. Signed-off-by: Chester Lin Reviewed-by: Dario Faggioli --- Changed commit message to say that the enums are identical --- tools/libxl/libxl_psr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c index 3d0dc61..1677f9c 100644 --- a/tools/libxl/libxl_psr.c +++ b/tools/libxl/libxl_psr.c @@ -298,7 +298,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid, uint64_t cbm) { GC_INIT(ctx); - int rc; + int rc, r; int socketid, nr_sockets; rc = libxl__count_physical_sockets(gc, &nr_sockets); @@ -310,7 +310,9 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid, libxl_for_each_set_bit(socketid, *target_map) { if (socketid >= nr_sockets) break; - if (xc_psr_cat_set_domain_data(ctx->xch, domid, type, socketid, cbm)) { + r = xc_psr_cat_set_domain_data(ctx->xch, domid, (xc_psr_cat_type) type, + socketid, cbm); + if (r) { libxl__psr_cat_log_err_msg(gc, errno); rc = ERROR_FAIL; } @@ -326,11 +328,14 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid, uint64_t *cbm_r) { GC_INIT(ctx); - int rc = 0; - - if (xc_psr_cat_get_domain_data(ctx->xch, domid, type, target, cbm_r)) { + int rc, r; + r = xc_psr_cat_get_domain_data(ctx->xch, domid, (xc_psr_cat_type) type, + target, cbm_r); + if (r) { libxl__psr_cat_log_err_msg(gc, errno); rc = ERROR_FAIL; + } else { + rc = 0; } GC_FREE;