Commit e4b4372c authored by Simon Giesecke's avatar Simon Giesecke

Simplified code

parent ad3d1e77
......@@ -604,8 +604,7 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
const int max_attempts = 10;
int iterations = 0;
IP_ADAPTER_ADDRESSES *addresses = NULL;
IP_ADAPTER_ADDRESSES *current_addresses = NULL;
IP_ADAPTER_ADDRESSES *addresses;
unsigned long out_buf_len = sizeof (IP_ADAPTER_ADDRESSES);
do {
......@@ -627,15 +626,15 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
} while ((rc == ERROR_BUFFER_OVERFLOW) && (iterations < max_attempts));
if (rc == 0) {
current_addresses = addresses;
while (current_addresses) {
for (const IP_ADAPTER_ADDRESSES *current_addresses = addresses;
current_addresses; current_addresses = current_addresses->Next) {
char *if_name = NULL;
char *if_friendly_name = NULL;
int str_rc1, str_rc2;
str_rc1 = get_interface_name (current_addresses->IfIndex, &if_name);
str_rc2 = wchar_to_utf8 (current_addresses->FriendlyName,
&if_friendly_name);
const int str_rc1 =
get_interface_name (current_addresses->IfIndex, &if_name);
const int str_rc2 = wchar_to_utf8 (current_addresses->FriendlyName,
&if_friendly_name);
// Find a network adapter by its "name" or "friendly name"
if (((str_rc1 == 0) && (!strcmp (nic_, if_name)))
......@@ -647,7 +646,7 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
unicast_address;
while (current_unicast_address) {
ADDRESS_FAMILY family =
const ADDRESS_FAMILY family =
current_unicast_address->Address.lpSockaddr->sa_family;
if (family == (_options.ipv6 () ? AF_INET6 : AF_INET)) {
......@@ -670,8 +669,6 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
free (if_name);
if (str_rc2 == 0)
free (if_friendly_name);
current_addresses = current_addresses->Next;
}
free (addresses);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment