From nobody Sun May 5 04:18:26 2024 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=1614101117; cv=none; d=zohomail.com; s=zohoarc; b=leaZ2H+YKvtAX2EsquV0zovPnUGcMjAgC41M2DcbxGhxFJqr1GiX8pGrTx5OE/JoctAjReY6xX+2CQIQyX6rgKtiuzPBxgO2vOGQPA+rGNyAty1VkjUtBOkQNoga/6uz7pi5dK2lLlbsDVcWYjwgtkCu2VbW0YweenR3lBWDa9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614101117; 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=LHR8iakH1EbYEYpGrj9uAirv+xh/+N+0egcC9/XbnT0=; b=GJd6m6DFGrgnmfmrelMgFETeOvrZJPjtNrRmOY5NveXJ/FlsnLoavwsK3v2jtNVdZ1OTRSxmKMusfZRFCkNAHodtPg2L2iobKTdiQVhdVDI+toPuF6RRx5ZOR7SenH55015F2Pw+REvKljq3lwoq7x9+Chi3KvYHWju4m4yn0Po= 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 161410111695237.34800230926044; Tue, 23 Feb 2021 09:25:16 -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-328-Ui9Rg0O_NH-v-wM8KCLuoQ-1; Tue, 23 Feb 2021 12:25:09 -0500 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 DB475C73AB; Tue, 23 Feb 2021 17:25:03 +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 C6DE760C04; Tue, 23 Feb 2021 17:25:02 +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 87D2857DFA; Tue, 23 Feb 2021 17:25:02 +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 11NHP0eZ006473 for ; Tue, 23 Feb 2021 12:25:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id ED59F1DB; Tue, 23 Feb 2021 17:25:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 565D25C3FD for ; Tue, 23 Feb 2021 17:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614101115; 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=LHR8iakH1EbYEYpGrj9uAirv+xh/+N+0egcC9/XbnT0=; b=GYMEEqVSk127StndemO9DXZPc7drEVa3/lUONBdHXau+fcX6UhK4qVJmE3/xPGOuGPqKbb DTnihJbOt96IsPAYREAMn20ohsoctMtRWpuGMd+ikWP2Cn/2Hq1dlHxfuF2ftns5rdSZbp UrJ2lxHkhvt6PkK6KUSMcMzVxdmizxw= X-MC-Unique: Ui9Rg0O_NH-v-wM8KCLuoQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/3] networkcommon_conf: Use g_autofree where possible Date: Tue, 23 Feb 2021 18:24:39 +0100 Message-Id: <1a671f5b5922b658d52b9210e001d069e641fa5c.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.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: Kristina Hanicova --- src/conf/networkcommon_conf.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 26eeb6dbda..e82dbc3d3d 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,7 +284,7 @@ int virNetDevIPRouteFormat(virBufferPtr buf, const virNetDevIPRoute *def) { - char *addr =3D NULL; + g_autofree char *addr =3D NULL; =20 virBufferAddLit(buf, "gateway))) return -1; virBufferAsprintf(buf, " gateway=3D'%s'", addr); - VIR_FREE(addr); =20 if (def->has_metric && def->metric > 0) virBufferAsprintf(buf, " metric=3D'%u'", def->metric); --=20 2.29.2 From nobody Sun May 5 04:18:26 2024 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 From nobody Sun May 5 04:18:26 2024 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=1614101122; cv=none; d=zohomail.com; s=zohoarc; b=MXluMYhyX0+zMnr4NK58mbn8xB/aYfh7Sds5oV0zlXXlalXB8J7MiqQKi5rtvasUiEjcbq8vVDDzt3Yzn950xKwAKDNJOCfdXHMBOwkBGdsZYZufm6UiYQj7m1CnYF9rQuK4ggiFpX+m1furXG5RJ8o02u3o1by0TDA26kb7kaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614101122; 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=DkuBpjM9q3ltWwKm1lAbvwStC50OH9uOPLc5RDtK4zo=; b=iowmASKWEtZMOnb8yzQWbwB2RCAB3FqlIBFvYZWtgudr4e3vcuz5yz6bz6WUHJwY1KmKBMxik842NnsRcAki6qhIjPD6U5/urtUzgOdEpSfoCXgDKIIs8O+MdMYZLIi1JK8rV3LQHinQGDOsUrSzSetvnGbkoG54NsVXMz/IX+Q= 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 16141011220961018.8889540482572; Tue, 23 Feb 2021 09:25:22 -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-183-HH-BwtsHO2O_F-ToCvjumw-1; Tue, 23 Feb 2021 12:25:15 -0500 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 CF2A5195D566; Tue, 23 Feb 2021 17:25:08 +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 AA7B05D9D3; Tue, 23 Feb 2021 17:25:08 +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 6DEC557DFD; Tue, 23 Feb 2021 17:25:08 +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 11NHP7X6006512 for ; Tue, 23 Feb 2021 12:25:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9FD685C3FD; Tue, 23 Feb 2021 17:25:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB78D5E1A7 for ; Tue, 23 Feb 2021 17:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614101121; 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=DkuBpjM9q3ltWwKm1lAbvwStC50OH9uOPLc5RDtK4zo=; b=hsV20InWabSZBp17tGDQRC+JrAIJcS0EoBtyq1riEMKQ5mTN5FmBuNRBuN3fjbYgEYetjI UNWQ6cunQifVixVNN0GxHVVrm/kjavtYZq33qmfyQPXQRJswg6Hh/nKwvACSadAj3AP2Gn wiC7xhViH4IkTwIcBAr5L+PVrmSuV1k= X-MC-Unique: HH-BwtsHO2O_F-ToCvjumw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/3] Remove redundant variables/labels Date: Tue, 23 Feb 2021 18:24:41 +0100 Message-Id: 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.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) Content-Type: text/plain; charset="utf-8" In files: src/lxc/lxc_native: in lxcAddNetworkRouteDefinition(), src/conf/networkcommon_conf: in virNetDevIPRouteCreate() and virNetDevIPRouteParseXML() Signed-off-by: Kristina Hanicova Reviewed-by: Laine Stump --- src/conf/networkcommon_conf.c | 55 +++++++++++++++-------------------- src/lxc/lxc_native.c | 7 ++--- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 9e7ad59337..a4c49b3caa 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -60,7 +60,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Missing required address attribute " "in route definition"), errorDetail); - goto error; + return NULL; } =20 if (!gateway) { @@ -68,7 +68,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Missing required gateway attribute " "in route definition"), errorDetail); - goto error; + return NULL; } =20 if (virSocketAddrParse(&def->address, address, AF_UNSPEC) < 0) { @@ -76,7 +76,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Bad network address '%s' " "in route definition"), errorDetail, address); - goto error; + return NULL; } =20 if (virSocketAddrParse(&def->gateway, gateway, AF_UNSPEC) < 0) { @@ -84,7 +84,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Bad gateway address '%s' " "in route definition"), errorDetail, gateway); - goto error; + return NULL; } =20 /* validate network address, etc. for each family */ @@ -98,7 +98,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: IPv4 family specified for non-IPv4 addre= ss '%s' " "in route definition"), errorDetail, address); - goto error; + return NULL; } if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->gateway, AF_INET)) { virReportError(VIR_ERR_XML_ERROR, @@ -108,7 +108,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: IPv4 family specified for non-IPv4 gatew= ay '%s' " "in route definition"), errorDetail, address); - goto error; + return NULL; } if (netmask) { if (virSocketAddrParse(&def->netmask, netmask, AF_UNSPEC) < 0)= { @@ -116,14 +116,14 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Bad netmask address '%s' " "in route definition"), errorDetail, netmask); - goto error; + return NULL; } if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->netmask, AF_INET)) { virReportError(VIR_ERR_XML_ERROR, _("%s: Invalid netmask '%s' " "for address '%s' (both must be IPv4)"), errorDetail, netmask, address); - goto error; + return NULL; } if (def->has_prefix) { /* can't have both netmask and prefix at the same time */ @@ -131,7 +131,7 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Route definition cannot have both " "a prefix and a netmask"), errorDetail); - goto error; + return NULL; } } if (def->prefix > 32) { @@ -140,7 +140,7 @@ virNetDevIPRouteCreate(const char *errorDetail, "in route definition, " "must be 0 - 32"), errorDetail, def->prefix); - goto error; + return NULL; } } else if (STREQ(def->family, "ipv6")) { if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET6)) { @@ -148,21 +148,21 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: ipv6 family specified for non-IPv6 addre= ss '%s' " "in route definition"), errorDetail, address); - goto error; + return NULL; } if (netmask) { virReportError(VIR_ERR_XML_ERROR, _("%s: Specifying netmask invalid for IPv6 addr= ess '%s' " "in route definition"), errorDetail, address); - goto error; + return NULL; } if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->gateway, AF_INET6)) { virReportError(VIR_ERR_XML_ERROR, _("%s: ipv6 specified for non-IPv6 gateway addr= ess '%s' " "in route definition"), errorDetail, gateway); - goto error; + return NULL; } if (def->prefix > 128) { virReportError(VIR_ERR_XML_ERROR, @@ -170,14 +170,14 @@ virNetDevIPRouteCreate(const char *errorDetail, "in route definition, " "must be 0 - 128"), errorDetail, def->prefix); - goto error; + return NULL; } } else { virReportError(VIR_ERR_XML_ERROR, _("%s: Unrecognized family '%s' " "in route definition"), errorDetail, def->family); - goto error; + return NULL; } =20 /* make sure the address is a network address */ @@ -188,7 +188,7 @@ virNetDevIPRouteCreate(const char *errorDetail, "to network-address " "in route definition"), errorDetail, address, netmask); - goto error; + return NULL; } } else { if (virSocketAddrMaskByPrefix(&def->address, @@ -198,7 +198,7 @@ virNetDevIPRouteCreate(const char *errorDetail, "to network-address " "in route definition"), errorDetail, address, def->prefix); - goto error; + return NULL; } } if (!virSocketAddrEqual(&def->address, &testAddr)) { @@ -206,13 +206,10 @@ virNetDevIPRouteCreate(const char *errorDetail, _("%s: Address '%s' in route definition " "is not a network address"), errorDetail, address); - goto error; + return NULL; } =20 return g_steal_pointer(&def); - - error: - return NULL; } =20 virNetDevIPRoutePtr @@ -225,7 +222,6 @@ virNetDevIPRouteParseXML(const char *errorDetail, * of an array. On failure clear: it out, but don't free it. */ =20 - virNetDevIPRoutePtr def =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *family =3D NULL; g_autofree char *address =3D NULL; @@ -249,7 +245,7 @@ virNetDevIPRouteParseXML(const char *errorDetail, _("%s: Invalid prefix specified " "in route definition"), errorDetail); - goto cleanup; + return NULL; } hasPrefix =3D (prefixRc =3D=3D 0); metricRc =3D virXPathULong("string(./@metric)", ctxt, &metric); @@ -258,7 +254,7 @@ virNetDevIPRouteParseXML(const char *errorDetail, _("%s: Invalid metric specified " "in route definition"), errorDetail); - goto cleanup; + return NULL; } if (metricRc =3D=3D 0) { hasMetric =3D true; @@ -267,16 +263,13 @@ virNetDevIPRouteParseXML(const char *errorDetail, _("%s: Invalid metric value, must be > 0 " "in route definition"), errorDetail); - goto cleanup; + return NULL; } } =20 - def =3D virNetDevIPRouteCreate(errorDetail, family, address, netmask, - gateway, prefix, hasPrefix, metric, - hasMetric); - - cleanup: - return def; + return virNetDevIPRouteCreate(errorDetail, family, address, netmask, + gateway, prefix, hasPrefix, metric, + hasMetric); } =20 int diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index d5020dafa7..555e9acd89 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -452,15 +452,12 @@ lxcAddNetworkRouteDefinition(const char *address, if (!(route =3D virNetDevIPRouteCreate(_("Domain interface"), familySt= r, zero, NULL, address, 0, false, 0, false))) - goto error; + return -1; =20 if (VIR_APPEND_ELEMENT(*routes, *nroutes, route) < 0) - goto error; + return -1; =20 return 0; - - error: - return -1; } =20 static int --=20 2.29.2