]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
removed double negatives for ipinfo define.
authorRoger Wolff <R.E.Wolff@BitWizard.nl>
Sat, 6 Jul 2013 05:36:42 +0000 (07:36 +0200)
committerRoger Wolff <R.E.Wolff@BitWizard.nl>
Sat, 6 Jul 2013 05:36:42 +0000 (07:36 +0200)
asn.h
curses.c
display.c
display.h
mtr.c
report.c
select.c

diff --git a/asn.h b/asn.h
index d5a6bd3ddb67067f2d9c33f1c6e821d904ad2579..dd2d4407e3460e0bd76aae3819851c7c2d01a77f 100644 (file)
--- a/asn.h
+++ b/asn.h
     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
index a103a4359fbab232ca98a2b7a6135ac54ee9cd8a..eacc40d9c6043e431e2af113c8b3f0fe285a61c6 100644 (file)
--- a/curses.c
+++ b/curses.c
 
 #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 <c>   set ping bit pattern to c(0..255) or random(c<0)\n" );
     printw("  Q <t>   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
index cc5cd5966789c9965039de26765f63fa38e21e69..aa369ee18b20885c134a980e134f8cde617ea1e3 100644 (file)
--- a/display.c
+++ b/display.c
@@ -29,9 +29,7 @@
 #include "select.h"
 #include "raw.h"
 #include "dns.h"
-#ifndef NO_IPINFO
-#include <asn.h>
-#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
index 4ed2d66db1255b11517cb42c7df2af0fdc57f55f..6168914b94428f9cd0abdb97844f15632e7d1c53 100644 (file)
--- 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 833de3936dd9a3bb9f6ef455e18f5622663c43b6..cf2456299525306f4864b9a11cc49e9746c0632a 100644 (file)
--- 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
index cf049c541848e39a1816876d6b2f3b16536a4363..fcbaa4017807667826f2162583cf259da30e2d7a 100644 (file)
--- 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);
index 377fe20dc1991c6caa5ecb904f2e94396ac9ce51..0545d9f736d012c11e6018708a6fc6eb8e8f66b9 100644 (file)
--- a/select.c
+++ b/select.c
 #include <errno.h>
 
 #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++;