diff options
author | Brad King <brad.king@kitware.com> | 2019-01-21 12:54:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-21 12:54:45 (GMT) |
commit | 55a2dc3055e8c5f2189c763eb3fd4c9c754d1c05 (patch) | |
tree | 9b7c691309d0a0eb52acbd32d5357e038552376c /Utilities/cmlibuv/src/unix/sunos.c | |
parent | eadaf0c8c3b4112d38a19b20a9d303e83640373d (diff) | |
parent | 5b3af28e4532eadf92dee229870cadc94be9c635 (diff) | |
download | CMake-55a2dc3055e8c5f2189c763eb3fd4c9c754d1c05.zip CMake-55a2dc3055e8c5f2189c763eb3fd4c9c754d1c05.tar.gz CMake-55a2dc3055e8c5f2189c763eb3fd4c9c754d1c05.tar.bz2 |
Merge topic 'update-libuv'
5b3af28e45 libuv: Update CMake-internal buildsystem
1136275ae1 libuv: Include uv/ headers from each other without any path
1e1209729b Merge branch 'upstream-libuv' into update-libuv
4fcb0d0213 libuv 2019-01-15 (f84c5e69)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2822
Diffstat (limited to 'Utilities/cmlibuv/src/unix/sunos.c')
-rw-r--r-- | Utilities/cmlibuv/src/unix/sunos.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Utilities/cmlibuv/src/unix/sunos.c b/Utilities/cmlibuv/src/unix/sunos.c index b92888e..aac6504 100644 --- a/Utilities/cmlibuv/src/unix/sunos.c +++ b/Utilities/cmlibuv/src/unix/sunos.c @@ -696,6 +696,8 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { #ifdef SUNOS_NO_IFADDRS int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { + *count = 0; + *addresses = NULL; return UV_ENOSYS; } #else /* SUNOS_NO_IFADDRS */ @@ -709,13 +711,14 @@ static int uv__set_phys_addr(uv_interface_address_t* address, struct sockaddr_dl* sa_addr; int sockfd; - int i; + size_t i; struct arpreq arpreq; /* This appears to only work as root */ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); for (i = 0; i < sizeof(address->phys_addr); i++) { + /* Check that all bytes of phys_addr are zero. */ if (address->phys_addr[i] != 0) return 0; } @@ -762,11 +765,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { struct ifaddrs* addrs; struct ifaddrs* ent; + *count = 0; + *addresses = NULL; + if (getifaddrs(&addrs)) return UV__ERR(errno); - *count = 0; - /* Count the number of interfaces */ for (ent = addrs; ent != NULL; ent = ent->ifa_next) { if (uv__ifaddr_exclude(ent)) @@ -774,6 +778,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { (*count)++; } + if (*count == 0) { + freeifaddrs(addrs); + return 0; + } + *addresses = uv__malloc(*count * sizeof(**addresses)); if (!(*addresses)) { freeifaddrs(addrs); |