From: Sami Kerola Date: Wed, 5 Oct 2016 20:48:18 +0000 (+0100) Subject: cleanup: remove dead code X-Git-Tag: v0.88~21^2^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f35df3d96c6eaa7c7f84e34b34d52cdaa5e648b3;p=thirdparty%2Fmtr.git cleanup: remove dead code Mostly comments, and some code without effect. Reference: bfcbfb9db72e88c8124ac5e181666b49d3716329 --- diff --git a/curses.c b/curses.c index 924426e..20fb497 100644 --- a/curses.c +++ b/curses.c @@ -21,7 +21,6 @@ #include #include -#ifdef HAVE_NCURSES #include #include #include @@ -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 @@ -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 6a325ab..81d7a23 100644 --- 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;iaf); - //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 0fcd863..f141fb4 100644 --- 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 990f2b7..5ddd28a 100644 --- 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 845d1c5..d47a61e 100644 --- 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 c271178..47ef342 100644 --- 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;iaf ) == 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 0c565e9..4bc723a 100644 --- a/raw.c +++ b/raw.c @@ -34,16 +34,6 @@ #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) { diff --git a/select.c b/select.c index 745faad..9a243e6 100644 --- 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; }