From: Harmandeep Kaur <write.harmandeep@gmail.com>
To: xen-devel@lists.xenproject.org
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 <write.harmandeep@gmail.com>
Subject: [PATCH] libxl: fix handling returns in libxl_get_version_info()
Date: Thu, 11 Feb 2016 14:00:59 +0530 [thread overview]
Message-ID: <1455179459-3392-1-git-send-email-write.harmandeep@gmail.com> (raw)
Avoid handling issue of the return value of xc_version() in many cases.
Coverity ID 1351217
Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
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,
--
2.5.0
next reply other threads:[~2016-02-11 8:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 8:30 Harmandeep Kaur [this message]
2016-02-11 9:48 ` [PATCH] libxl: fix handling returns in libxl_get_version_info() Dario Faggioli
2016-02-11 10:21 ` Ian Campbell
2016-02-12 10:52 ` Harmandeep Kaur
2016-02-12 11:00 ` Dario Faggioli
2016-02-12 11:04 ` Harmandeep Kaur
2016-02-12 11:12 ` Dario Faggioli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455179459-3392-1-git-send-email-write.harmandeep@gmail.com \
--to=write.harmandeep@gmail.com \
--cc=dario.faggioli@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).