From nobody Mon Feb 9 08:29:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609952303; cv=none; d=zohomail.com; s=zohoarc; b=EGY/thOm3aoj9mYRIVKJTh7DwHwSX+OmE9NN9btQQP6vXQLqN7WaZygNRJNRNsg5vv3KIVwMR6xptHVWhf2MyEbMRpWAZGtfS3K/12/wexLw+zJcw/vhY94Ppl7WVIdpj8Ins2oijUMLaSXN+ISd0R4op9lT6oyYjfzZz6Hb3H4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609952303; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lhPQ+npMEDCMBH+dhaf3WduDDTSX2perTZ/vhUWB+4g=; b=QNMdQ5LNDx20Q0DigX/VY1N8ojdRcAyWjLvDh8eFbdHXb4cFQ85nxxuZZd6icdYAQPNGe3I35YxLUdIttNBRxxteYVzuqiPKakLo82BqahEXzl5SHxa7Fr0rV4nx/A5kXRt2Z72Fz5BKjylbAfHrjiVtgb20nd+JUc1xJBA8n6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1609952303791844.4800429094261; Wed, 6 Jan 2021 08:58:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-V7WAZbL5M2OAXgIUgItmJw-1; Wed, 06 Jan 2021 11:58:20 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CDF8100558A; Wed, 6 Jan 2021 16:58:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2354B1894E; Wed, 6 Jan 2021 16:58:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 40D071809C9F; Wed, 6 Jan 2021 16:58:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106Gw9Vn022388 for ; Wed, 6 Jan 2021 11:58:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 000961802E; Wed, 6 Jan 2021 16:58:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BB045C1C4 for ; Wed, 6 Jan 2021 16:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609952302; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lhPQ+npMEDCMBH+dhaf3WduDDTSX2perTZ/vhUWB+4g=; b=KgVjQBCo3pGWLeCgjl2CQ8z3ia6vrBRDqT85PXltxojsMBIHUxejfMiXo3sWw78VrK1y5o NAXcR5fq/p+CJ4sZ/szwywQ2MDKCDQkB3tUbD5LU/p2FkNHcDCaJpX8V+1Mp0gop61PGLX D0ADdiCEw9xpIVnVy6cNro4Tu4EG8ag= X-MC-Unique: V7WAZbL5M2OAXgIUgItmJw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] secretXMLParseNode: Clean up freeing of memory Date: Wed, 6 Jan 2021 17:57:56 +0100 Message-Id: <822109b44a36d227329ddd5528985bc3c5511280.1609952208.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use one variable per extracted property instead of reusing strings and drop needless VIR_FREE calls. Signed-off-by: Peter Krempa --- src/conf/secret_conf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 9cacc43e28..4d7d685d6e 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -131,7 +131,8 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) { g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virSecretDef) def =3D NULL; - g_autofree char *prop =3D NULL; + g_autofree char *ephemeralstr =3D NULL; + g_autofree char *privatestr =3D NULL; g_autofree char *uuidstr =3D NULL; if (!virXMLNodeNameEqual(root, "secret")) { @@ -149,24 +150,20 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) def =3D g_new0(virSecretDef, 1); - prop =3D virXPathString("string(./@ephemeral)", ctxt); - if (prop !=3D NULL) { - if (virStringParseYesNo(prop, &def->isephemeral) < 0) { + if ((ephemeralstr =3D virXPathString("string(./@ephemeral)", ctxt))) { + if (virStringParseYesNo(ephemeralstr, &def->isephemeral) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid value of 'ephemeral'")); return NULL; } - VIR_FREE(prop); } - prop =3D virXPathString("string(./@private)", ctxt); - if (prop !=3D NULL) { - if (virStringParseYesNo(prop, &def->isprivate) < 0) { + if ((privatestr =3D virXPathString("string(./@private)", ctxt))) { + if (virStringParseYesNo(privatestr, &def->isprivate) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid value of 'private'")); return NULL; } - VIR_FREE(prop); } uuidstr =3D virXPathString("string(./uuid)", ctxt); @@ -182,7 +179,6 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) "%s", _("malformed uuid element")); return NULL; } - VIR_FREE(uuidstr); } def->description =3D virXPathString("string(./description)", ctxt); --=20 2.29.2