From nobody Sun Feb 8 19:03:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575453366; cv=none; d=zohomail.com; s=zohoarc; b=VLmtCpZGeer5RROsjTM2VS5pOAMFtu+wwiJVf7WfDIjHBhIZG5uPEbg0org6q6y07hCIm3KnN2/PUGqfiUw5Td62JrKbs0GBPw0Iz8lFq5QFITno6HyWdjIA+I9zY+IWgMZ2JIuhwC8KyfDv6yylSExAGVsNt3EH3tbvlWGLsuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575453366; 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=Ny77mx8kkVt3QTE3b5xMmfQblCphvQ5d4SwdT1eiRvw=; b=lNaJl1qs9ppY7U83bhPi3OklvKSlvyvqX5u8CY9b3kog37X/BRzx6HvvjPX0pOs9aGtNSZOv74ls+K/Zppy/iF+aRfvldi4Mz3q6UYG+VB1PtZWK5SOzFpVHJ9QOvoq5cPs662NmQ9TESrdjxtyKm2Nct4mRvhZLHT8/pMSCByA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575453366093790.1330671296754; Wed, 4 Dec 2019 01:56:06 -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-228-39sGL4zCPKKkGsEqdQ223Q-1; Wed, 04 Dec 2019 04:56:01 -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 2CEFB8C052B; Wed, 4 Dec 2019 09:55:56 +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 02CE210375D5; Wed, 4 Dec 2019 09:55:56 +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 ABC9A18089D6; Wed, 4 Dec 2019 09:55:55 +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 xB49thxw023738 for ; Wed, 4 Dec 2019 04:55:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id B2B6D5DA70; Wed, 4 Dec 2019 09:55:43 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B73E5DA7D for ; Wed, 4 Dec 2019 09:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575453363; 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=Ny77mx8kkVt3QTE3b5xMmfQblCphvQ5d4SwdT1eiRvw=; b=DLXjapwxyOy+saMyTvFxBCthX4sn1ym9K5XUm9Im6Gnw1dvqx77SYqbkjA8DdJ/5XPEOKT PDHwmMOamoWmRzEFfmpCIuXMw7d8lnc6RYaPN3AIGOP7gZ9A5OeTS07GKh8NnxclcjM+Rp vNUueQRTZYnoN8GRbws+OuEl1W5pZnY= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 10:55:28 +0100 Message-Id: <5029304f2a2a95ca77c33ee7b9ccf72c757e8d70.1575453027.git.mprivozn@redhat.com> 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 3/9] qemuGetDHCPInterfaces: 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.84 on 10.5.11.22 X-MC-Unique: 39sGL4zCPKKkGsEqdQ223Q-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/qemu/qemu_driver.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e5be74c461..2bc2081d0b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21553,26 +21553,27 @@ qemuGetDHCPInterfaces(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; - g_autoptr(virNetwork) 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); =20 - 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