mirror of https://gitee.com/openkylin/libvirt.git
network: fix check for ambiguous lookup
gcc -O2 complained: ../../src/conf/network_conf.c: In function 'virNetworkDefUpdateDNSSrv': ../../src/conf/network_conf.c:3232: error: 'foundIdx' may be used uninitialized in this function [-Wuninitialized] It turned out to be a spurious warning (we didn't use foundIdx unless foundCt was non-zero). But in investigating that, I noticed a worse problem: we were using 'if (foundCt > 1)', but since foundCt was bool, it could never be > 1. * src/conf/network_conf.c (virNetworkDefUpdateDNSHost): Use correct type. (virNetworkDefUpdateDNSSrv): Likewise, and silence compiler warning.
This commit is contained in:
parent
b667125065
commit
f5b654e33e
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* network_conf.c: network XML handling
|
* network_conf.c: network XML handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2013 Red Hat, Inc.
|
||||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
@ -3138,7 +3138,7 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def,
|
||||||
virNetworkDNSHostDef host;
|
virNetworkDNSHostDef host;
|
||||||
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
|
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
|
||||||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
|
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
|
||||||
bool foundCt = 0;
|
int foundCt = 0;
|
||||||
|
|
||||||
memset(&host, 0, sizeof(host));
|
memset(&host, 0, sizeof(host));
|
||||||
|
|
||||||
|
@ -3229,12 +3229,12 @@ virNetworkDefUpdateDNSSrv(virNetworkDefPtr def,
|
||||||
/* virNetworkUpdateFlags */
|
/* virNetworkUpdateFlags */
|
||||||
unsigned int fflags ATTRIBUTE_UNUSED)
|
unsigned int fflags ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
int ii, foundIdx, ret = -1;
|
int ii, foundIdx = -1, ret = -1;
|
||||||
virNetworkDNSDefPtr dns = &def->dns;
|
virNetworkDNSDefPtr dns = &def->dns;
|
||||||
virNetworkDNSSrvDef srv;
|
virNetworkDNSSrvDef srv;
|
||||||
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
|
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
|
||||||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
|
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
|
||||||
bool foundCt = 0;
|
int foundCt = 0;
|
||||||
|
|
||||||
memset(&srv, 0, sizeof(srv));
|
memset(&srv, 0, sizeof(srv));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue