From nobody Mon Feb 9 16:45:21 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=1620650943; cv=none; d=zohomail.com; s=zohoarc; b=cc9E1TRLAyISfa5J0VdLwmlTPJYMyTp68ZV0oQ9EwaRitfWQsdpW5DE/EAbFs4xkaM8b5tvtN5UAIV6GRIo0026mS1GsOPtgDMRFp8IwWmSW1OLVGWelKP+hCWybzxTyhLrO7SLGoVJBujLUEwQ8PoULH1hshYLwKYGI+cux5Pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620650943; h=Content-Type:Content-Transfer-Encoding:Cc: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=fxzyWr56YqYhEULI+1ic4/xQHhRWVlJQ/UYz4CgUbRc=; b=YRFBg7hBHT8DsbqAYRVzKw6N1tf7SUiZ0jNDuKHdAohf4xi7hh1ki69mAb3+i6h6Go9GVxCjjWoqvMBfjk2IZrrRhVqcTqXJMoU/QtnFJ1raBdyY4UnZ5mySpdIyBpSsLteLWpffUxGf2WQLqU6uGlAHeo1EcKpVHkDG94M54eM= 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 1620650942749174.74052268233027; Mon, 10 May 2021 05:49:02 -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-47-vWCI0JNEN0Kbm9TuVEiDWw-1; Mon, 10 May 2021 08:48:57 -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 84F811854E26; Mon, 10 May 2021 12:48:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 366D561094; Mon, 10 May 2021 12:48:51 +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 26D5344A65; Mon, 10 May 2021 12:48:50 +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 14ACmmVJ005600 for ; Mon, 10 May 2021 08:48:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84F1E1724D; Mon, 10 May 2021 12:48:48 +0000 (UTC) Received: from work.redhat.com (ovpn-113-46.ams2.redhat.com [10.36.113.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id B608C2C6FB; Mon, 10 May 2021 12:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620650941; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=fxzyWr56YqYhEULI+1ic4/xQHhRWVlJQ/UYz4CgUbRc=; b=BDHBgPZfm8SXI12EOEiqWFSgzWZHOQA7/dxPVamJ1x5C5dKG8EVr/H2j5JQKwFd6GJvtrd X53BrdI3hQAeryUT0ufHIG7YiYGAuF0ASI4+RZMuC4Y+acHrpuN7FfQN4l8bpIt7GxV649 zQVZKuF0qZd+6dFG3wfArXigF1jLT6U= X-MC-Unique: vWCI0JNEN0Kbm9TuVEiDWw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] virDomainObjParseXML: Use g_autoptr Date: Mon, 10 May 2021 14:48:33 +0200 Message-Id: <20210510124841.123066-3-twiederh@redhat.com> In-Reply-To: <20210510124841.123066-1-twiederh@redhat.com> References: <20210510124841.123066-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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" Signed-off-by: Tim Wiederhake --- src/conf/domain_conf.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0d396cbdda..7044701fac 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20351,7 +20351,7 @@ virDomainObjParseXML(xmlDocPtr xml, long val; xmlNodePtr config; xmlNodePtr oldnode; - virDomainObj *obj; + g_autoptr(virDomainObj) obj =3D NULL; size_t i; int n; virDomainState state; @@ -20367,7 +20367,7 @@ virDomainObjParseXML(xmlDocPtr xml, if (!(config =3D virXPathNode("./domain", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no domain config")); - goto error; + return NULL; } =20 oldnode =3D ctxt->node; @@ -20375,17 +20375,17 @@ virDomainObjParseXML(xmlDocPtr xml, obj->def =3D virDomainDefParseXML(xml, ctxt, xmlopt, flags); ctxt->node =3D oldnode; if (!obj->def) - goto error; + return NULL; =20 if (virXMLPropEnum(ctxt->node, "state", virDomainStateTypeFromString, VIR_XML_PROP_REQUIRED, &state) < 0) - goto error; + return NULL; =20 if ((tmp =3D virXMLPropString(ctxt->node, "reason"))) { if ((reason =3D virDomainStateReasonFromString(state, tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state reason '%s'"), tmp); - goto error; + return NULL; } } =20 @@ -20394,12 +20394,12 @@ virDomainObjParseXML(xmlDocPtr xml, if (virXPathLong("string(./@pid)", ctxt, &val) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid pid")); - goto error; + return NULL; } obj->pid =3D (pid_t)val; =20 if ((n =3D virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0) - goto error; + return NULL; for (i =3D 0; i < n; i++) { int rc; virDomainTaintFlags taint; @@ -20407,14 +20407,14 @@ virDomainObjParseXML(xmlDocPtr xml, if ((rc =3D virXMLPropEnum(taintNodes[i], "flag", virDomainTaintTypeFromString, VIR_XML_PROP_NONE, &taint)) < 0) - goto error; + return NULL; =20 if (rc =3D=3D 1) virDomainObjTaint(obj, taint); } =20 if ((n =3D virXPathNodeSet("./deprecation", ctxt, &depNodes)) < 0) - goto error; + return NULL; for (i =3D 0; i < n; i++) { g_autofree char *str =3D virXMLNodeContentString(depNodes[i]); virDomainObjDeprecation(obj, str); @@ -20422,24 +20422,20 @@ virDomainObjParseXML(xmlDocPtr xml, =20 if (xmlopt->privateData.parse && xmlopt->privateData.parse(ctxt, obj, &xmlopt->config) < 0) - goto error; + return NULL; =20 if (xmlopt->privateData.getParseOpaque) parseOpaque =3D xmlopt->privateData.getParseOpaque(obj); =20 /* callback to fill driver specific domain aspects */ if (virDomainDefPostParse(obj->def, flags, xmlopt, parseOpaque) < 0) - goto error; + return NULL; =20 /* validate configuration */ if (virDomainDefValidate(obj->def, flags, xmlopt, parseOpaque) < 0) - goto error; - - return obj; + return NULL; =20 - error: - virObjectUnref(obj); - return NULL; + return g_steal_pointer(&obj); } =20 =20 --=20 2.26.3