提交 66eafbc2 编写于 作者: M Michal Privoznik

libxlGetDHCPInterfaces: Move some variables inside the loop

Some variables are not used outside of the for() loop. Move their
declaration to clean up the code a bit.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 068fd891
...@@ -6232,25 +6232,27 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm, ...@@ -6232,25 +6232,27 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm,
virDomainInterfacePtr **ifaces) virDomainInterfacePtr **ifaces)
{ {
g_autoptr(virConnect) conn = NULL; g_autoptr(virConnect) conn = NULL;
virDomainInterfacePtr *ifaces_ret = NULL;
size_t ifaces_count = 0;
int rv = -1; int rv = -1;
int n_leases = 0; int n_leases = 0;
size_t i, j;
size_t ifaces_count = 0;
virNetworkPtr network = NULL;
char macaddr[VIR_MAC_STRING_BUFLEN];
virDomainInterfacePtr iface = NULL;
virNetworkDHCPLeasePtr *leases = NULL; virNetworkDHCPLeasePtr *leases = NULL;
virDomainInterfacePtr *ifaces_ret = NULL; size_t i;
if (!(conn = virGetConnectNetwork())) if (!(conn = virGetConnectNetwork()))
return -1; return -1;
for (i = 0; i < vm->def->nnets; i++) { for (i = 0; i < vm->def->nnets; i++) {
g_autoptr(virNetwork) network = NULL;
char macaddr[VIR_MAC_STRING_BUFLEN];
virDomainInterfacePtr iface = NULL;
size_t j;
if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK) if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
continue; continue;
virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
virObjectUnref(network);
network = virNetworkLookupByName(conn, network = virNetworkLookupByName(conn,
vm->def->nets[i]->data.network.name); vm->def->nets[i]->data.network.name);
if (!network) if (!network)
...@@ -6300,7 +6302,6 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm, ...@@ -6300,7 +6302,6 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm,
rv = ifaces_count; rv = ifaces_count;
cleanup: cleanup:
virObjectUnref(network);
if (leases) { if (leases) {
for (i = 0; i < n_leases; i++) for (i = 0; i < n_leases; i++)
virNetworkDHCPLeaseFree(leases[i]); virNetworkDHCPLeaseFree(leases[i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册