From nobody Mon Feb 9 12:15:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1620919958; cv=none; d=zohomail.com; s=zohoarc; b=dhBDyuXuKOel9YB8WDbu20IpMiPkymexc746VvgGxWaOfpjwv8snA6EeHJiUuWM56OgUMs4Iyp/9jdmFRTnWXAVGX7qzTdSyvXrGqB/psrfP1v4HmPxIkSo5MybvKP88bIqeEZzWGyxe7lJPqg0R776rFgztMjjakFqdu9Ifivo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919958; 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=nQm32h8AjrI5rFfqvkHJ5w7KjBDswbIWMhrRMZ0kO0I=; b=XanpUdeXybxiYA4neFRUq+kXUED/xkLPKNajWseovsYiEOsksH2XURs1VC0oCJMcYbB+apxBsmsaqlASSg7+5HhFmBCxZBbFjHCH+/5IxdCVrmZIzh6eSMXxwswDGWelCHG7x7LpjjZjqbSRKyIKoFVrlhGdqhsIAGrr5jNWa5g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620919958532378.6196933194783; Thu, 13 May 2021 08:32:38 -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-582-_3YhjwKIOhmFx2E5Z7j1Ew-1; Thu, 13 May 2021 11:32:34 -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 D505C107ACE3; Thu, 13 May 2021 15:32:29 +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 B458060CC6; Thu, 13 May 2021 15:32:29 +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 7541B55349; Thu, 13 May 2021 15:32:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14DFWC67026177 for ; Thu, 13 May 2021 11:32:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02F2D18B42; Thu, 13 May 2021 15:32:12 +0000 (UTC) Received: from work.redhat.com (ovpn-112-97.ams2.redhat.com [10.36.112.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AC36189C4; Thu, 13 May 2021 15:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919956; 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=nQm32h8AjrI5rFfqvkHJ5w7KjBDswbIWMhrRMZ0kO0I=; b=JC6KbMf+n7otw0bUHCV5U4jiNpGv/kwmwvXvPPK99WwtgtkWl1hnR0mJZpmBRxItLz3sK4 OnnAKkuAx8w+n3nz/DMrH29clNOXENtoIzG460j2s/Z9IplwPyWkAXqqB7dkpNCxrzhkEh tpTO87KnTqvuL00L/JZISmCIP0PDGD4= X-MC-Unique: _3YhjwKIOhmFx2E5Z7j1Ew-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/6] virNodeDeviceDefParseXML: Use g_auto* Date: Thu, 13 May 2021 17:31:56 +0200 Message-Id: <20210513153201.20407-2-twiederh@redhat.com> In-Reply-To: <20210513153201.20407-1-twiederh@redhat.com> References: <20210513153201.20407-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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/node_device_conf.c | 44 +++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4477a8d9d2..861f43f6c4 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2059,21 +2059,20 @@ 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 *devnode =3D NULL; + g_autofree xmlNodePtr *capability =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"); @@ -2082,27 +2081,27 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, def->sysfs_path =3D virXPathString("string(./path[1])", ctxt); =20 /* Parse devnodes */ - if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) - goto error; + if ((n =3D virXPathNodeSet("./devnode", ctxt, &devnode)) < 0) + return NULL; =20 def->devlinks =3D g_new0(char *, n + 1); =20 for (i =3D 0, m =3D 0; i < n; i++) { - xmlNodePtr node =3D nodes[i]; + xmlNodePtr node =3D devnode[i]; virNodeDevDevnodeType val; =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 +2117,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,42 +2125,35 @@ 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); =20 /* Parse device capabilities */ - VIR_FREE(nodes); - if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) - goto error; + if ((n =3D virXPathNodeSet("./capability", ctxt, &capability)) < 0) + 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; for (i =3D 0; i < n; i++) { *next_cap =3D virNodeDevCapsDefParseXML(ctxt, def, - nodes[i], + capability[i], create, virt_type); if (!*next_cap) - goto error; + return NULL; =20 next_cap =3D &(*next_cap)->next; } - VIR_FREE(nodes); - - return def; =20 - error: - virNodeDeviceDefFree(def); - VIR_FREE(nodes); - return NULL; + return g_steal_pointer(&def); } =20 =20 --=20 2.26.3