]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
data types: get rid of all globals that are easy to remove
authorSami Kerola <kerolasa@iki.fi>
Sat, 27 Aug 2016 09:51:20 +0000 (10:51 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 27 Aug 2016 09:52:33 +0000 (10:52 +0100)
Some variables are unnecessary, others can be moved to a function or a file
scope.

asn.c
asn.h
curses.c
mtr.c
raw.c

diff --git a/asn.c b/asn.c
index f456ba88d6fb6c9370435c768c8fa735beca516f..90252ddf419eb4b266fa9337c7b3706e92190204 100644 (file)
--- a/asn.c
+++ b/asn.c
@@ -64,7 +64,7 @@
 
 int  ipinfo_no = -1;
 int  ipinfo_max = -1;
-int  iihash = 0;
+static int  iihash = 0;
 char fmtinfo[32];
 extern int af;                  /* address family of remote target */
 
@@ -73,9 +73,9 @@ int iiwidth[] = { 7, 19, 4, 8, 11};   // item len + space
 int iiwidth_len = sizeof(iiwidth)/sizeof((iiwidth)[0]);
 
 typedef char* items_t[ITEMSMAX + 1];
-items_t items_a;               // without hash: items
-char txtrec[NAMELEN + 1];      // without hash: txtrec
-items_t* items = &items_a;
+static items_t items_a;                // without hash: items
+static char txtrec[NAMELEN + 1];       // without hash: txtrec
+static items_t* items = &items_a;
 
 
 static char *ipinfo_lookup(const char *domain) {
diff --git a/asn.h b/asn.h
index b9d0c09469de10cb26c531db800387c71bc655ef..2987b2ccf4ae415faf1933d31368821e63782d12 100644 (file)
--- a/asn.h
+++ b/asn.h
@@ -19,7 +19,6 @@
 extern int ipinfo_no;
 extern int ipinfo_max;
 extern int iiwidth_len;
-extern int iihash;
 extern void asn_open();
 extern void asn_close();
 extern char *fmt_ipinfo(ip_t *addr);
index eaf19f5a5f121e5100401b73a51367a1142b374d..ee00875c5d05f86cf7bab6e20b395ae6d2df841e 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -75,12 +75,12 @@ extern float WaitTime;
 extern int af;
 extern int mtrtype;
 
-static int __unused_int;
 
 static void pwcenter(char *str) 
 {
   int maxx;
   int cx;
+  int __unused_int UNUSED;
 
   getmaxyx(stdscr, __unused_int, maxx);
   cx = (signed)(maxx - strlen(str)) / 2;
@@ -375,6 +375,7 @@ static void mtr_curses_hosts(int startstat)
   int i, j, k;
   int hd_len;
   char buf[1024];
+  int __unused_int UNUSED;
 
   max = net_max();
 
@@ -464,12 +465,12 @@ static void mtr_curses_hosts(int startstat)
 #define NUM_FACTORS 8
 static double factors[NUM_FACTORS];
 static int scale[NUM_FACTORS];
-static int low_ms, high_ms;
 
 static void mtr_gen_scale(void) 
 {
        int *saved, i, max, at;
        int range;
+       static int low_ms, high_ms;
 
        low_ms = 1000000;
        high_ms = -1;
@@ -584,6 +585,7 @@ static void mtr_curses_graph(int startstat, int cols)
        int max, at, y;
        ip_t * addr;
        char* name;
+       int __unused_int UNUSED;
 
        max = net_max();
 
@@ -625,6 +627,7 @@ extern void mtr_curses_redraw(void)
   int startstat;
   int rowstat;
   time_t t;
+  int __unused_int UNUSED;
 
   int i, j;
   int  hd_len = 0;
diff --git a/mtr.c b/mtr.c
index bc6d4bccd708ea308660b70fdb12a78da1c44f0e..dd2ad4eaf7abd1db0f9b9753d56493dc0573ce39 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -68,8 +68,6 @@
 int   DisplayMode;
 int   display_mode;
 int   Interactive = 1;
-int   PrintVersion = 0;
-int   PrintHelp = 0;
 int   MaxPing = 10;
 int   ForceMaxPing = 0;
 float WaitTime = 1.0;
@@ -446,10 +444,11 @@ static void parse_arg (int argc, char **argv)
 
     switch(opt) {
     case 'v':
-      PrintVersion = 1;
+      printf ("mtr " PACKAGE_VERSION "\n");
+      exit(EXIT_SUCCESS);
       break;
     case 'h':
-      PrintHelp = 1;
+      usage(stdout);
       break;
 
     case 'r':
@@ -752,15 +751,6 @@ extern int main(int argc, char **argv)
     error(EXIT_FAILURE, 0, "Couldn't determine raw socket type");
   }
 
-  if (PrintVersion) {
-    printf ("mtr " PACKAGE_VERSION "\n");
-    exit(EXIT_SUCCESS);
-  }
-
-  if (PrintHelp) {
-    usage(stdout);
-  }
-
   time_t now = time(NULL);
 
   if (!names) append_to_names ("localhost"); // default: localhost. 
diff --git a/raw.c b/raw.c
index ed190de56604b9cb14fbb45b52ffb3873ba9f36f..093fc7b924c6b239b44fd9a68af1e823da58ce63 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -33,9 +33,6 @@
 #include "net.h"
 #include "dns.h"
 
-static int havename[MaxHost];
-
-extern int af;
 
 #if 0
 static char *addr_to_str(ip_t addr)
@@ -57,6 +54,7 @@ extern void raw_rawxmit (int host, int seq)
 // Log an echo reply, or a "pong"
 extern void raw_rawping (int host, int msec, int seq)
 {
+  static int havename[MaxHost];
   char *name;
 
   if (dns && !havename[host]) {