From nobody Tue Feb 10 07:39:05 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=1620745586; cv=none; d=zohomail.com; s=zohoarc; b=D19YHrCoGn3zZvzIlRbQgSqKr3ljX91Dy9+wejMbbpmemnuoix27YiSLq+FMEIyivRIynDHC/s+PKSdxnzduclWzc3dWXubkvrs8MkbuGPKUEsZR+KBPwhRYxKVa5wcxCLCSuyp40weZf8YOmiPiXpwhQBJPagKq2Ynebyha81A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745586; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=Wu5WNqcKSN8SRz0GuIgdHEuWfOLLbT82xeWnI2g+SpM362sLHoX74MnOR+RwpSY/fAeHvoCdSuQLRu1OZ5XjoITXtShjt66Bf58yd6tzy8nJt0WiaBdsc6ftFRSgjFCV+eja5QXbXtHPKNI03pxGWaKs0x2k3iBrQvHSYaS0rRM= 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 16207455862521017.6037570666548; Tue, 11 May 2021 08:06:26 -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-261-sAKzJqmCM82Uwk60w1FwRg-1; Tue, 11 May 2021 11:02:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0BC9818426; Tue, 11 May 2021 15:02:13 +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 954EA5D9E3; Tue, 11 May 2021 15:02: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 17D9655344; Tue, 11 May 2021 15:02:13 +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 14BF1xZ3005477 for ; Tue, 11 May 2021 11:01:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9E8360CDE; Tue, 11 May 2021 15:01:59 +0000 (UTC) Received: from work.redhat.com (ovpn-113-41.ams2.redhat.com [10.36.113.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 409C01B427; Tue, 11 May 2021 15:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745344; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=B0ed1D2D8lxP6xxAEWAYjktkkiySUvnaR2c6oHQSA1smJDLLbS++c0LMpy7SbfWRZYoVbv a/vPxFZCtrr1TVbx5h9odwQ9bXTIg3Z785Uvxsp8po7GXJolp1B89ve5yMKeIotlz3KCk+ EqWBgSwXA8UM8LOQ8B3JcnJSEkmmlDE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745585; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=jM0CCNsMKuvTet/tRtWTD0stOIl6GXXr2PXe7TDg8cjWBkNttfmThBE9WVbRqjj0+fU5c0 yPRu/NvOyqyRnWCn05tx0MWtAtj9Q1L7AvITjQp5diz+UyzAD2KX6v7pWX6co3+/E7xfEJ Yx1fqyDg/zIR/2OIl+5xD/znPlxMdsg= X-MC-Unique: sAKzJqmCM82Uwk60w1FwRg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] virNodeDeviceDefParseXML: Use g_auto* Date: Tue, 11 May 2021 17:01:48 +0200 Message-Id: <20210511150157.26027-2-twiederh@redhat.com> In-Reply-To: <20210511150157.26027-1-twiederh@redhat.com> References: <20210511150157.26027-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.14 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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/node_device_conf.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4477a8d9d2..5ac046f768 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2059,21 +2059,19 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, int create, const char *virt_type) { - virNodeDeviceDef *def; + g_autoptr(virNodeDeviceDef) def =3D g_new0(virNodeDeviceDef, 1); virNodeDevCapsDef **next_cap; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; int n, m; size_t i; =20 - def =3D g_new0(virNodeDeviceDef, 1); - /* Extract device name */ if (create =3D=3D EXISTING_DEVICE) { def->name =3D virXPathString("string(./name[1])", ctxt); =20 if (!def->name) { virReportError(VIR_ERR_NO_NAME, NULL); - goto error; + return NULL; } } else { def->name =3D g_strdup("new device"); @@ -2083,7 +2081,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, =20 /* Parse devnodes */ if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) - goto error; + return NULL; =20 def->devlinks =3D g_new0(char *, n + 1); =20 @@ -2093,16 +2091,16 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, =20 if (virXMLPropEnum(node, "type", virNodeDevDevnodeTypeFromString, VIR_XML_PROP_REQUIRED, &val) < 0) - goto error; + return NULL; =20 switch (val) { case VIR_NODE_DEV_DEVNODE_DEV: if (!(def->devnode =3D virXMLNodeContentString(node))) - goto error; + return NULL; break; case VIR_NODE_DEV_DEVNODE_LINK: if (!(def->devlinks[m++] =3D virXMLNodeContentString(node))) - goto error; + return NULL; break; case VIR_NODE_DEV_DEVNODE_LAST: break; @@ -2118,7 +2116,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, _("when providing parent wwnn=3D'%s', the " "wwpn must also be provided"), def->parent_wwnn); - goto error; + return NULL; } =20 if (!def->parent_wwnn && def->parent_wwpn) { @@ -2126,7 +2124,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, _("when providing parent wwpn=3D'%s', the " "wwnn must also be provided"), def->parent_wwpn); - goto error; + return NULL; } def->parent_fabric_wwn =3D virXPathString("string(./parent[1]/@fabric_= wwn)", ctxt); @@ -2134,13 +2132,13 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, /* Parse device capabilities */ VIR_FREE(nodes); if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) - goto error; + return NULL; =20 if (n =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no device capabilities for '%s'"), def->name); - goto error; + return NULL; } =20 next_cap =3D &def->caps; @@ -2150,18 +2148,12 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, create, virt_type); if (!*next_cap) - goto error; + return NULL; =20 next_cap =3D &(*next_cap)->next; } - VIR_FREE(nodes); =20 - return def; - - error: - virNodeDeviceDefFree(def); - VIR_FREE(nodes); - return NULL; + return g_steal_pointer(&def); } =20 =20 --=20 2.26.3