From nobody Sun May 5 20:50:28 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=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 Reviewed-by: Laine Stump --- 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 From nobody Sun May 5 20:50:28 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=1614253951; cv=none; d=zohomail.com; s=zohoarc; b=b6/3Eep+9HmzmDpJ0K1o8+RePmM2uwzgUyHum0TSyEhrT+W4Uib4omeW4sgAYVdZzG8NNuDma7RmGLpVxLJiBRaKFMiAZDLWgKG/zltJenuLy85RNzSmLX1u+HFeAby/1erzcQX53AhcoMZndr9dlBqmNrvLd0leWaczwyNdyZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614253951; 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=HBPwD9P6CaPPf87xrXseKsfjCJxOcuzJ/1XP21aR+qE=; b=lMTzcaNsn9x+sjv6ckz0cYtV8c8d4GD8Fv0eIvZYinvoAGSlPiuTliqDF6hIypmJsel+g0IvE6kusF8eHweK5hpXzX6p0YJouDGVFwGfTJO88eEGOrWeaI6PUrBUJy99LUIpXptSaN4sTGSTjzE65K+VbQ/nVM1cyqrr/ZMsnqU= 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 161425395101693.96066269889957; Thu, 25 Feb 2021 03:52:31 -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-rtWASSldN8WfFTca-ZwcJg-1; Thu, 25 Feb 2021 06:52:27 -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 44D3A801975; Thu, 25 Feb 2021 11:52:20 +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 1D2A81001281; Thu, 25 Feb 2021 11:52:20 +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 D74DC4EBC6; Thu, 25 Feb 2021 11:52:19 +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 11PBqIxI001424 for ; Thu, 25 Feb 2021 06:52:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6EC961001281; Thu, 25 Feb 2021 11:52:18 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id B520910013D6 for ; Thu, 25 Feb 2021 11:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614253950; 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=HBPwD9P6CaPPf87xrXseKsfjCJxOcuzJ/1XP21aR+qE=; b=Q4iOouR4KqyM7pWLJbD9zLwtJZAQ3PMumVgZ+USvePkrNIHz1EnDCg5ttm95M7Lj04PB47 YiLlRna4/ObYc2b2Yc5c3Hsn/Vag5fd9jBjvq+G/jWoy6yHJup+KGLuXVHGSHuln96uJT6 5Lnbse0CfytT5ymCxd+kgfC7owpDNjo= X-MC-Unique: rtWASSldN8WfFTca-ZwcJg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 2/3] Use g_autoptr instead of virNetDevIPRouteFree if possible Date: Thu, 25 Feb 2021 12:51:56 +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.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 430d48a997..db78b85268 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 20:50:28 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=1614253956; cv=none; d=zohomail.com; s=zohoarc; b=dndSwDvojzyMhX1/0Jbwgyje106r7Zv+KWmVZ0JtYHKQf5JGglLU3mzyUOk35uu57wkV6/SIF3aUbCoU88Xprr/tPIWXvMXuVnrOjk2sgwTclztRdZ7pg484I0Kcy3riX1322uKf1sd+3P9JE3O5cFwUD7ipSpG8rxJKgr4aBv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614253956; 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=0RhoiPjK2DWVRW6zVSQO6/PXo5EjBpq9o3GgxGBlZW4=; b=hwhKxxvSo99MCYVv4vOz6wCFt5FQklwISLp0I18/BPs/Lqvc9vINP7z7WtHnz86UufG0FilmaYpzT0Oc99YlmKsCToGMJMSBYhcdBtvk4nr/zh2P3wf2lRXv7qt/0SGFTdRqzuD9lW27rAX/8tCJzYPbOhFPF2NGdjFGlxvSq/4= 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 16142539562391016.2156009859737; Thu, 25 Feb 2021 03:52:36 -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-103-glwQR-IzOFKZ5PV0WbS8Pg-1; Thu, 25 Feb 2021 06:52:32 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 833C280402E; Thu, 25 Feb 2021 11:52:26 +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 A1F5839A63; Thu, 25 Feb 2021 11:52:25 +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 692C249; Thu, 25 Feb 2021 11:52:25 +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 11PBqLqd001434 for ; Thu, 25 Feb 2021 06:52:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 796E61001281; Thu, 25 Feb 2021 11:52:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5EF610013D6 for ; Thu, 25 Feb 2021 11:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614253955; 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=0RhoiPjK2DWVRW6zVSQO6/PXo5EjBpq9o3GgxGBlZW4=; b=arEy0GWZdTISBxPOjWTgpH5330rfSAjCqazHBvRfdEdu1/xCUIJciCDSlvASiBjj8nAwhJ ApYEO18jCdQ30p3XC+yul5PuYJgmpfppEWKN5JPFknf8J+meRpaX4/n3FguCKezAU/LhlU K6npqWciJictJA8j9RmS69JGnm7HHYY= X-MC-Unique: glwQR-IzOFKZ5PV0WbS8Pg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 3/3] Remove redundant variables/labels Date: Thu, 25 Feb 2021 12:51:57 +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.79 on 10.5.11.11 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 db78b85268..425b94e511 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