diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-01-18 11:07:30 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-01-18 11:07:30 -0800 |
commit | deb755c0ad4575a7542e2abcba986a003fddb198 (patch) | |
tree | ca04126559770012446fa935868075d546e215b2 | |
parent | 02415310dd4997b4a7943814381c0b52d91eb8de (diff) |
if inet_ntop() is available, use it, even if IPv6 support is disabled
Support for using inet_ntop() was originally added to support IPv6,
and only used if IPv6 support was enabled. Two decades later, support
for inet_ntop() is ubiquitous and OS'es have marked inet_ntoa()
as deprecated, so use the modern interface whenever we can now.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxtrans/-/merge_requests/28>
-rw-r--r-- | Xtransutil.c | 8 | ||||
-rw-r--r-- | xtrans.m4 | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Xtransutil.c b/Xtransutil.c index b554b66..2aa4686 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -66,6 +66,12 @@ from The Open Group. #error "Cannot build IPv6 support without AF_INET6" #endif +/* Temporary workaround for consumers whose configure scripts were + generated with pre-1.6 versions of xtrans.m4 */ +#if defined(IPv6) && !defined(HAVE_INET_NTOP) +#define HAVE_INET_NTOP +#endif + #ifdef X11_t /* @@ -389,7 +395,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) if (hostp != NULL) addr = hostp->h_name; else -#ifdef IPv6 +#ifdef HAVE_INET_NTOP addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf)); #else addr = inet_ntoa (saddr->sin_addr); @@ -33,7 +33,7 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ fi # Needs to come after above checks for libsocket & libnsl for SVR4 systems - AC_CHECK_FUNCS([getaddrinfo]) + AC_CHECK_FUNCS([getaddrinfo inet_ntop]) AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--enable-ipv6],[Enable IPv6 support]), |