tableid is either initialized to the current routing table or to the
one specified by the T flag. No need to pass a flag around if the
tableid is valid. It always is.
    
This code is now in sync between flushroutes() and p_rttables().

OK?

diff --git route.c route.c
index 229cca1491d..5e1aacd83e2 100644
--- route.c
+++ route.c
@@ -750,7 +750,7 @@ show(int argc, char *argv[])
                        usage(*argv);
        }
 
-       p_rttables(af, tableid, Tflag, prio);
+       p_rttables(af, tableid, prio);
        return (0);
 }
 
diff --git show.c show.c
index bfd726e6a20..f67b45b359f 100644
--- show.c
+++ show.c
@@ -111,12 +111,12 @@ char      *netname6(struct sockaddr_in6 *, struct 
sockaddr_in6 *);
  * Print routing tables.
  */
 void
-p_rttables(int af, u_int tableid, int hastable, char prio)
+p_rttables(int af, u_int tableid, char prio)
 {
        struct rt_msghdr *rtm;
        char *buf = NULL, *next, *lim = NULL;
        size_t needed;
-       int mib[7], mcnt;
+       int mib[7];
        struct sockaddr *sa;
 
        mib[0] = CTL_NET;
@@ -125,20 +125,16 @@ p_rttables(int af, u_int tableid, int hastable, char prio)
        mib[3] = af;
        mib[4] = NET_RT_DUMP;
        mib[5] = prio;
-       if (hastable) {
-               mib[6] = tableid;
-               mcnt = 7;
-       } else
-               mcnt = 6;
+       mib[6] = tableid;
 
        while (1) {
-               if (sysctl(mib, mcnt, NULL, &needed, NULL, 0) == -1)
+               if (sysctl(mib, 7, NULL, &needed, NULL, 0) == -1)
                        err(1, "route-sysctl-estimate");
                if (needed == 0)
                        break;
                if ((buf = realloc(buf, needed)) == NULL)
                        err(1, NULL);
-               if (sysctl(mib, mcnt, buf, &needed, NULL, 0) == -1) {
+               if (sysctl(mib, 7, buf, &needed, NULL, 0) == -1) {
                        if (errno == ENOMEM)
                                continue;
                        err(1, "sysctl of routing table");
diff --git show.h show.h
index 14c8b0e9c11..0a06fd8edf6 100644
--- show.h
+++ show.h
@@ -29,7 +29,7 @@ union sockunion {
 };
 
 void    get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
-void    p_rttables(int, u_int, int, char);
+void    p_rttables(int, u_int, char);
 void    p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
 char   *routename(struct sockaddr *);
 char   *netname(struct sockaddr *, struct sockaddr *);

-- 
I'm not entirely sure you are real.

Reply via email to