From nobody Mon Feb 9 01:07:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1653311889; cv=none; d=zohomail.com; s=zohoarc; b=dBQS4lGFVxJGMci96v6duQGAb98evDQpO1RgSCc4I+KuT6fh+9cB9Q2J9fybp6KI8OmDj1L9ioP0vsyf/zJ9YAQ9hSGlvS5CZ6vWotEKuhNnupwV1mj2caTsw02nx3zNmoHZAq+8tbb1XLq10OeCDychOOOyRJtlnUCxFXk3Qug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653311889; 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=QCkrMWVHpPlzq2daPazLc6q+MjmrF4mf6E2ueX0XFo8=; b=H71ZbDiW5a/RlrOBJZrRE3W8LnONhVl05AzyfAlhBzaQ+7/d1xD2Ff0JBn3yqIGvtmphrNEkJoU+UAY6v4Bo6rf0EqE3c71e2HxlfX/176+Kn8LRl4d2OpbTGpBJmbr5SyRo0S0XiBRFFPpgbFNdiFpT9Iwf9w1bxVgl2U9cuV8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1653311889603321.23151756245954; Mon, 23 May 2022 06:18:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-_7U59weJPtu3_5abVV4B1A-1; Mon, 23 May 2022 09:17:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A77AE85A5B5; Mon, 23 May 2022 13:17:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848BD2166B2F; Mon, 23 May 2022 13:17:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D2A941947067; Mon, 23 May 2022 13:17:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EFD6F1947059 for ; Mon, 23 May 2022 13:17:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E2EAF407E1C1; Mon, 23 May 2022 13:17:04 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A592407E1C0 for ; Mon, 23 May 2022 13:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653311885; 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=QCkrMWVHpPlzq2daPazLc6q+MjmrF4mf6E2ueX0XFo8=; b=NpW+Q99/977HZ0ss+PtRk3QNVkKMG3UX5e0yY5yDgpO/mXT4uY/pXpVq1RpqH/P8nno3I7 iD+g1SfpckJEHyTvMNjW+e945SY48OjTIGAZT3loyND1dIzvQevKQ1g1WcqmPkwrAciX3t w7hKG5WLc8sDDoUh+0ohISp/ocW6BKY= X-MC-Unique: _7U59weJPtu3_5abVV4B1A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] network: Initialize variables in networkDnsmasqConfContents() Date: Mon, 23 May 2022 15:17:00 +0200 Message-Id: <82ff0cadd55a8ae7b88087c99521ab256fa5adb1.1653311757.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1653311892005100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ca1e0ca50f..10099571c2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1004,15 +1004,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 *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 @@ -1211,9 +1210,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) { @@ -1255,6 +1252,7 @@ networkDnsmasqConfContents(virNetworkObj *obj, =20 while (ipdef) { int prefix; + int r; =20 prefix =3D virNetworkIPDefPrefix(ipdef); if (prefix < 0) { --=20 2.35.1