From: Sami Kerola Date: Sun, 9 Oct 2016 10:02:38 +0000 (+0100) Subject: data types: move variables from a file to a function scope X-Git-Tag: v0.88~21^2^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56fdd6a4c32e88f64bce4d25e2e31fd9325f0fe0;p=thirdparty%2Fmtr.git data types: move variables from a file to a function scope Use of static keyword, that ensures persistent variables within function during different invocations, is the reason why these values can be moved from global scope to a function scope. --- diff --git a/net.c b/net.c index c63424d..a2afb15 100644 --- a/net.c +++ b/net.c @@ -166,11 +166,6 @@ struct sequence { }; -/* BSD-derived kernels use host byte order for the IP length and - offset fields when using raw sockets. We detect this automatically at - run-time and do the right thing. */ -static int BSDfix = 0; - static struct nethost host[MaxHost]; static struct sequence sequence[MaxSequence]; @@ -566,6 +561,10 @@ static void net_send_query(struct mtr_ctl *ctl, int index) /* offset for ipv6 checksum calculation */ int offset = 6; #endif + /* BSD-derived kernels use host byte order for the IP length and offset + fields when using raw sockets. We detect this automatically at + run-time and do the right thing. */ + static int BSDfix = 0; if (ctl->mtrtype == IPPROTO_TCP) { net_send_tcp(ctl, index); diff --git a/select.c b/select.c index 9a243e6..6a2b9fa 100644 --- a/select.c +++ b/select.c @@ -41,9 +41,6 @@ #include "display.h" #include "select.h" -static double dnsinterval; -static struct timeval intervaltime; - extern void select_loop(struct mtr_ctl *ctl){ fd_set readfd; fd_set writefd; @@ -60,6 +57,8 @@ extern void select_loop(struct mtr_ctl *ctl){ int dt; int rv; int graceperiod = 0; + struct timeval intervaltime; + static double dnsinterval = 0; memset(&startgrace, 0, sizeof(startgrace));