]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
net: simplify AI_IDN guards 629/head
authorDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 13:38:58 +0000 (17:38 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 13:38:58 +0000 (17:38 +0400)
Use the AI_IDN macro directly after checking for netdb.h in configure. This follows the libc-based IDN approach from #620 while keeping the relevant header checks explicit.

Suggested-by: yvs <VSYakovetsky@gmail.com>
configure.ac
ui/asn.c
ui/mtr.c
ui/mtr.h
ui/net.h
ui/report.c

index b6f7a3b1185a50e9081840327884f08b5b80c420..3edc58f1a1ac6a62ff95850f8ffd38d3a2e4d879 100644 (file)
@@ -52,6 +52,7 @@ AC_CHECK_HEADERS([ \
   linux/errqueue.h \
   ncurses.h \
   ncurses/curses.h \
+  netdb.h \
   netinet/in.h \
   socket.h \
   sys/cdefs.h \
@@ -207,14 +208,6 @@ AC_CHECK_DECLS([errno], [], [], [[
 #include <errno.h>
 #include <sys/errno.h>
   ]])
-AC_CHECK_DECLS([AI_IDN], [], [], [[
-#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#include <netdb.h>
-  ]])
-
 AC_CHECK_TYPE([socklen_t],
   [AC_DEFINE([HAVE_SOCKLEN_T], [], [Define if your system has socklen_t])], [],
   [[#include <netinet/in.h>
index cae9971e3ab840f1e667e74e8a34f7dd671a0b00..659f91018d3a1809297473af7891fd14d101891d 100644 (file)
--- a/ui/asn.c
+++ b/ui/asn.c
@@ -39,7 +39,9 @@
 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
 #include <arpa/nameser_compat.h>
 #endif
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <netinet/in.h>
 #include <resolv.h>
 #include <string.h>
index 54b976b110baf42b73089e8dc303d64a5a4d7dac..a9b99e856fd8281370da96721624b1e9ef2bf9dc 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -851,7 +851,7 @@ int get_addrinfo_from_name(
     memset(&hints, 0, sizeof hints);
     hints.ai_family = ctl->af;
     hints.ai_socktype = SOCK_DGRAM;
-#if HAVE_DECL_AI_IDN
+#ifdef AI_IDN
     hints.ai_flags = AI_IDN;
 #endif
     gai_error = getaddrinfo(name, NULL, &hints, res);
@@ -898,7 +898,7 @@ static int validate_report_targets(
         memset(&hints, 0, sizeof hints);
         hints.ai_family = lookup_ctl.af;
         hints.ai_socktype = SOCK_DGRAM;
-#if HAVE_DECL_AI_IDN
+#ifdef AI_IDN
         hints.ai_flags = AI_IDN;
 #endif
         gai_error = getaddrinfo(names->name, NULL, &hints, &res);
index 7af3dcc89ae3be2dd9349fd4a0655fa6c2ce1336..c4fd2ebf94bd7bebd6bfa0b00643a59d390655fa 100644 (file)
--- a/ui/mtr.h
+++ b/ui/mtr.h
@@ -23,7 +23,9 @@
 #include "config.h"
 
 #include <stdint.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <sys/socket.h>
 #include <arpa/inet.h>
 
index 354c99845bf947687ec44ee4d89e155b7d67cecb..1bc4d65f1b5444eb3b3caa8eb64f23b4c69d03ec 100644 (file)
--- a/ui/net.h
+++ b/ui/net.h
@@ -18,7 +18,9 @@
 
 /*  Prototypes for functions in net.c  */
 #include <sys/types.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
index acc72c0035809b70c5feb9ac855286fb0371dcd2..11353c02b6025b0de251f841a0a2b4502c9153bc 100644 (file)
@@ -20,7 +20,9 @@
 
 #include <sys/types.h>
 #include <stdio.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <string.h>