From nobody Sun Feb 8 19:59:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568636271; cv=none; d=zoho.com; s=zohoarc; b=X+6qSBVfWlpeHVxSzBxIIG6PoCGslDB+v1tztrfUlfcoOvNCKH/a+Zr7zq4XQbbBQpGOA87I2nbPKXct8Ja7SV+OomfCey/IAFyby3UYWNuUDIAjJEeDHw//JAJpcJwhmn6vJcqeo4/io1rqp7wwq4NEHK6Sk2OePZx/2U8vt2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568636271; 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:ARC-Authentication-Results; bh=sMCkw9SzFnmC6ArAD/BocV51EI5m4vb8OKtPA/nj04Q=; b=ZS3OCiMHmXoZ9lPG0EmIy7ki4h42Ad/L16XrSoG1QuuX9UZz2xbmrvVjM7SPUGxjTtPUgJEIWHvgpy1ANv5rsUVgvYDByWfl7T457ef7nwedUh9CGqXjDHcbZPcKcQFJPaGa3nm7bbkskrxmB/SZ2KRzS1L/f3asB1A/M0ktQ/o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568636271371665.2392670943506; Mon, 16 Sep 2019 05:17:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3E29C8A1C95; Mon, 16 Sep 2019 12:17:49 +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 183B56012C; Mon, 16 Sep 2019 12:17:49 +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 CF749180BA9B; Mon, 16 Sep 2019 12:17:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCHSgh024562 for ; Mon, 16 Sep 2019 08:17:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9615F196AE; Mon, 16 Sep 2019 12:17:28 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FAEE4115 for ; Mon, 16 Sep 2019 12:17:27 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:17:12 +0200 Message-Id: <39e980ad75e4597282e1bee8a93fedb812feca07.1568636165.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 9/9] conf: secret: Refactor cleanup in secretXMLParseNode 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 16 Sep 2019 12:17:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use VIR_AUTO* for temporary locals and get rid of the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/secret_conf.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index a7691da7b5..da61c6917e 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -131,33 +131,33 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, static virSecretDefPtr secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) { - xmlXPathContextPtr ctxt =3D NULL; - virSecretDefPtr def =3D NULL, ret =3D NULL; - char *prop =3D NULL; - char *uuidstr =3D NULL; + VIR_AUTOPTR(xmlXPathContext) ctxt =3D NULL; + VIR_AUTOPTR(virSecretDef) def =3D NULL; + VIR_AUTOFREE(char *) prop =3D NULL; + VIR_AUTOFREE(char *) uuidstr =3D NULL; if (!virXMLNodeNameEqual(root, "secret")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), root->name); - goto cleanup; + return NULL; } if (!(ctxt =3D virXMLXPathContextNew(xml))) - goto cleanup; + return NULL; ctxt->node =3D root; if (VIR_ALLOC(def) < 0) - goto cleanup; + return NULL; prop =3D virXPathString("string(./@ephemeral)", ctxt); if (prop !=3D NULL) { if (virStringParseYesNo(prop, &def->isephemeral) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid value of 'ephemeral'")); - goto cleanup; + return NULL; } VIR_FREE(prop); } @@ -167,7 +167,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) if (virStringParseYesNo(prop, &def->isprivate) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid value of 'private'")); - goto cleanup; + return NULL; } VIR_FREE(prop); } @@ -177,13 +177,13 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); - goto cleanup; + return NULL; } } else { if (virUUIDParse(uuidstr, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed uuid element")); - goto cleanup; + return NULL; } VIR_FREE(uuidstr); } @@ -191,15 +191,9 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) def->description =3D virXPathString("string(./description)", ctxt); if (virXPathNode("./usage", ctxt) !=3D NULL && virSecretDefParseUsage(ctxt, def) < 0) - goto cleanup; - VIR_STEAL_PTR(ret, def); - - cleanup: - VIR_FREE(prop); - VIR_FREE(uuidstr); - virSecretDefFree(def); - xmlXPathFreeContext(ctxt); - return ret; + return NULL; + + VIR_RETURN_PTR(def); } static virSecretDefPtr --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list