From nobody Sun Feb 8 09:32:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1667311333; cv=none; d=zohomail.com; s=zohoarc; b=QquFYIbvoJIIRvq6Y2gVRtQEExMU5QjN2fUPlkJo8XZhV1XjzBO1Z1mORou4d8siI5vVQAhVKlGowEKWOC2q2sg2rT2bpEUOKGk8eU9YyheETWdSKN4AD2qFeK6Y8mwZu13MgchYkk3Kcx2PYaYvPNvtVjRXZ4vNFhTeJHOYPGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667311333; 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=US7VsMgblVCkf+2IG0SFv9cJVcMVJgDi7V6G9smKoJc=; b=ixy+uejAtJpL133Uag+s1SpAK7kgBQZ9I1ihD/c6+6+vpMuTVeZ3uj189p59e1rgRRBWZ+uHC05n3ZoFC2Xm/h5HglHRhm2QVoaBtGYl2f13vU/asHgYLUNqSV3CQky5Sjk1sNw6GzA96jgTrOIQM89CawqzC+ke3YfrAy+lkAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1667311333277178.07755817039754; Tue, 1 Nov 2022 07:02:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-z6UHWAy3PPC594O0GtQBZg-1; Tue, 01 Nov 2022 10:02:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39D7E1C0A135; Tue, 1 Nov 2022 14:01:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2509640C83EC; Tue, 1 Nov 2022 14:01:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F21291946A42; Tue, 1 Nov 2022 14:01:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9FDA31946A74 for ; Tue, 1 Nov 2022 14:01:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9602C2022C3D; Tue, 1 Nov 2022 14:01:55 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1BD12028DC1 for ; Tue, 1 Nov 2022 14:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667311332; 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=US7VsMgblVCkf+2IG0SFv9cJVcMVJgDi7V6G9smKoJc=; b=E34QvOOhlxBcb/3DHPsydsRlD9vfsV6HrJTUiEgeu0SLX59tygiZheOOXW1gwhZ4zOA9Yf jVRBqEBF/roLUTN8CEH/HGFkjeSuyCgAePuZpkvTjKAb/uDhwewbjCYGVijmFq/u9dFkKV 6Pq4+0ONqW2WgwL5pXiiKhquHjTh7Ss= X-MC-Unique: z6UHWAy3PPC594O0GtQBZg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/12] util: xml: Refactor cleanup path in virXMLValidatorInit Date: Tue, 1 Nov 2022 15:01:41 +0100 Message-Id: <623dc1b4e20522ff5ee356d472bf06d9a9ad4a52.1667310693.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667311334210100001 Content-Type: text/plain; charset="utf-8" Automatically free 'validator' on errors. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 35c0340779..e9595da97d 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1608,7 +1608,7 @@ virXMLValidatorRNGErrorIgnore(void *ctx G_GNUC_UNUSED, virXMLValidator * virXMLValidatorInit(const char *schemafile) { - virXMLValidator *validator =3D NULL; + g_autoptr(virXMLValidator) validator =3D NULL; validator =3D g_new0(virXMLValidator, 1); @@ -1619,7 +1619,7 @@ virXMLValidatorInit(const char *schemafile) virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to create RNG parser for %s"), validator->schemafile); - goto error; + return NULL; } xmlRelaxNGSetParserErrors(validator->rngParser, @@ -1632,25 +1632,22 @@ virXMLValidatorInit(const char *schemafile) _("Unable to parse RNG %s: %s"), validator->schemafile, virBufferCurrentContent(&validator->buf)); - goto error; + return NULL; } if (!(validator->rngValid =3D xmlRelaxNGNewValidCtxt(validator->rng)))= { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to create RNG validation context %s"), validator->schemafile); - goto error; + return NULL; } xmlRelaxNGSetValidErrors(validator->rngValid, virXMLValidatorRNGErrorCatch, virXMLValidatorRNGErrorIgnore, &validator->buf); - return validator; - error: - virXMLValidatorFree(validator); - return NULL; + return g_steal_pointer(&validator); } --=20 2.38.1