From patchwork Fri Jan 15 02:33:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 8037351 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 C13EEBEEE5 for ; Fri, 15 Jan 2016 02:37:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E581320501 for ; Fri, 15 Jan 2016 02:37:19 +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 1848F204FC for ; Fri, 15 Jan 2016 02:37:19 +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 1aJuDG-0004Vr-Mp; Fri, 15 Jan 2016 02:34:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJuDF-0004Vk-BL for xen-devel@lists.xenproject.org; Fri, 15 Jan 2016 02:34:05 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id E3/E0-13905-C9A58965; Fri, 15 Jan 2016 02:34:04 +0000 X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1452825242!15987801!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48733 invoked from network); 15 Jan 2016 02:34:03 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jan 2016 02:34:03 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u0F2XwBU029838 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 15 Jan 2016 02:33:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u0F2XvmP023398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 15 Jan 2016 02:33:57 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u0F2XvXo015137; Fri, 15 Jan 2016 02:33:57 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Jan 2016 18:33:57 -0800 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, ian.campbell@citrix.com, wei.liu2@citrix.com Date: Thu, 14 Jan 2016 21:33:49 -0500 Message-Id: <1452825229-15881-1-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.3 X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH] libxl: Use libxl_strdup instead of strdup on libxl_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.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 As the libxl_strdup allows us to unwind and free all of the allocations, while strdup requires the callers to remember to free (which they didn't seem too). Suggested-by: Wei Liu Signed-off-by: Konrad Rzeszutek Wilk --- tools/libxl/libxl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 9207621..03505ee 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5282,19 +5282,19 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->xen_version_minor = xen_version & 0xFF; xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra); - info->xen_version_extra = strdup(u.xen_extra); + info->xen_version_extra = libxl__strdup(NOGC, u.xen_extra); xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc); - info->compiler = strdup(u.xen_cc.compiler); - info->compile_by = strdup(u.xen_cc.compile_by); - info->compile_domain = strdup(u.xen_cc.compile_domain); - info->compile_date = strdup(u.xen_cc.compile_date); + 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); xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps); - info->capabilities = strdup(u.xen_caps); + info->capabilities = libxl__strdup(NOGC, u.xen_caps); xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset); - info->changeset = strdup(u.xen_chgset); + info->changeset = libxl__strdup(NOGC, u.xen_chgset); xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms); info->virt_start = u.p_parms.virt_start; @@ -5302,7 +5302,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL); xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); - info->commandline = strdup(u.xen_commandline); + info->commandline = libxl__strdup(NOGC, u.xen_commandline); return info; }