From nobody Mon Feb 9 07:26:55 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=1614101135; cv=none; d=zohomail.com; s=zohoarc; b=aum3XLk47uHxThaHaWYekRlj44fyUL0LQgV0ZXIhiNtICBzB2giibCDHqGywyY+XkR85QHODMGShxA4xL4nzmShkcjgHOgg3NvXN7gxIY5TX13K9Uy/XTfo4cirDIXmlRP2ky2u8hjDarn1CxrCaJTGmYnQvO6YqgKSS0MDd+E0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614101135; 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=i/t3mwC9HL0bsTYCmVL1ztDeVC4vIRPaNQ5+iqDbqp4=; b=EtTS+fy09RKo4PBaBR/mioetQIxTgxQP7B+FXKDO5UsJ84fOQjUM7fSP7wDDBYuyKZiX5NszrCLG3SiOUourTtoCs/thfSlKncxKSosSdEJ0fFoLdzCt7BbtjWtd61NqwJwD1ec51yhyTG0MdS3y4gUgSoJIZen8hnT2Izs2en4= 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 1614101135301619.0577107157073; Tue, 23 Feb 2021 09:25:35 -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-176-bTFOZiluOh-lilW2PE0eaw-1; Tue, 23 Feb 2021 12:25:18 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB8DEC73AE; Tue, 23 Feb 2021 17:25:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E94310016F9; Tue, 23 Feb 2021 17:25:06 +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 5574718095CD; Tue, 23 Feb 2021 17:25:06 +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 11NHP4m4006505 for ; Tue, 23 Feb 2021 12:25:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C8C22CFD8; Tue, 23 Feb 2021 17:25:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 835761DB for ; Tue, 23 Feb 2021 17:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614101134; 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=i/t3mwC9HL0bsTYCmVL1ztDeVC4vIRPaNQ5+iqDbqp4=; b=W+G8dtYJ6JTF8NGXV9Ps0wE+0ImYJcEk2Lssi9geD3V2/lyzL3gh8jwkAJ6XJpzIYVzkwj EGdhuDmIV0x20dqQnHnzmB8BdqX6vw6SLkmJxlGAhXufjDXdYkWqkuQo4DQfWdm+CCfqRF qb9IS9J278CviUGmV/au7SHgec6F4zQ= X-MC-Unique: bTFOZiluOh-lilW2PE0eaw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/3] Use g_autoptr instead of virNetDevIPRouteFree if possible Date: Tue, 23 Feb 2021 18:24:40 +0100 Message-Id: <9132d220b8911af5d31c250979d0ce6df8e31ced.1614100068.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.22 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" In files: src/conf/domain_conf: in virDomainNetIPInfoParseXML(), src/lxc/lxc_native: in lxcAddNetworkRouteDefinition(), src/vz/vz_sdk: in prlsdkGetRoutes(), src/conf/networkcommon_conf: in virNetDevIPRouteCreate() Signed-off-by: Kristina Hanicova Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 3 +-- src/conf/networkcommon_conf.c | 5 ++--- src/lxc/lxc_native.c | 3 +-- src/vz/vz_sdk.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b731744f04..2504911931 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7481,7 +7481,7 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfoPtr def) { - virNetDevIPRoutePtr route =3D NULL; + g_autoptr(virNetDevIPRoute) route =3D NULL; int nnodes; int ret =3D -1; size_t i; @@ -7511,7 +7511,6 @@ virDomainNetIPInfoParseXML(const char *source, cleanup: if (ret < 0) virNetDevIPInfoClear(def); - virNetDevIPRouteFree(route); return ret; } =20 diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index e82dbc3d3d..9e7ad59337 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -41,7 +41,7 @@ virNetDevIPRouteCreate(const char *errorDetail, unsigned int metric, bool hasMetric) { - virNetDevIPRoutePtr def =3D NULL; + g_autoptr(virNetDevIPRoute) def =3D NULL; virSocketAddr testAddr; =20 def =3D g_new0(virNetDevIPRoute, 1); @@ -209,10 +209,9 @@ virNetDevIPRouteCreate(const char *errorDetail, goto error; } =20 - return def; + return g_steal_pointer(&def); =20 error: - virNetDevIPRouteFree(def); return NULL; } =20 diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index b903dc91d6..d5020dafa7 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -441,7 +441,7 @@ lxcAddNetworkRouteDefinition(const char *address, virNetDevIPRoutePtr **routes, size_t *nroutes) { - virNetDevIPRoutePtr route =3D NULL; + g_autoptr(virNetDevIPRoute) route =3D NULL; g_autofree char *familyStr =3D NULL; g_autofree char *zero =3D NULL; =20 @@ -460,7 +460,6 @@ lxcAddNetworkRouteDefinition(const char *address, return 0; =20 error: - virNetDevIPRouteFree(route); return -1; } =20 diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f49cd983f0..6f712c7a31 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -974,7 +974,7 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr n= et) int ret =3D -1; char *gw =3D NULL; char *gw6 =3D NULL; - virNetDevIPRoutePtr route =3D NULL; + g_autoptr(virNetDevIPRoute) route =3D NULL; =20 if (!(gw =3D prlsdkGetStringParamVar(PrlVmDevNet_GetDefaultGateway, sd= knet))) goto cleanup; @@ -1006,7 +1006,6 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr= net) ret =3D 0; =20 cleanup: - virNetDevIPRouteFree(route); VIR_FREE(gw); VIR_FREE(gw6); =20 --=20 2.29.2