mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
Extend virSocketParseAddr() to allow a NULL result pointer
That way it can be used to verify a numeric address without storing the details * src/util/network.c: change virSocketParseAddr to allow a null @addr parameter
This commit is contained in:
parent
ab8b2bea47
commit
e9a8f3c644
@ -56,7 +56,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) {
|
||||
/**
|
||||
* virSocketParseAddr:
|
||||
* @val: a numeric network address IPv4 or IPv6
|
||||
* @addr: where to store the return value.
|
||||
* @addr: where to store the return value, optional.
|
||||
* @hint: optional hint to pass down to getaddrinfo
|
||||
*
|
||||
* Mostly a wrapper for getaddrinfo() extracting the address storage
|
||||
@ -70,7 +70,7 @@ virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) {
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res = NULL;
|
||||
|
||||
if ((val == NULL) || (addr == NULL))
|
||||
if (val == NULL)
|
||||
return(-1);
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
@ -80,6 +80,7 @@ virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) {
|
||||
}
|
||||
|
||||
len = res->ai_addrlen;
|
||||
if (addr != NULL)
|
||||
memcpy(&addr->stor, res->ai_addr, len);
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
Loading…
Reference in New Issue
Block a user