getifaddrs: don't fail if there are no interfaces.

* This is not an error, just return an empty list.
* Same behavior as *BSD implementation.
This commit is contained in:
Adrien Destugues 2015-07-29 22:53:31 +02:00
parent 2df7158917
commit f93dab03ec

View File

@ -78,8 +78,9 @@ getifaddrs(struct ifaddrs** _ifaddrs)
size_t count = (size_t)config.ifc_value;
if (count == 0) {
errno = B_BAD_VALUE;
return -1;
// No interfaces found
*_ifaddrs = NULL;
return 0;
}
// Allocate a buffer for ifreqs for all interfaces