From nobody Mon Feb 9 06:34:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618560476; cv=none; d=zohomail.com; s=zohoarc; b=Oje8Qv++oGRw8eiQ7eguRSlpfpPb7jgqRpSWQ5EgjGOmCwQmQCLlfCzD1Ht3cPBxLxUHiLz/qQiOcrDHWp7z3z5DSXrgX+xWYD3BTSQrzGLHrF5VbJB1auqVqQz2ezh+b5Wj89GwOuUamB9t2rYisVhnGdppBFAXV1qHPmKLtHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560476; 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=pb/dHtkeJzwraxCzigP2aFUu54Pt0OgPfKWHUz+K2GM=; b=K7s2RnrfNrwGNyBO1bWeWqKyDK4Hl0cVcd/g8tn9I3xGDA3Wmk2HUDxe8z2oxbzlFiKiyYiXqUBXIrUDLQt8kJI3XN8l10aqjk8C62r2WBwtYECBm+M2E5yfOe6Wb8gXEBtI4EStTswbNkXvPCW2B/EWgBLMUB0sXg6UGAG89W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618560476944444.3212613622836; Fri, 16 Apr 2021 01:07:56 -0700 (PDT) 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-550-drDm-SVoO2eGNJ2JVRQW7Q-1; Fri, 16 Apr 2021 04:07:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F8EB81747A; Fri, 16 Apr 2021 08:07:46 +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 0FE10610AF; Fri, 16 Apr 2021 08:07:46 +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 CC0881806D19; Fri, 16 Apr 2021 08:07:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13G87JkN026111 for ; Fri, 16 Apr 2021 04:07:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 529D56A046; Fri, 16 Apr 2021 08:07:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92F3F6A04C for ; Fri, 16 Apr 2021 08:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560474; 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=pb/dHtkeJzwraxCzigP2aFUu54Pt0OgPfKWHUz+K2GM=; b=R+wF4ZCPXq0Ke6EcHgsvb3JXcEIvN4EP4CkaxbD+mTof7/oA/mA+x5uM84YmrJvGoyy0YI FCtVljiiVwhZdWl6lOVB1H5QP7CCZXYzsgxqqQpksjDVmwkDBPamW8sqU3kY2eJ7dgQYjG /V4NjNpML2Z7n8JZpxD+5YkN5uUaeOU= X-MC-Unique: drDm-SVoO2eGNJ2JVRQW7Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] virXMLParseHelper: Refactor cleanup Date: Fri, 16 Apr 2021 10:07:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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" Switch @xml and @pctxt to g_autofree and get rid of the "error" and "cleanup" labels. Signed-off-by: Peter Krempa --- src/util/virxml.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 029b3d646e..58d640546f 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -786,8 +786,8 @@ virXMLParseHelper(int domcode, xmlXPathContextPtr *ctxt) { struct virParserData private; - xmlParserCtxtPtr pctxt; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlParserCtxt) pctxt =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; const char *docname; if (filename) @@ -823,32 +823,24 @@ virXMLParseHelper(int domcode, docname); } - goto error; + return NULL; } if (xmlDocGetRootElement(xml) =3D=3D NULL) { virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); - goto error; + + return NULL; } if (ctxt) { if (!(*ctxt =3D virXMLXPathContextNew(xml))) - goto error; + return NULL; (*ctxt)->node =3D xmlDocGetRootElement(xml); } - cleanup: - xmlFreeParserCtxt(pctxt); - - return xml; - - error: - xmlFreeDoc(xml); - xml =3D NULL; - - goto cleanup; + return g_steal_pointer(&xml); } const char *virXMLPickShellSafeComment(const char *str1, const char *str2) --=20 2.30.2