From patchwork Thu Feb 11 08:30:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harmandeep Kaur X-Patchwork-Id: 8277121 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 97444BEEE5 for ; Thu, 11 Feb 2016 08:35:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7B1120103 for ; Thu, 11 Feb 2016 08:35:03 +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 C355820376 for ; Thu, 11 Feb 2016 08:35:02 +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 1aTmfM-0005u7-4Z; Thu, 11 Feb 2016 08:31:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTmfK-0005u2-RL for xen-devel@lists.xenproject.org; Thu, 11 Feb 2016 08:31:55 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id E5/1C-25438-AF64CB65; Thu, 11 Feb 2016 08:31:54 +0000 X-Env-Sender: write.harmandeep@gmail.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1455179512!22939474!1 X-Originating-IP: [209.85.192.169] 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 36671 invoked from network); 11 Feb 2016 08:31:53 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Feb 2016 08:31:53 -0000 Received: by mail-pf0-f169.google.com with SMTP id x65so26078972pfb.1 for ; Thu, 11 Feb 2016 00:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2JgIz/cXi0QUeTGM+4HVYewUhxuCskBDa1McwRpmWxs=; b=XgbThLqQn3BooptlXZHtaWs3MwdygvMaVkPQDZi87DHM9VdrCs002QIOa8KIohStNv ZeJZ6RVZmVqbYBBC9zppXth304Sui1cmXc5N5iBCQvrEpSoIBMLEnyA4u+JVlwlK3zad rMq+QdHdt7EKaNpb3ospKEKoQAe/dRnzLmB3HMopY7RmB1Rak1I39KylckcFe5Q4rc0Z mmbTKzKyvqQeVbpStZtXID45KG4I3WRCW+bI3JX6efwx1ICucLJzGHOXRwuzG4g00cOS liSGPSuNPahCYqbCAGKNcLqqdns5sOf5Ee0qw00hhcxFEcV1UOmon6ENk/vBvz+3I/I5 qRkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2JgIz/cXi0QUeTGM+4HVYewUhxuCskBDa1McwRpmWxs=; b=WfIp1tdMi6q09fTuM1qLJDMbKe2nVZrbr9fg9NmJsJI/Vk2LuNVqKXhj0fHr/UJeyj XtY1JMyWJe9ZmcJFbAAxDqrzfDgMPrwmCrLcfcu8/wGn64Zthf6H6c43oSAxPGFXidvr gh+kFkiriWAxKaN97XTJbAsLPDpkBAEIsS9YfLTCUOkHqXw5CrrcYu/gAt1JjYAN4iEC 2y9zPL3kDT5RonmHjb+A1e18S6uCS/64ZGJhb5tlyXdu4XOCqntIKDt4jUj5xwo/rocg HyyxemMXgS8hwAjaDxzlL18WpNqtFuV/FmRBilBZ+hPjM/IjlFIzcYjl7rRE68vvM4XY GRKA== X-Gm-Message-State: AG10YOTCE+IYAO9hTs2Dj5cYCP6nod1DfHODH4CKUZicn+rzTuXPqT0SuaNM/omoEaTDWw== X-Received: by 10.98.66.157 with SMTP id h29mr64605321pfd.91.1455179511750; Thu, 11 Feb 2016 00:31:51 -0800 (PST) Received: from localhost.localdomain ([124.253.95.243]) by smtp.googlemail.com with ESMTPSA id 19sm10339648pfb.64.2016.02.11.00.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 00:31:51 -0800 (PST) From: Harmandeep Kaur To: xen-devel@lists.xenproject.org Date: Thu, 11 Feb 2016 14:00:59 +0530 Message-Id: <1455179459-3392-1-git-send-email-write.harmandeep@gmail.com> X-Mailer: git-send-email 2.5.0 Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Harmandeep Kaur Subject: [Xen-devel] [PATCH] libxl: fix handling returns in libxl_get_version_info() 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 Avoid handling issue of the return value of xc_version() in many cases. Coverity ID 1351217 Signed-off-by: Harmandeep Kaur --- tools/libxl/libxl.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2d18b8d..a939e51 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5267,42 +5267,63 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) xen_platform_parameters_t p_parms; xen_commandline_t xen_commandline; } u; + int rc; long xen_version; libxl_version_info *info = &ctx->version_info; if (info->xen_version_extra != NULL) goto out; - xen_version = xc_version(ctx->xch, XENVER_version, NULL); + rc = xen_version = xc_version(ctx->xch, XENVER_version, NULL); + if ( rc < 0 ) + goto out; + info->xen_version_major = xen_version >> 16; info->xen_version_minor = xen_version & 0xFF; + rc = xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra); info->xen_version_extra = libxl__strdup(NOGC, u.xen_extra); + rc = xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc); info->compiler = libxl__strdup(NOGC, u.xen_cc.compiler); info->compile_by = libxl__strdup(NOGC, u.xen_cc.compile_by); info->compile_domain = libxl__strdup(NOGC, u.xen_cc.compile_domain); info->compile_date = libxl__strdup(NOGC, u.xen_cc.compile_date); + rc = xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps); info->capabilities = libxl__strdup(NOGC, u.xen_caps); + rc = xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset); info->changeset = libxl__strdup(NOGC, u.xen_chgset); + rc = xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms); info->virt_start = u.p_parms.virt_start; + rc = info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL); + if ( rc < 0 ) + goto out; - info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL); + rc = xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); + if ( rc < 0 ) + goto out; - xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); info->commandline = libxl__strdup(NOGC, u.xen_commandline); out: GC_FREE; - return info; + if ( rc < 0 ) + return NULL; + else + return info; } libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,