From: Sami Kerola Date: Sun, 9 Oct 2016 10:27:07 +0000 (+0100) Subject: cleanup: move file scope variables to the beginning of file X-Git-Tag: v0.88~21^2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d17bcac20b88250184cd44c9c83752f732d7bd8;p=thirdparty%2Fmtr.git cleanup: move file scope variables to the beginning of file 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. --- diff --git a/curses.c b/curses.c index f1935eb..cba17bd 100644 --- a/curses.c +++ b/curses.c @@ -66,6 +66,23 @@ #include +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 750aeeb..8822878 100644 --- 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;