diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2016-07-19 15:13:37 +0100 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2016-07-19 15:13:37 +0100 |
commit | a7094cffbcbd14fdba7d0ab6e0c7057a8857a674 (patch) | |
tree | 923f90f104ff8860410cf5ae9e9c73e11f5a4344 | |
parent | f8147b9736d4385c02b5f27b497c90806a9e9d96 (diff) |
Make tun_fd variable static
tun functions use global state in tun.c anyway.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r-- | latency.c | 4 | ||||
-rw-r--r-- | tun.c | 10 | ||||
-rw-r--r-- | tun.h | 6 |
3 files changed, 9 insertions, 11 deletions
@@ -92,7 +92,7 @@ main(int argc, char **argv) setuid(0); } - tun_fd = tun_setup(); + tun_setup(); if (ruid != euid) setuid(ruid); @@ -105,6 +105,6 @@ main(int argc, char **argv) setup_signals(); - handle_tun(tun_fd); + handle_tun(); return EXIT_SUCCESS; } @@ -20,7 +20,7 @@ #include "latency.h" #include "utils.h" -int tun_fd = -1; +static int tun_fd = -1; /** * @param dev name of interface. MUST have enough @@ -52,7 +52,7 @@ static int tun_alloc(char *dev, int flags) return fd; } -int tun_setup(void) +void tun_setup(void) { char tun_name[IFNAMSIZ]; int fd; @@ -79,7 +79,7 @@ int tun_setup(void) setpriority(PRIO_PROCESS, 0, -20); - return fd; + tun_fd = fd; } #define MIN_PKT_LEN 2000u @@ -216,7 +216,7 @@ bytes2time(int64_t bytes) } void -handle_tun(int fd) +handle_tun(void) { packet_t *pkt; pthread_t writer; @@ -233,7 +233,7 @@ handle_tun(int fd) uint32_t num_packets = 0; while (!term && (pkt = alloc_packet())) { - int len = read(fd, pkt->data, MIN_PKT_LEN); + int len = read(tun_fd, pkt->data, MIN_PKT_LEN); if (len < 0) break; @@ -1,5 +1,3 @@ -extern int tun_fd; +void tun_setup(void); -int tun_setup(void); - -void handle_tun(int tun_fd); +void handle_tun(void); |