]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
cleanup: remove dead code
authorSami Kerola <kerolasa@iki.fi>
Wed, 5 Oct 2016 20:48:18 +0000 (21:48 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:19 +0000 (19:29 +0100)
Mostly comments, and some code without effect.

Reference: bfcbfb9db72e88c8124ac5e181666b49d3716329

curses.c
dns.c
dns.h
gtk.c
mtr.c
net.c
raw.c
select.c

index 924426ed9576fbc7fc072e01f359bab1824c74a6..20fb497e8a15ec6d51d19f10168a07c7127a8f30 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -21,7 +21,6 @@
 #include <strings.h>
 #include <unistd.h>
 
-#ifdef HAVE_NCURSES
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
@@ -50,6 +49,9 @@
 #  error No curses header file available
 #endif
 
+/* This go-around is needed only when compiling with antique version of curses.
+   getmaxyx is part of Technical Standard X/Open Curses Issue 4, Version 2 (1996).
+   http://pubs.opengroup.org/onlinepubs/9693989999/toc.pdf see page 106 */
 #ifndef getmaxyx
 #  define getmaxyx(win,y,x)    ((y) = (win)->_maxy + 1, (x) = (win)->_maxx + 1)
 #endif
@@ -62,8 +64,6 @@
 #include "display.h"
 #include "utils.h"
 
-#endif
-
 #include <time.h>
 
 
@@ -637,21 +637,6 @@ extern void mtr_curses_redraw(struct mtr_ctl *ctl)
   attroff(A_BOLD);
 
   mvprintw(1, 0, "%s (%s)", ctl->LocalHostname, net_localaddr());
-  /*
-  printw("(tos=0x%X ", tos);
-  printw("psize=%d ", packetsize );
-  printw("bitpattern=0x%02X)", (unsigned char)(abs(ctl->bitpattern)));
-  if( cpacketsize > 0 ){
-    printw("psize=%d ", cpacketsize);
-  } else {
-    printw("psize=rand(%d,%d) ",MINPACKET, -cpacketsize);
-  }
-  if( ctl->bitpattern>=0 ){
-    printw("bitpattern=0x%02X)", (unsigned char)(ctl->bitpattern));
-  } else {
-    printw("bitpattern=rand(0x00-FF))");
-  }
-  */
   t = time(NULL);
   mvprintw(1, maxx-25, iso_time(&t));
   printw("\n");
diff --git a/dns.c b/dns.c
index 6a325abb76cbf92da0d44bde5990d60a2094fd9a..81d7a2330f5c95ec0abb23a8ec23790235fcf240 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -93,9 +93,7 @@ static struct dns_results *findip (struct mtr_ctl *ctl, ip_t *ip)
 {
   struct dns_results *t;
   
-  //printf ("Looking for: %s\n",  strlongip (ctl, ip));
   for (t=results;t;t=t->next) {
-    //printf ("comparing: %s\n",  strlongip (ctl, &t->ip));
     if (addrcmp ( (void *)ip, (void*) &t->ip, ctl->af) == 0)
       return t;
   }
@@ -127,12 +125,6 @@ static void set_sockaddr_ip (struct mtr_ctl *ctl, struct sockaddr_storage *sa, i
 static int todns[2], fromdns[2];
 FILE *fromdnsfp;
 
-#if 0
-static void handle_sigchld(int sig) {
-  while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
-}
-#endif
-
 extern void dns_open(struct mtr_ctl *ctl)
 {
   int pid; 
@@ -146,26 +138,19 @@ extern void dns_open(struct mtr_ctl *ctl)
   }
   fflush (stdout);
   pid = fork ();
-  //pid = 1;
   if (pid < 0) {
     error(EXIT_FAILURE, errno, "can't fork for DNS process");
   }
   if (pid == 0) {
     char buf[2048];
     int i;
-    FILE *infp; //, *outfp;
+    FILE *infp;
 
     // Automatically reap children. 
     if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
       error(EXIT_FAILURE, errno, "signal");
     }
 
-#if 0
-    // No longer necessary: we close all of them below.
-    // The child: We're going to handle the DNS requests here. 
-    close (todns[1]); // close the pipe ends we don't need. 
-    close (fromdns[0]);
-#endif
     // Close all unneccessary FDs.
     // for debugging and error reporting, keep std-in/out/err.
     for (i=3;i<fromdns[1];i++) {
@@ -174,7 +159,6 @@ extern void dns_open(struct mtr_ctl *ctl)
        close (i);
     }
     infp = fdopen (todns[0],"r"); 
-    //outfp = fdopen (fromdns[1],"w"); 
 
     while (fgets (buf, sizeof (buf), infp)) {
       ip_t host; 
@@ -189,7 +173,6 @@ extern void dns_open(struct mtr_ctl *ctl)
         buf[strlen(buf)-1] = 0; // chomp newline.
 
         longipstr (buf, &host, ctl->af);
-        //printf ("resolving %s (%d)\n", strlongip (ctl, &host), ctl->af);
         set_sockaddr_ip (ctl, &sa, &host);
         salen = (ctl->af == AF_INET)?sizeof(struct sockaddr_in):
                                 sizeof(struct sockaddr_in6);
@@ -198,7 +181,6 @@ extern void dns_open(struct mtr_ctl *ctl)
                               hostname, sizeof (hostname), NULL, 0, 0);
         if (rv == 0) {
           sprintf (result, "%s %s\n", strlongip (ctl, &host), hostname);
-          //printf ("resolved: %s -> %s (%d)\n", strlongip (ctl, &host), hostname, rv);
           rv = write (fromdns[1], result, strlen (result));
           if (rv < 0)
             error (0, errno, "write DNS lookup result");
@@ -277,14 +259,10 @@ extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip)
         return strlongip (ctl, ip);
   } else {
      r = xmalloc (sizeof (struct dns_results));
-     //r->ip = *ip;
      memcpy (&r->ip, ip, sizeof (r->ip));
      r->name = NULL;
      r->next = results;
      results = r;
-
-     //printf ("lookup: %s\n", strlongip (ctl, ip));
-
      snprintf (buf, sizeof(buf), "%s\n", strlongip (ctl, ip));
      rv = write  (todns[1], buf, strlen (buf));
      if (rv < 0)
@@ -304,21 +282,6 @@ extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip)
   return t;
 }
 
-
-#if 0
-extern char *strlongip(struct mtr_ctl *ctl, ip_t * ip)
-{
-#ifdef ENABLE_IPV6
-  static char addrstr[INET6_ADDRSTRLEN];
-
-  return (char *) inet_ntop( ctl->af, ip, addrstr, sizeof addrstr );
-#else
-  return inet_ntoa( *ip );
-#endif
-}
-#endif
-
-
 // XXX check if necessary/exported. 
 
 /* Resolve an IP address to a hostname. */ 
diff --git a/dns.h b/dns.h
index 0fcd863003263528a92ce4c2dca1b7d19ee3d872..f141fb427262246933f04dde723c37ee3934b704 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -28,21 +28,6 @@ extern void dns_ack(struct mtr_ctl *ctl);
 #ifdef ENABLE_IPV6
 extern int dns_waitfd6(void);
 extern void dns_ack6(void);
-#ifdef NEED_RES_STATE_EXT
-/* __res_state_ext is missing on many (most?) BSD systems */
-struct __res_state_ext {
-       union res_sockaddr_union nsaddrs[MAXNS];
-       struct sort_list {
-               int     af;
-               union {
-                       struct in_addr  ina;
-                       struct in6_addr in6a;
-               } addr, mask;
-       } sort_list[MAXRESOLVSORT];
-       char nsuffix[64];
-       char nsuffix2[64];
-};
-#endif
 #endif
 
 extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * address);
diff --git a/gtk.c b/gtk.c
index 990f2b794b898607939f2e0cc9e6eff85895913a..5ddd28a92fdb0fe657676557c2413e6be33e4ce8 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -274,9 +274,6 @@ static void Toolbar_fill(struct mtr_ctl *ctl, GtkWidget *Toolbar)
                                                   0.0);
   Button = gtk_spin_button_new(Adjustment, 0.5, 2);
   gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(Button), TRUE);
-  /* gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(Button), FALSE); */
-  /* gtk_spin_button_set_set_update_policy(GTK_SPIN_BUTTON(Button),
-     GTK_UPDATE_IF_VALID); */
   gtk_box_pack_end(GTK_BOX(Toolbar), Button, FALSE, FALSE, 0);
   ctl->gtk_data = Button;
   g_signal_connect(GTK_OBJECT(Adjustment), "value_changed",
diff --git a/mtr.c b/mtr.c
index 845d1c5721f2127c07a480599b1cca33c802e632..d47a61e97247782285e59f244e3e0aac5367eb32 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -701,7 +701,6 @@ extern int main(int argc, char **argv)
   while (names != NULL) {
 
     ctl.Hostname = names->name;
-    //  if (Hostname == NULL) Hostname = "localhost"; // no longer necessary.
     if (gethostname(ctl.LocalHostname, sizeof(ctl.LocalHostname))) {
       xstrncpy(ctl.LocalHostname, "UNKNOWNHOST", sizeof(ctl.LocalHostname));
     }
diff --git a/net.c b/net.c
index c27117818d8846e1c0c204118dc5753c4a25624b..47ef342c351f559e3f44c191dee12acc458bc520 100644 (file)
--- a/net.c
+++ b/net.c
@@ -146,7 +146,6 @@ struct nethost {
   int avg;     /* average:  addByMin */
   int gmean;   /* geometric mean: addByMin */
   int jitter;  /* current jitter, defined as t1-t0 addByMin */
-/*int jbest;*/ /* min jitter, of cause it is 0, not needed */
   int javg;    /* avg jitter */
   int jworst;  /* max jitter */
   int jinta;   /* estimated variance,? rfc1889's "Interarrival Jitter" */
@@ -174,7 +173,6 @@ static int BSDfix = 0;
 
 static struct nethost host[MaxHost];
 static struct sequence sequence[MaxSequence];
-static struct timeval reset = { 0, 0 };
 
 static int    sendsock4;
 static int    sendsock4_icmp;
@@ -378,7 +376,6 @@ static void net_send_tcp(struct mtr_ctl *ctl, int index)
     error(EXIT_FAILURE, errno, "getsockname()");
   }
 
-  //  opt = 1;
   flags = fcntl(s, F_GETFL, 0);
   if (flags < 0) {
     display_clear(ctl);
@@ -817,17 +814,6 @@ static void net_process_ping(struct mtr_ctl *ctl, int seq, struct mplslen mpls,
     host[index].jitter = host[index].jworst = host[index].jinta= 0;
   }
 
-  /* some time best can be too good to be true, experienced 
-   * at least in linux 2.4.x.
-   *  safe guard 1) best[index]>=best[index-1] if index>0
-   *             2) best >= average-20,000 usec (good number?)
-  if (index > 0) {
-    if (totusec < host[index].best &&
-       totusec>= host[index-1].best) host[index].best  = totusec;
-  } else {
-    if(totusec < host[index].best) host[index].best  = totusec;
-  }
-   */
   if (totusec < host[index].best ) host[index].best  = totusec;
   if (totusec > host[index].worst) host[index].worst = totusec;
 
@@ -1207,7 +1193,6 @@ extern int net_max(struct mtr_ctl *ctl)
   int max;
 
   max = 0;
-  /* for(at = 0; at < MaxHost-2; at++) { */
   for(at = 0; at < ctl->maxTTL-1; at++) {
     if ( addrcmp( (void *) &(host[at].addr),
                   (void *) remoteaddress, ctl->af ) == 0 ) {
@@ -1288,8 +1273,6 @@ extern int net_send_batch(struct mtr_ctl *ctl)
     }
   }
 
-  /* printf ("cpacketsize = %d, packetsize = %d\n", cpacketsize, packetsize);  */
-
   net_send_query(ctl, batch_at);
 
   for (i=ctl->fstTTL-1;i<batch_at;i++) {
@@ -1302,8 +1285,7 @@ extern int net_send_batch(struct mtr_ctl *ctl)
        If the line proves necessary, it should at least NOT trigger that line
        when host[i].addr == 0 */
     if ( ( addrcmp( (void *) &(host[i].addr),
-                    (void *) remoteaddress, ctl->af ) == 0 )
-       /* || (host[i].addr == host[batch_at].addr)  */)
+                    (void *) remoteaddress, ctl->af ) == 0 ))
       n_unknown = MaxHost; /* Make sure we drop into "we should restart" */
   }
 
@@ -1455,9 +1437,6 @@ extern int net_open(struct mtr_ctl *ctl, struct hostent * hostent)
   len = sizeof name_struct; 
   getsockname (recvsock, name, &len);
   sockaddrtop( name, localaddr, sizeof localaddr );
-#if 0
-  printf ("got localaddr: %s\n", localaddr); 
-#endif
 
   return 0;
 }
@@ -1518,7 +1497,6 @@ extern void net_reset(struct mtr_ctl *ctl)
     }
   }
 
-  gettimeofday(&reset, NULL);
 }
 
 static int net_set_interfaceaddress_udp(struct mtr_ctl *ctl)
diff --git a/raw.c b/raw.c
index 0c565e93e91c5475960e5df81ec1177d86783bcc..4bc723a515d948be0d170d130431780fb097f882 100644 (file)
--- a/raw.c
+++ b/raw.c
 #include "dns.h"
 
 
-#if 0
-static char *addr_to_str(struct mtr_ctl *ctl, ip_t addr)
-{
-  static char buf[20];
-
-  sprintf (buf, "%s", strlongip(ctl, &addr ));
-  return buf;
-}
-#endif
-
 // Log an echo request, or a "ping"
 extern void raw_rawxmit (int host, int seq)
 {
index 745faade667283fe2690631bc10f822fbc53b602..9a243e6fef0ab0b5f051d05a5733ebe1cd8e473b 100644 (file)
--- a/select.c
+++ b/select.c
@@ -44,8 +44,6 @@
 static double dnsinterval;
 static struct timeval intervaltime;
 
-#define GRACETIME (ctl->GraceTime * 1000*1000)
-
 extern void select_loop(struct mtr_ctl *ctl){
   fd_set readfd;
   fd_set writefd;
@@ -145,7 +143,7 @@ extern void select_loop(struct mtr_ctl *ctl){
        if (graceperiod) {
          dt = (thistime.tv_usec - startgrace.tv_usec) +
                    1000000 * (thistime.tv_sec - startgrace.tv_sec);
-         if (dt > GRACETIME)
+         if ((ctl->GraceTime * 1000 * 1000) < dt)
            return;
        }