Less nesting for clearer code.

OK?

The macro backslashes got adjusted but diff with `-w' for ease of review.

Index: pfctl_table.c
===================================================================
RCS file: /cvs/src/sbin/pfctl/pfctl_table.c,v
retrieving revision 1.82
diff -u -p -w -r1.82 pfctl_table.c
--- pfctl_table.c       15 Jan 2020 11:52:50 -0000      1.82
+++ pfctl_table.c       15 Jan 2020 15:23:16 -0000
@@ -59,7 +59,6 @@ static void   print_tstats(struct pfr_tsta
 static int     load_addr(struct pfr_buffer *, int, char *[], char *, int, int);
 static void    print_addrx(struct pfr_addr *, struct pfr_addr *, int);
 static void    print_astats(struct pfr_astats *, int);
-static void    radix_perror(void);
 static void    xprintf(int, const char *, ...);
 static void    print_iface(struct pfi_kif *, int);
 
@@ -78,7 +77,7 @@ static const char     *istats_text[2][2][2] 
                    (opts & PF_OPT_DUMMYACTION)) &&     \
                    (fct)) {                            \
                        if ((opts & PF_OPT_RECURSE) == 0)\
-                               radix_perror();         \
+                               warnx("%s", pfr_strerror(errno));       \
                        goto _error;                    \
                }                                       \
        } while (0)
@@ -91,7 +90,7 @@ static const char     *istats_text[2][2][2] 
                    (opts & PF_OPT_DUMMYACTION)) &&                     \
                    (pfr_add_tables(&table, 1, &nadd, flags)) &&        \
                    (errno != EPERM)) {                                 \
-                       radix_perror();                                 \
+                       warnx("%s", pfr_strerror(errno));               \
                        goto _error;                                    \
                }                                                       \
                if (nadd) {                                             \
@@ -509,13 +508,6 @@ print_astats(struct pfr_astats *as, int 
                            (unsigned long long)as->pfras_bytes[dir][op]);
 }
 
-void
-radix_perror(void)
-{
-       extern char *__progname;
-       fprintf(stderr, "%s: %s.\n", __progname, pfr_strerror(errno));
-}
-
 int
 pfctl_define_table(char *name, int flags, int addrs, const char *anchor,
     struct pfr_buffer *ab, u_int32_t ticket)
@@ -598,10 +590,8 @@ pfctl_show_ifaces(const char *filter, in
        for (;;) {
                pfr_buf_grow(&b, b.pfrb_size);
                b.pfrb_size = b.pfrb_msize;
-               if (pfi_get_ifaces(filter, b.pfrb_caddr, &b.pfrb_size)) {
-                       radix_perror();
-                       exit(1);
-               }
+               if (pfi_get_ifaces(filter, b.pfrb_caddr, &b.pfrb_size))
+                       errx(1, "%s", pfr_strerror(errno));
                if (b.pfrb_size <= b.pfrb_msize)
                        break;
                i++;

Reply via email to