From: Sami Kerola Date: Sat, 20 Aug 2016 08:17:06 +0000 (+0100) Subject: cleanup: remove obsolete herror() function X-Git-Tag: v0.88~30^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=262291a8c49848ecc1fd82d784cc0c39099de61b;p=thirdparty%2Fmtr.git cleanup: remove obsolete herror() function Applications should use getaddrinfo(3), getnameinfo(3), and gai_strerror(3) instead. Systems without getaddrinfo() are from now on considered too broken to be supported. These include for example platforms: HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 7, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, and BeOS. --- diff --git a/configure.ac b/configure.ac index ea9e1ce..98f0c63 100644 --- a/configure.ac +++ b/configure.ac @@ -122,10 +122,7 @@ AC_CHECK_FUNC([res_query], [RESOLV_LIBS=""], [ ]) AC_SUBST([RESOLV_LIBS]) -# Error printing functions. -AC_CHECK_FUNC([herror], [], - [AC_DEFINE([NO_HERROR], [1], [Define if you don't have the herror() function available.])]) - +# Check errno and socket data types. AC_CHECK_DECLS([errno], [], [], [[ #include #include diff --git a/mtr.c b/mtr.c index d6d3a4b..cc01537 100644 --- a/mtr.c +++ b/mtr.c @@ -53,11 +53,6 @@ #endif -#ifdef NO_HERROR -#define herror(str) fprintf(stderr, str ": error looking up \"%s\"\n", Hostname); -#endif - - int DisplayMode; int display_mode; int Interactive = 1; @@ -642,12 +637,12 @@ int main(int argc, char **argv) { struct hostent * host = NULL; int net_preopen_result; -#ifdef ENABLE_IPV6 struct addrinfo hints, *res; int error; struct hostent trhost; char * alptr[2]; struct sockaddr_in * sa4; +#ifdef ENABLE_IPV6 struct sockaddr_in6 * sa6; #endif @@ -726,7 +721,6 @@ int main(int argc, char **argv) } } -#ifdef ENABLE_IPV6 /* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */ memset( &hints, 0, sizeof hints ); hints.ai_family = af; @@ -758,10 +752,12 @@ int main(int argc, char **argv) sa4 = (struct sockaddr_in *) res->ai_addr; alptr[0] = (void *) &(sa4->sin_addr); break; +#ifdef ENABLE_IPV6 case AF_INET6: sa6 = (struct sockaddr_in6 *) res->ai_addr; alptr[0] = (void *) &(sa6->sin6_addr); break; +#endif default: fprintf( stderr, "mtr unknown address type\n" ); if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE); @@ -771,18 +767,6 @@ int main(int argc, char **argv) } } alptr[1] = NULL; -#else - host = gethostbyname(Hostname); - if (host == NULL) { - herror("mtr gethostbyname"); - if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE); - else { - names = names->next; - continue; - } - } - af = host->h_addrtype; -#endif if (net_open(host) != 0) { fprintf(stderr, "mtr: Unable to start net module.\n");