From nobody Sun Feb 8 14:56:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1575453357; cv=none; d=zohomail.com; s=zohoarc; b=jKV4lOeBBeqalw8RTqPgzU/NdFFa+H/IoHWgeidrKv9UkrR3tbai4iKz7t9JQMnw1hmpjFjNzs10oELjQJwo41Hy4lbMTKnW/QJ4TgDbb7EPAikGpVZMkH2Ajniei9El0F9/vIDAm7lz7teUn0pgJjdpXtwyAAGJY7/On7/yaGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575453357; 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=oKJkkVCOJlc+iToheEerECWEBRgg7DjCoowMlp8f9Pk=; b=GevvU6gcCwAESbyK7fwPkuyBuILtRUZRYrhT3cF1o2dyug3ejefYYAZpm2fpOecUhazTBwKykXsOaO9QYyU7d3TpTq4OuVDllbormJDEHjbVEHEYVuA4lMy8t4msRKrXmfM5asKeDm1Nbafjo4a8MrnnYSRP6Wlksj8E8NYl6uY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575453357153979.4464660523413; Wed, 4 Dec 2019 01:55:57 -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-241-DNxAfFRPMVq3cMFp30oYCw-1; Wed, 04 Dec 2019 04:55:54 -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 4B6D8101F7F0; Wed, 4 Dec 2019 09:55:49 +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 1495A5DA76; Wed, 4 Dec 2019 09:55:49 +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 82F595BC10; Wed, 4 Dec 2019 09:55:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB49tkn1023771 for ; Wed, 4 Dec 2019 04:55:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EB5B5DA7B; Wed, 4 Dec 2019 09:55:46 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27A7D5DA70 for ; Wed, 4 Dec 2019 09:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575453356; 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=oKJkkVCOJlc+iToheEerECWEBRgg7DjCoowMlp8f9Pk=; b=cEeSz2k0kCAuw4M7EJyI56VN6qQ9+uT/Uz3bbYtzLZtWGz0ibxfADHysINJO/GS0YIPLtv A7/iOsvsyk9btTSP5pTVNUhd4ZmVWHQ0pKw+W+1SzYvp1ah0lkq8bQ4I7eUqohmCdd3+8L xQbQZTd2qBFHOmLyjOietx6mmbUx6og= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 10:55:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/9] libxlGetDHCPInterfaces: Move some variables inside the loop 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 X-MC-Unique: DNxAfFRPMVq3cMFp30oYCw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some variables are not used outside of the for() loop. Move their declaration to clean up the code a bit. Signed-off-by: Michal Privoznik --- src/libxl/libxl_driver.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ccef4f3955..6064436681 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6239,25 +6239,27 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm, virDomainInterfacePtr **ifaces) { g_autoptr(virConnect) conn =3D NULL; + virDomainInterfacePtr *ifaces_ret =3D NULL; + size_t ifaces_count =3D 0; int rv =3D -1; int n_leases =3D 0; - size_t i, j; - size_t ifaces_count =3D 0; - virNetworkPtr network =3D NULL; - char macaddr[VIR_MAC_STRING_BUFLEN]; - virDomainInterfacePtr iface =3D NULL; virNetworkDHCPLeasePtr *leases =3D NULL; - virDomainInterfacePtr *ifaces_ret =3D NULL; + size_t i; =20 if (!(conn =3D virGetConnectNetwork())) return -1; =20 for (i =3D 0; i < vm->def->nnets; i++) { + g_autoptr(virNetwork) network =3D NULL; + char macaddr[VIR_MAC_STRING_BUFLEN]; + virDomainInterfacePtr iface =3D NULL; + size_t j; + if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) continue; =20 virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); - virObjectUnref(network); + network =3D virNetworkLookupByName(conn, vm->def->nets[i]->data.network.na= me); if (!network) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list