From: Sami Kerola Date: Sat, 27 Aug 2016 09:51:20 +0000 (+0100) Subject: data types: get rid of all globals that are easy to remove X-Git-Tag: v0.88~26^2~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43fc06cd1f9505dc3741bb3a732e1a2d47ff822f;p=thirdparty%2Fmtr.git data types: get rid of all globals that are easy to remove Some variables are unnecessary, others can be moved to a function or a file scope. --- diff --git a/asn.c b/asn.c index f456ba8..90252dd 100644 --- 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 b9d0c09..2987b2c 100644 --- 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); diff --git a/curses.c b/curses.c index eaf19f5..ee00875 100644 --- 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 bc6d4bc..dd2ad4e 100644 --- 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 ed190de..093fc7b 100644 --- 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]) {