]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
data types: move variables from a file to a function scope
authorSami Kerola <kerolasa@iki.fi>
Sun, 9 Oct 2016 10:02:38 +0000 (11:02 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
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.

net.c
select.c

diff --git a/net.c b/net.c
index c63424d6a593e94ea6e527d8ebd56c1c9a1e3742..a2afb158f47f15cf27ef8b1fdd714aeca08bc1ab 100644 (file)
--- 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);
index 9a243e6fef0ab0b5f051d05a5733ebe1cd8e473b..6a2b9fa7c883412be47f18899a2132fb84461406 100644 (file)
--- 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));