]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
cleanup: move file scope variables to the beginning of file
authorSami Kerola <kerolasa@iki.fi>
Sun, 9 Oct 2016 10:27:07 +0000 (11:27 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
Writing file scope global variables in between function somewhere half way
down feels like an attempt to hide these variables.  This commit moves such
variables to beginning of file before functions.  From technical point of
view the change is unnecessary, but hope is to help to read the code.

curses.c
dns.c

index f1935eb228fd864153267149edaabe6bf4ffa1e6..cba17bd5288adfe4b609d1e2be3104a4d658bd32 100644 (file)
--- a/curses.c
+++ b/curses.c
 
 #include <time.h>
 
+enum { NUM_FACTORS = 8 };
+static double factors[NUM_FACTORS];
+static int scale[NUM_FACTORS];
+static char block_map[NUM_FACTORS];
+
+enum { black = 1, red, green, yellow, blue, magenta, cyan, white };
+static const int block_col[NUM_FACTORS + 1] = {
+  COLOR_PAIR(red) | A_BOLD,
+  A_NORMAL,
+  COLOR_PAIR(green),
+  COLOR_PAIR(green) | A_BOLD,
+  COLOR_PAIR(yellow) | A_BOLD,
+  COLOR_PAIR(magenta) | A_BOLD,
+  COLOR_PAIR(magenta),
+  COLOR_PAIR(red),
+  COLOR_PAIR(red) | A_BOLD
+};
 
 static void pwcenter(char *str) 
 {
@@ -452,10 +469,6 @@ static void mtr_curses_hosts(struct mtr_ctl *ctl, int startstat)
   move(2, 0);
 }
 
-#define NUM_FACTORS 8
-static double factors[NUM_FACTORS];
-static int scale[NUM_FACTORS];
-
 static void mtr_gen_scale(struct mtr_ctl *ctl)
 {
        int *saved, i, max, at;
@@ -487,9 +500,6 @@ static void mtr_gen_scale(struct mtr_ctl *ctl)
        }
 }
 
-
-static char block_map[NUM_FACTORS];
-
 static void mtr_curses_init(void) {
        int i;
        int block_split;
@@ -512,19 +522,6 @@ static void mtr_curses_init(void) {
        block_map[NUM_FACTORS-1] = '>';
 }
 
-enum { black = 1, red, green, yellow, blue, magenta, cyan, white };
-static const int block_col[NUM_FACTORS + 1] = {
-        COLOR_PAIR(red)|A_BOLD,
-       A_NORMAL,
-       COLOR_PAIR(green),
-       COLOR_PAIR(green)|A_BOLD,
-       COLOR_PAIR(yellow)|A_BOLD,
-       COLOR_PAIR(magenta)|A_BOLD,
-       COLOR_PAIR(magenta),
-       COLOR_PAIR(red),
-       COLOR_PAIR(red)|A_BOLD
-};
-
 static void mtr_print_scaled(int ms) 
 {
        int i;
@@ -721,7 +718,7 @@ extern void mtr_curses_open(struct mtr_ctl *ctl)
   if (use_default_colors() == OK)
     bg_col = -1;
 #endif
-  for (i = 0; i < 8; i++)
+  for (i = 0; i < NUM_FACTORS; i++)
       init_pair(i+1, i, bg_col);
 
   mtr_curses_init();
diff --git a/dns.c b/dns.c
index 750aeebbca6f30670a6f2ccb9fd03e05d0ac4a16..88228783f4b0702a979390316d7d9c68ca381ea9 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -68,6 +68,9 @@ extern char *strlongip(struct mtr_ctl *ctl, ip_t * ip)
 # define UNUSED_IF_NO_IPV6 ATTRIBUTE_UNUSED
 #endif
 
+static int todns[2], fromdns[2];
+static FILE *fromdnsfp;
+
 static int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6)
 {
 #ifdef ENABLE_IPV6
@@ -121,10 +124,6 @@ static void set_sockaddr_ip (struct mtr_ctl *ctl, struct sockaddr_storage *sa, i
   }
 }
 
-
-static int todns[2], fromdns[2];
-FILE *fromdnsfp;
-
 extern void dns_open(struct mtr_ctl *ctl)
 {
   int pid;