From: Nick Bowler Date: Thu, 27 Jul 2023 04:05:32 +0000 (-0400) Subject: Stop using GNU "error" functions. X-Git-Tag: v1~4 X-Git-Url: https://git.draconx.ca/gitweb/rarpd-dx.git/commitdiff_plain/0bf68d0c2640d1bd7a50e8438a89164e68d03e0d Stop using GNU "error" functions. For an actually portable error fallback, just don't use error at all. There are literally just 3 calls to the GNU error function, all of which are directly in main. We can just use normal prints and return. --- diff --git a/configure.ac b/configure.ac index af8b33f..cd2be37 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,5 @@ $XSLTPROC --nonet conftest.xsl conftest.xml >conftest.out 2>&AS_MESSAGE_LOG_FD & rm -f conftest.xsl conftest.xml conftest.out])]) AM_CONDITIONAL([HAVE_XSLTPROC], [test x"$dx_cv_xsltproc_works" = x"yes"]) -AC_CHECK_HEADERS_ONCE([error.h]) - AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/src/rarpd.c b/src/rarpd.c index b7aa2e1..2374fb0 100644 --- a/src/rarpd.c +++ b/src/rarpd.c @@ -32,10 +32,6 @@ #include #include -#if HAVE_ERROR_H -#include -#endif - int do_reload = 1; int debug; @@ -657,8 +653,10 @@ int main(int argc, char **argv) memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, ifname, IFNAMSIZ); if (ioctl(pset[0].fd, SIOCGIFINDEX, &ifr)) { - error(0, errno, "ioctl(SIOCGIFINDEX)"); - usage(); + fprintf(stderr, "%s: %s: ioctl(SIOCGIFINDEX): %s\n", + progname, ifname, strerror(errno)); + print_usage(stderr); + return EXIT_FAILURE; } ifidx = ifr.ifr_ifindex; } @@ -699,12 +697,17 @@ int main(int argc, char **argv) pset[0] = pset[1]; psize--; } - if (psize == 0) - error(1, errno, "failed to bind any socket"); + if (psize == 0) { + fprintf(stderr, "%s: error: failed to bind any socket\n", progname); + return EXIT_FAILURE; + } if (!debug) { - if (daemon(0, 0) < 0) - error(1, errno, "failed to daemon()"); + if (daemon(0, 0) < 0) { + fprintf(stderr, "%s: error: daemon() failed: %s\n", + progname, strerror(errno)); + return EXIT_FAILURE; + } } openlog("rarpd", LOG_PID | LOG_CONS, LOG_DAEMON);