From nobody Mon Feb 9 06:27:10 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=1614788291; cv=none; d=zohomail.com; s=zohoarc; b=iE46AML122yM8EmcBj3WR0KyBOQZMt8QFCFmdGtl0oaE08qxuXNzIKFm7IFaOOBl2BKwFwpf6pqjSGAs4cVZVkj1rG6VWNrnNH3aUJhWXNFe5WjgzsK1fnk4SuO1q9zc1hBx/UKoTQV0lcePeyLNKDsrBBMJrVApU4/CCa+vjy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614788291; 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=cdeXDsRQ1xpv8OjCMgYp1zKy2PAjVPvDwiH33NlMMz0=; b=W2CR0OxCjk6mVpZJxg37I6yJ2iLkfoXktHWqGz5ESDMoSjYW0iyFxs1e/RUxHMByMDFzloBg9nrPpivsrv2vorVQ8FvMfFdhrMLuvfqE34cBbRL/7FlGK48LIJD4UEsnvK3u53mVXcm7aXMfZdZsb7d5nyQDrIhnEN3rAs4cl7I= 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 1614788291202763.0740330926499; Wed, 3 Mar 2021 08:18:11 -0800 (PST) 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-575-MC8pqaVKMP6S5Fqcdy0JZQ-1; Wed, 03 Mar 2021 11:18:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 400F9106BB42; Wed, 3 Mar 2021 16:18:01 +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 1DD355D749; Wed, 3 Mar 2021 16:18:01 +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 D38275002E; Wed, 3 Mar 2021 16:18:00 +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 123GHxq7020451 for ; Wed, 3 Mar 2021 11:17:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2849D6091B; Wed, 3 Mar 2021 16:17:59 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B50070953 for ; Wed, 3 Mar 2021 16:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614788290; 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=cdeXDsRQ1xpv8OjCMgYp1zKy2PAjVPvDwiH33NlMMz0=; b=a4RDMTo04yKYpjGZCiauOt8UHhAUVgoR1iDAxlPN98T1DNItZGIuH6LOElPsn8Z+OvrxvA iOPudLRn3tdxq5xzd3FTFZglD6wJOyyKHgkAjPmBJRA/N8JCUVghISHJWsv1XjeJIFn8Gp 9o5mzh1nGn22VebojXozmpOWxaqp5Nc= X-MC-Unique: MC8pqaVKMP6S5Fqcdy0JZQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/4] node_device_conf: Refactoring functions in order to remove VIR_FREE Date: Wed, 3 Mar 2021 17:17:25 +0100 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.15 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" By: * declaration of an autofreed variable in for loop * use of a new variable * removal of VIR_FREE Signed-off-by: Kristina Hanicova --- src/conf/node_device_conf.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 20fafd2c15..cfc72299de 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1229,7 +1229,6 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ct= xt, g_autofree xmlNodePtr *nodes =3D NULL; int ret =3D -1, n =3D 0; size_t i; - char *type =3D NULL; =20 ctxt->node =3D node; =20 @@ -1245,6 +1244,7 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ct= xt, goto out; =20 for (i =3D 0; i < n; ++i) { + g_autofree char *type =3D NULL; type =3D virXMLPropString(nodes[i], "type"); =20 if (!type) { @@ -1280,14 +1280,11 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr = ctxt, type, def->name); goto out; } - - VIR_FREE(type); } =20 ret =3D 0; =20 out: - VIR_FREE(type); return ret; } =20 @@ -1304,7 +1301,6 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, g_autofree xmlNodePtr *nodes =3D NULL; int ret =3D -1, n =3D 0; size_t i; - char *type =3D NULL; =20 ctxt->node =3D node; =20 @@ -1328,6 +1324,7 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, goto out; =20 for (i =3D 0; i < n; i++) { + g_autofree char *type =3D NULL; type =3D virXMLPropString(nodes[i], "type"); =20 if (!type) { @@ -1381,14 +1378,11 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ct= xt, type, def->name); goto out; } - - VIR_FREE(type); } =20 ret =3D 0; =20 out: - VIR_FREE(type); return ret; } =20 @@ -1403,7 +1397,7 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, xmlNodePtr lnk; size_t i =3D -1; int ret =3D -1, n =3D -1; - char *tmp =3D NULL; + g_autofree char *type =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; =20 ctxt->node =3D node; @@ -1425,6 +1419,7 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, net->features =3D virBitmapNew(VIR_NET_DEV_FEAT_LAST); =20 for (i =3D 0; i < n; i++) { + g_autofree char *tmp =3D NULL; int val; if (!(tmp =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1439,15 +1434,13 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, goto out; } ignore_value(virBitmapSetBit(net->features, val)); - VIR_FREE(tmp); } =20 net->subtype =3D VIR_NODE_DEV_CAP_NET_LAST; =20 - tmp =3D virXPathString("string(./capability/@type)", ctxt); - if (tmp) { - int val =3D virNodeDevNetCapTypeFromString(tmp); - VIR_FREE(tmp); + type =3D virXPathString("string(./capability/@type)", ctxt); + if (type) { + int val =3D virNodeDevNetCapTypeFromString(type); if (val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid network type supplied for '%s'"), @@ -1463,7 +1456,6 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - VIR_FREE(tmp); return ret; } =20 --=20 2.29.2