mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
network: Initialize variables in networkDnsmasqConfContents()
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 <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f344005547
commit
314dac422d
@ -1004,15 +1004,14 @@ networkDnsmasqConfContents(virNetworkObj *obj,
|
||||
{
|
||||
virNetworkDef *def = virNetworkObjGetDef(obj);
|
||||
g_auto(virBuffer) configbuf = VIR_BUFFER_INITIALIZER;
|
||||
int r;
|
||||
int nbleases = 0;
|
||||
size_t i;
|
||||
virNetworkDNSDef *dns = &def->dns;
|
||||
bool wantDNS = dns->enable != VIR_TRISTATE_BOOL_NO;
|
||||
virNetworkIPDef *ipdef;
|
||||
virNetworkIPDef *ipv4def;
|
||||
virNetworkIPDef *ipv6def;
|
||||
bool ipv6SLAAC;
|
||||
virNetworkIPDef *ipdef = NULL;
|
||||
virNetworkIPDef *ipv4def = NULL;
|
||||
virNetworkIPDef *ipv6def = NULL;
|
||||
bool ipv6SLAAC = false;
|
||||
|
||||
*configstr = NULL;
|
||||
|
||||
@ -1211,9 +1210,7 @@ networkDnsmasqConfContents(virNetworkObj *obj,
|
||||
}
|
||||
|
||||
/* Find the first dhcp for both IPv4 and IPv6 */
|
||||
for (i = 0, ipv4def = NULL, ipv6def = NULL, ipv6SLAAC = false;
|
||||
(ipdef = virNetworkDefGetIPByIndex(def, AF_UNSPEC, i));
|
||||
i++) {
|
||||
for (i = 0; (ipdef = 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,
|
||||
|
||||
while (ipdef) {
|
||||
int prefix;
|
||||
int r;
|
||||
|
||||
prefix = virNetworkIPDefPrefix(ipdef);
|
||||
if (prefix < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user