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_) ...@@ -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; const int max_attempts = 10;
int iterations = 0; int iterations = 0;
IP_ADAPTER_ADDRESSES *addresses = NULL; IP_ADAPTER_ADDRESSES *addresses;
IP_ADAPTER_ADDRESSES *current_addresses = NULL;
unsigned long out_buf_len = sizeof (IP_ADAPTER_ADDRESSES); unsigned long out_buf_len = sizeof (IP_ADAPTER_ADDRESSES);
do { do {
...@@ -627,15 +626,15 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_) ...@@ -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)); } while ((rc == ERROR_BUFFER_OVERFLOW) && (iterations < max_attempts));
if (rc == 0) { if (rc == 0) {
current_addresses = addresses; for (const IP_ADAPTER_ADDRESSES *current_addresses = addresses;
while (current_addresses) { current_addresses; current_addresses = current_addresses->Next) {
char *if_name = NULL; char *if_name = NULL;
char *if_friendly_name = NULL; char *if_friendly_name = NULL;
int str_rc1, str_rc2;
str_rc1 = get_interface_name (current_addresses->IfIndex, &if_name); const int str_rc1 =
str_rc2 = wchar_to_utf8 (current_addresses->FriendlyName, get_interface_name (current_addresses->IfIndex, &if_name);
&if_friendly_name); const int str_rc2 = wchar_to_utf8 (current_addresses->FriendlyName,
&if_friendly_name);
// Find a network adapter by its "name" or "friendly name" // Find a network adapter by its "name" or "friendly name"
if (((str_rc1 == 0) && (!strcmp (nic_, if_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_) ...@@ -647,7 +646,7 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
unicast_address; unicast_address;
while (current_unicast_address) { while (current_unicast_address) {
ADDRESS_FAMILY family = const ADDRESS_FAMILY family =
current_unicast_address->Address.lpSockaddr->sa_family; current_unicast_address->Address.lpSockaddr->sa_family;
if (family == (_options.ipv6 () ? AF_INET6 : AF_INET)) { 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_) ...@@ -670,8 +669,6 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
free (if_name); free (if_name);
if (str_rc2 == 0) if (str_rc2 == 0)
free (if_friendly_name); free (if_friendly_name);
current_addresses = current_addresses->Next;
} }
free (addresses); 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