From: Roger Wolff Date: Sat, 6 Jul 2013 05:36:42 +0000 (+0200) Subject: removed double negatives for ipinfo define. X-Git-Tag: v0.86~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d772cc8188e7c99fdaa98fecc04d159b7cdac3c;p=thirdparty%2Fmtr.git removed double negatives for ipinfo define. --- diff --git a/asn.h b/asn.h index d5a6bd3..dd2d440 100644 --- a/asn.h +++ b/asn.h @@ -16,6 +16,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// The autoconf system provides us with the NO_IPINFO define. +// Littering the code with #ifndef NO_IPINFO (double negative) +// does not benefit readabilty. So here we invert the sense of the +// define. +// +// Similarly, this include file should be included unconditially. +// It will evaluate to nothing if we don't need it. + +#ifndef NO_IPINFO +#define IPINFO + + extern int ipinfo_no; extern int ipinfo_max; extern int iiwidth_len; @@ -26,3 +38,4 @@ char *fmt_ipinfo(ip_t *addr); int get_iiwidth(void); int is_printii(void); +#endif diff --git a/curses.c b/curses.c index a103a43..eacc40d 100644 --- a/curses.c +++ b/curses.c @@ -60,12 +60,11 @@ #include "mtr.h" #include "mtr-curses.h" -#include "display.h" #include "net.h" #include "dns.h" -#ifndef NO_IPINFO #include "asn.h" -#endif +#include "display.h" + #include "version.h" #endif @@ -121,7 +120,7 @@ int mtr_curses_keyaction(void) return ActionMPLS; if (tolower(c) == 'n') return ActionDNS; -#ifndef NO_IPINFO +#ifdef IPINFO if (tolower(c) == 'y') return ActionII; if (tolower(c) == 'z') @@ -304,7 +303,7 @@ int mtr_curses_keyaction(void) printw(" b set ping bit pattern to c(0..255) or random(c<0)\n" ); printw(" Q set ping packet's TOS to t\n" ); printw(" u switch between ICMP ECHO and UDP datagrams\n" ); -#ifndef NO_IPINFO +#ifdef IPINFO printw(" y switching IP info\n"); printw(" z toggle ASN info on/off\n"); pressanykey_row += 2; @@ -344,7 +343,7 @@ void mtr_curses_hosts(int startstat) name = dns_lookup(addr); if (! net_up(at)) attron(A_BOLD); -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) printw(fmt_ipinfo(addr)); #endif @@ -401,7 +400,7 @@ void mtr_curses_hosts(int startstat) name = dns_lookup(addrs); if (! net_up(at)) attron(A_BOLD); printw("\n "); -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) printw(fmt_ipinfo(addrs)); #endif @@ -552,7 +551,7 @@ void mtr_curses_graph(int startstat, int cols) if (! net_up(at)) attron(A_BOLD); if (addrcmp((void *) addr, (void *) &unspec_addr, af)) { -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) printw(fmt_ipinfo(addr)); #endif @@ -642,7 +641,7 @@ void mtr_curses_redraw(void) } else { char msg[80]; int padding = 30; -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) padding += get_iiwidth(); #endif diff --git a/display.c b/display.c index cc5cd59..aa369ee 100644 --- a/display.c +++ b/display.c @@ -29,9 +29,7 @@ #include "select.h" #include "raw.h" #include "dns.h" -#ifndef NO_IPINFO -#include -#endif +#include "asn.h" extern int DisplayMode; @@ -97,7 +95,7 @@ void display_open(void) break; case DisplayCurses: mtr_curses_open(); -#ifndef NO_IPINFO +#ifdef IPINFO if (ipinfo_no >= 0) asn_open(); #endif @@ -128,7 +126,7 @@ void display_close(time_t now) csv_close(now); break; case DisplayCurses: -#ifndef NO_IPINFO +#ifdef IPINFO if (ipinfo_no >= 0) asn_close(); #endif diff --git a/display.h b/display.h index 4ed2d66..6168914 100644 --- a/display.h +++ b/display.h @@ -22,7 +22,7 @@ (notably the one on Irix 5.2) do not like that. */ enum { ActionNone, ActionQuit, ActionReset, ActionDisplay, ActionClear, ActionPause, ActionResume, ActionMPLS, ActionDNS, -#ifndef NO_IPINFO +#ifdef IPINFO ActionII, ActionAS, #endif ActionScrollDown, ActionScrollUp }; diff --git a/mtr.c b/mtr.c index 833de39..cf24562 100644 --- a/mtr.c +++ b/mtr.c @@ -41,9 +41,7 @@ #include "dns.h" #include "report.h" #include "net.h" -#ifndef NO_IPINFO #include "asn.h" -#endif #include "version.h" @@ -290,7 +288,7 @@ void parse_arg (int argc, char **argv) { "timeout", 1, 0, 'Z' }, /* timeout for TCP sockets */ { "inet", 0, 0, '4' }, /* IPv4 only */ { "inet6", 0, 0, '6' }, /* IPv6 only */ -#ifndef NO_IPINFO +#ifdef IPINFO { "ipinfo", 1, 0, 'y' }, /* IP info lookup */ { "aslookup", 0, 0, 'z' }, /* Do AS lookup (--ipinfo 0) */ #endif @@ -456,7 +454,7 @@ void parse_arg (int argc, char **argv) fprintf( stderr, "IPv6 not enabled.\n" ); break; #endif -#ifndef NO_IPINFO +#ifdef IPINFO case 'y': ipinfo_no = atoi (optarg); if (ipinfo_no < 0) @@ -576,7 +574,7 @@ int main(int argc, char **argv) "\t\t[--report-wide] [--report-cycles=COUNT] [--curses] [--gtk]\n" "\t\t[--csv|-C] [--raw] [--split] [--mpls] [--no-dns] [--show-ips]\n" "\t\t[--address interface] [--filename=FILE|-F]\n" /* BL */ -#ifndef NO_IPINFO +#ifdef IPINFO "\t\t[--ipinfo=item_no|-y item_no]\n" "\t\t[--aslookup|-z]\n" #endif diff --git a/report.c b/report.c index cf049c5..fcbaa40 100644 --- a/report.c +++ b/report.c @@ -31,9 +31,7 @@ #include "report.h" #include "net.h" #include "dns.h" -#ifndef NO_IPINFO #include "asn.h" -#endif #define MAXLOADBAL 5 @@ -77,7 +75,7 @@ static size_t snprint_addr(char *dst, size_t dst_len, ip_t *addr) } -#ifndef NO_IPINFO +#ifdef IPINFO void print_mpls(struct mplslen *mpls) { int k; for (k=0; k < mpls->labels; k++) @@ -112,7 +110,7 @@ void report_close(void) } } -#ifndef NO_IPINFO +#ifdef IPINFO int len_tmp = len_hosts; if (ipinfo_no >= 0) { ipinfo_no %= iiwidth_len; @@ -146,7 +144,7 @@ void report_close(void) mpls = net_mpls(at); snprint_addr(name, sizeof(name), addr); -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { snprintf(fmt, sizeof(fmt), " %%2d. %%s%%-%ds", len_hosts); snprintf(buf, sizeof(buf), fmt, at+1, fmt_ipinfo(addr), name); @@ -154,7 +152,7 @@ void report_close(void) #endif snprintf( fmt, sizeof(fmt), " %%2d.|-- %%-%ds", len_hosts); snprintf(buf, sizeof(buf), fmt, at+1, name); -#ifndef NO_IPINFO +#ifdef IPINFO } #endif len = reportwide ? strlen(buf) : len_hosts; @@ -192,7 +190,7 @@ void report_close(void) if (!found) { -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { if (mpls->labels && z == 1 && enablempls) print_mpls(mpls); @@ -221,14 +219,14 @@ void report_close(void) } } #endif -#ifndef NO_IPINFO +#ifdef IPINFO } #endif } } /* No multipath */ -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { if (mpls->labels && z == 1 && enablempls) print_mpls(mpls); @@ -241,7 +239,7 @@ void report_close(void) } } #endif -#ifndef NO_IPINFO +#ifdef IPINFO } #endif } @@ -340,7 +338,7 @@ void csv_close(time_t now) snprint_addr(name, sizeof(name), addr); int last = net_last(at); -#ifndef NO_IPINFO +#ifdef IPINFO if(!ipinfo_no) { char* fmtinfo = fmt_ipinfo(addr); if (fmtinfo != NULL) fmtinfo = trim(fmtinfo); diff --git a/select.c b/select.c index 377fe20..0545d9f 100644 --- a/select.c +++ b/select.c @@ -29,12 +29,10 @@ #include #include "mtr.h" -#include "display.h" #include "dns.h" #include "net.h" -#ifndef NO_IPINFO #include "asn.h" -#endif +#include "display.h" extern int Interactive; extern int MaxPing; @@ -210,7 +208,7 @@ void select_loop(void) { display_clear(); } break; -#ifndef NO_IPINFO +#ifdef IPINFO case ActionII: if (ipinfo_no >= 0) { ipinfo_no++;