]> git.draconx.ca Git - rarpd-dx.git/commitdiff
Stop using GNU "error" functions.
authorNick Bowler <nbowler@draconx.ca>
Thu, 27 Jul 2023 04:05:32 +0000 (00:05 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 27 Jul 2023 04:10:36 +0000 (00:10 -0400)
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.

configure.ac
src/rarpd.c

index af8b33ff9e7371ca4000bffc5bd5d455dfc96821..cd2be37b1779180253772aa0d1f0331e91e398f3 100644 (file)
@@ -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
index b7aa2e1007e5236318cbd10fb69b753fc7bbc838..2374fb096ed665e0d3e735bab92197a57f46624d 100644 (file)
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 
-#if HAVE_ERROR_H
-#include <error.h>
-#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);