From nobody Mon Feb 9 00:56:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614253950; cv=none; d=zohomail.com; s=zohoarc; b=JEUvGGK8wqj6o6WrzdbU6fGlDV4lO+THjfz0IFBWNBKOIHose6RkDdc0cszjJBtv2PhKSwNvCrylpVQJBoCNx3JvNGw+n7PPxpGyLn81fuHZaxDXLPhRHm7VN2yX0lXqBQoqIuFr1TWgQFzNZHMIEoaIQKpC31LsfrLRuD0C8sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614253950; 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=EegCv//eZBkG1jAtPbzKefZQjSpfRHBCKpFruhp0W3w=; b=i0Lhj7X/VPShC1HgQKzqQsmropS8r246E+f+bdM4TjQ/BXecf+pyj1zbvb6zE3l/mJ0gIy/izdQyUEfswlboikldLS8FRXu1UZ2XjqgsYwKTRExKYLPGV55JCQcS5luBSV4+/dQtR9ZCMQvub85gVbf7Wky5yLlwQuu/1vDlXXQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614253950109498.4438753858118; Thu, 25 Feb 2021 03:52:30 -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-182-fDac5FE2Nl6c72KRFr4Txw-1; Thu, 25 Feb 2021 06:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 466491005501; Thu, 25 Feb 2021 11:52:18 +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 1577819D61; Thu, 25 Feb 2021 11:52:18 +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 508B24E58E; Thu, 25 Feb 2021 11:52:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11PBqFGt001412 for ; Thu, 25 Feb 2021 06:52:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26B3A1001281; Thu, 25 Feb 2021 11:52:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8042C10013D6 for ; Thu, 25 Feb 2021 11:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614253946; 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=EegCv//eZBkG1jAtPbzKefZQjSpfRHBCKpFruhp0W3w=; b=XOWm9R6XRbaEV8vFlYZvkBsURiTGeKzwnNZz0wndm3U5tSnLpKkBPF3rv4WzbWIP730WPw ozQQvyUf/JgMxgAWEUIvfxQUkiA3CJhSAVz/wnXo59PIgBWqzlEtWB8W3FJaATvYgu5lAW FwAQS8WdAkm8bsG/0ndXLwTUaFB677E= X-MC-Unique: fDac5FE2Nl6c72KRFr4Txw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/3] networkcommon_conf: Use g_autofree where possible Date: Thu, 25 Feb 2021 12:51:55 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 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: Kristina Hanicova --- src/conf/networkcommon_conf.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 26eeb6dbda..430d48a997 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -228,9 +228,10 @@ virNetDevIPRouteParseXML(const char *errorDetail, =20 virNetDevIPRoutePtr def =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) - char *family =3D NULL; - char *address =3D NULL, *netmask =3D NULL; - char *gateway =3D NULL; + g_autofree char *family =3D NULL; + g_autofree char *address =3D NULL; + g_autofree char *netmask =3D NULL; + g_autofree char *gateway =3D NULL; unsigned long prefix =3D 0, metric =3D 0; int prefixRc, metricRc; bool hasPrefix =3D false; @@ -276,10 +277,6 @@ virNetDevIPRouteParseXML(const char *errorDetail, hasMetric); =20 cleanup: - VIR_FREE(family); - VIR_FREE(address); - VIR_FREE(netmask); - VIR_FREE(gateway); return def; } =20 @@ -287,31 +284,30 @@ int virNetDevIPRouteFormat(virBufferPtr buf, const virNetDevIPRoute *def) { - char *addr =3D NULL; + g_autofree char *address =3D NULL; + g_autofree char *netmask =3D NULL; + g_autofree char *gateway =3D NULL; =20 virBufferAddLit(buf, "family) virBufferAsprintf(buf, " family=3D'%s'", def->family); =20 - if (!(addr =3D virSocketAddrFormat(&def->address))) + if (!(address =3D virSocketAddrFormat(&def->address))) return -1; - virBufferAsprintf(buf, " address=3D'%s'", addr); - VIR_FREE(addr); + virBufferAsprintf(buf, " address=3D'%s'", address); =20 if (VIR_SOCKET_ADDR_VALID(&def->netmask)) { - if (!(addr =3D virSocketAddrFormat(&def->netmask))) + if (!(netmask =3D virSocketAddrFormat(&def->netmask))) return -1; - virBufferAsprintf(buf, " netmask=3D'%s'", addr); - VIR_FREE(addr); + virBufferAsprintf(buf, " netmask=3D'%s'", netmask); } if (def->has_prefix) virBufferAsprintf(buf, " prefix=3D'%u'", def->prefix); =20 - if (!(addr =3D virSocketAddrFormat(&def->gateway))) + if (!(gateway =3D virSocketAddrFormat(&def->gateway))) return -1; - virBufferAsprintf(buf, " gateway=3D'%s'", addr); - VIR_FREE(addr); + virBufferAsprintf(buf, " gateway=3D'%s'", gateway); =20 if (def->has_metric && def->metric > 0) virBufferAsprintf(buf, " metric=3D'%u'", def->metric); --=20 2.29.2