From nobody Mon Feb 9 05:00:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1639066728; cv=none; d=zohomail.com; s=zohoarc; b=KN6QdJxA+Fi425EQwI0d5iwzYfLdUfOZELPkx9aHUhEMGhaDVUrWcmk1URNamUdTwPiC5CB9T1Xlp3KnSMmUlF1UvRNXOq3xxfPQnC9O+9T3oBQomZF+kNdf0IG/4aVLLaXCNU6fOqkbo04ikNchWilC+fm169gcIfa8aDfdmaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639066728; 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=V4uYRY+Q5kWJ4Wlk2wiQuCJJW6nHVjjeY+taNKRe5xc=; b=b+7K6W5pMFcbMkCqg3C9cttcMMvr4gPT8Wc+SSaMTqr4RLc+JzcdMF/RTuh9WpOKtKdYx21R9G/nxkB2QJnCB9Fzn1b7rUxAWI0A10PKg6bBifzEF3L2/RSLjb2EJe+RqxydLFXPAAwlDSb9i8PCRaM8SSXuJIysz6Cg/jefKSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639066728112135.37712098247152; Thu, 9 Dec 2021 08:18:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-92v4uapXPZOUiHuqWJnCug-1; Thu, 09 Dec 2021 11:18:45 -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 E6DCE18C89D9; Thu, 9 Dec 2021 16:18:40 +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 C7EAE45D87; Thu, 9 Dec 2021 16:18:40 +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 7E5071809CB9; Thu, 9 Dec 2021 16:18:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9GI5aG014587 for ; Thu, 9 Dec 2021 11:18:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9FECA19D9F; Thu, 9 Dec 2021 16:18:05 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 285D119C59 for ; Thu, 9 Dec 2021 16:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639066727; 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=V4uYRY+Q5kWJ4Wlk2wiQuCJJW6nHVjjeY+taNKRe5xc=; b=P3YjI8xI1LpP1MmZdEPvwJLwnEfLGFgkgz/zGXs2b/RrOAwVwi7OYXR1/ZAr0woxMPmn5f tD2lqPzegC2tWBN5zmNZc9p5nh2vOinF3ZGlYA6n8ahfkAHGXpsBzHac7V3sMFcs5ZGt6M d1ieJuJVC+h0JNv01G5eag+u5keGglY= X-MC-Unique: 92v4uapXPZOUiHuqWJnCug-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] network: Initialize variables in networkDnsmasqConfContents() Date: Thu, 9 Dec 2021 17:17:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1639066730731100001 Content-Type: text/plain; charset="utf-8" In networkDnsmasqConfContents() there's a for() loop which initializes some variables in its initialization block. This makes both the loop() statement and variable declaration block look needlessly ugly. Speaking of variable declaration, also move some variables which are used only within blocks into their respective blocks. Signed-off-by: Michal Privoznik --- src/network/bridge_driver.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7e5fab630b..2d8bebdd2f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1057,16 +1057,14 @@ networkDnsmasqConfContents(virNetworkObj *obj, { virNetworkDef *def =3D virNetworkObjGetDef(obj); g_auto(virBuffer) configbuf =3D VIR_BUFFER_INITIALIZER; - int r; int nbleases =3D 0; size_t i; virNetworkDNSDef *dns =3D &def->dns; bool wantDNS =3D dns->enable !=3D VIR_TRISTATE_BOOL_NO; - virNetworkIPDef *tmpipdef; - virNetworkIPDef *ipdef; - virNetworkIPDef *ipv4def; - virNetworkIPDef *ipv6def; - bool ipv6SLAAC; + virNetworkIPDef *ipdef =3D NULL; + virNetworkIPDef *ipv4def =3D NULL; + virNetworkIPDef *ipv6def =3D NULL; + bool ipv6SLAAC =3D false; =20 *configstr =3D NULL; =20 @@ -1186,6 +1184,8 @@ networkDnsmasqConfContents(virNetworkObj *obj, "interface=3D%s\n", def->bridge); } else { + virNetworkIPDef *tmpipdef =3D NULL; + virBufferAddLit(&configbuf, "bind-interfaces\n"); /* * --interface does not actually work with dnsmasq < 2.47, @@ -1312,9 +1312,7 @@ networkDnsmasqConfContents(virNetworkObj *obj, } =20 /* Find the first dhcp for both IPv4 and IPv6 */ - for (i =3D 0, ipv4def =3D NULL, ipv6def =3D NULL, ipv6SLAAC =3D false; - (ipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); - i++) { + for (i =3D 0; (ipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i))= ; i++) { if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET)) { if (ipdef->nranges || ipdef->nhosts) { if (ipv4def) { @@ -1370,6 +1368,7 @@ networkDnsmasqConfContents(virNetworkObj *obj, =20 while (ipdef) { int prefix; + int r; =20 prefix =3D virNetworkIPDefPrefix(ipdef); if (prefix < 0) { --=20 2.32.0