From: Sami Kerola Date: Sun, 1 Jan 2017 19:19:22 +0000 (+0000) Subject: smatch: extern keyword is needed only in header X-Git-Tag: v0.88~9^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c7ad75699f567c401cf0de441c443a55b9a4b8c;p=thirdparty%2Fmtr.git smatch: extern keyword is needed only in header Signed-off-by: Sami Kerola --- diff --git a/ui/asn.c b/ui/asn.c index 4239ad0..c38034b 100644 --- a/ui/asn.c +++ b/ui/asn.c @@ -256,11 +256,11 @@ static char *get_ipinfo(struct mtr_ctl *ctl, ip_t *addr){ return val; } -extern ATTRIBUTE_CONST size_t get_iiwidth_len(void) { +ATTRIBUTE_CONST size_t get_iiwidth_len(void) { return (sizeof(iiwidth) / sizeof((iiwidth)[0])); } -extern ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) { +ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) { static const int len = (sizeof(iiwidth) / sizeof((iiwidth)[0])); if (ipinfo_no < len) @@ -268,7 +268,7 @@ extern ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) { return iiwidth[ipinfo_no % len]; } -extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){ +char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){ char *ipinfo = get_ipinfo(ctl, addr); char fmt[8]; snprintf(fmt, sizeof(fmt), "%s%%-%ds", ctl->ipinfo_no?"":"AS", get_iiwidth(ctl->ipinfo_no)); @@ -276,11 +276,11 @@ extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){ return fmtinfo; } -extern int is_printii(struct mtr_ctl *ctl) { +int is_printii(struct mtr_ctl *ctl) { return ((ctl->ipinfo_no >= 0) && (ctl->ipinfo_no != ctl->ipinfo_max)); } -extern void asn_open(struct mtr_ctl *ctl) { +void asn_open(struct mtr_ctl *ctl) { if (ctl->ipinfo_no >= 0) { DEB_syslog(LOG_INFO, "hcreate(%d)", IIHASH_HI); if (!(iihash = hcreate(IIHASH_HI))) @@ -288,7 +288,7 @@ extern void asn_open(struct mtr_ctl *ctl) { } } -extern void asn_close(struct mtr_ctl *ctl) { +void asn_close(struct mtr_ctl *ctl) { if ((ctl->ipinfo_no >= 0) && iihash) { DEB_syslog(LOG_INFO, "hdestroy()"); hdestroy(); diff --git a/ui/curses.c b/ui/curses.c index 214f27d..0ec2e56 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -117,7 +117,7 @@ static char *format_number (int n, int w, char *buf) } -extern int mtr_curses_keyaction(struct mtr_ctl *ctl) +int mtr_curses_keyaction(struct mtr_ctl *ctl) { int c = getch(); int i = 0; @@ -608,7 +608,7 @@ static void mtr_curses_graph(struct mtr_ctl *ctl, int startstat, int cols) } -extern void mtr_curses_redraw(struct mtr_ctl *ctl) +void mtr_curses_redraw(struct mtr_ctl *ctl) { int maxx; int startstat; @@ -707,7 +707,7 @@ extern void mtr_curses_redraw(struct mtr_ctl *ctl) } -extern void mtr_curses_open(struct mtr_ctl *ctl) +void mtr_curses_open(struct mtr_ctl *ctl) { int bg_col = 0; int i; @@ -726,14 +726,14 @@ extern void mtr_curses_open(struct mtr_ctl *ctl) } -extern void mtr_curses_close(void) +void mtr_curses_close(void) { printw("\n"); endwin(); } -extern void mtr_curses_clear(struct mtr_ctl *ctl) +void mtr_curses_clear(struct mtr_ctl *ctl) { mtr_curses_close(); mtr_curses_open(ctl); diff --git a/ui/display.c b/ui/display.c index 58ba2c0..00fa5d5 100644 --- a/ui/display.c +++ b/ui/display.c @@ -53,7 +53,7 @@ # define UNUSED_IF_NO_GTK ATTRIBUTE_UNUSED #endif -extern void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK, +void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK, char ***argv UNUSED_IF_NO_GTK) { ctl->DisplayMode = DEFAULT_DISPLAY; @@ -66,7 +66,7 @@ extern void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK, } -extern void display_open(struct mtr_ctl *ctl) +void display_open(struct mtr_ctl *ctl) { switch(ctl->DisplayMode) { @@ -108,7 +108,7 @@ extern void display_open(struct mtr_ctl *ctl) } -extern void display_close(struct mtr_ctl *ctl) +void display_close(struct mtr_ctl *ctl) { time_t now; @@ -150,7 +150,7 @@ extern void display_close(struct mtr_ctl *ctl) } -extern void display_redraw(struct mtr_ctl *ctl) +void display_redraw(struct mtr_ctl *ctl) { switch(ctl->DisplayMode) { @@ -173,7 +173,7 @@ extern void display_redraw(struct mtr_ctl *ctl) } -extern int display_keyaction(struct mtr_ctl *ctl) +int display_keyaction(struct mtr_ctl *ctl) { switch(ctl->DisplayMode) { #ifdef HAVE_CURSES @@ -193,28 +193,28 @@ extern int display_keyaction(struct mtr_ctl *ctl) } -extern void display_rawxmit(struct mtr_ctl *ctl, int host, int seq) +void display_rawxmit(struct mtr_ctl *ctl, int host, int seq) { if (ctl->DisplayMode == DisplayRaw) raw_rawxmit (host, seq); } -extern void display_rawping(struct mtr_ctl *ctl, int host, int msec, int seq) +void display_rawping(struct mtr_ctl *ctl, int host, int msec, int seq) { if (ctl->DisplayMode == DisplayRaw) raw_rawping (ctl, host, msec, seq); } -extern void display_rawhost(struct mtr_ctl *ctl, int host, ip_t *ip_addr) +void display_rawhost(struct mtr_ctl *ctl, int host, ip_t *ip_addr) { if (ctl->DisplayMode == DisplayRaw) raw_rawhost (ctl, host, ip_addr); } -extern void display_loop(struct mtr_ctl *ctl) +void display_loop(struct mtr_ctl *ctl) { #ifdef HAVE_GTK if (ctl->DisplayMode == DisplayGTK) @@ -225,7 +225,7 @@ extern void display_loop(struct mtr_ctl *ctl) } -extern void display_clear(struct mtr_ctl *ctl) +void display_clear(struct mtr_ctl *ctl) { #ifdef HAVE_CURSES if (ctl->DisplayMode == DisplayCurses) diff --git a/ui/dns.c b/ui/dns.c index 7e976cf..df0e8c3 100644 --- a/ui/dns.c +++ b/ui/dns.c @@ -48,9 +48,9 @@ struct dns_results { struct dns_results *next; }; -struct dns_results *results; +static struct dns_results *results; -extern char *strlongip(struct mtr_ctl *ctl, ip_t * ip) +char *strlongip(struct mtr_ctl *ctl, ip_t * ip) { #ifdef ENABLE_IPV6 static char addrstr[INET6_ADDRSTRLEN]; @@ -81,7 +81,7 @@ static int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6) } -extern struct hostent * dns_forward(const char *name) +struct hostent * dns_forward(const char *name) { struct hostent *host; @@ -124,7 +124,7 @@ static void set_sockaddr_ip (struct mtr_ctl *ctl, struct sockaddr_storage *sa, i } } -extern void dns_open(struct mtr_ctl *ctl) +void dns_open(struct mtr_ctl *ctl) { int pid; @@ -205,13 +205,13 @@ extern void dns_open(struct mtr_ctl *ctl) } } -extern int dns_waitfd (void) +int dns_waitfd (void) { return fromdns[0]; } -extern void dns_ack(struct mtr_ctl *ctl) +void dns_ack(struct mtr_ctl *ctl) { char buf[2048], host[NI_MAXHOST], name[NI_MAXHOST]; ip_t hostip; @@ -233,12 +233,12 @@ extern void dns_ack(struct mtr_ctl *ctl) #ifdef ENABLE_IPV6 -extern int dns_waitfd6 (void) +int dns_waitfd6 (void) { return -1; } -extern void dns_ack6(void) +void dns_ack6(void) { return; } @@ -246,7 +246,7 @@ extern void dns_ack6(void) #endif -extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip) +char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip) { struct dns_results *r; char buf[INET6_ADDRSTRLEN + 1]; @@ -274,7 +274,7 @@ extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip) } -extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip) +char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip) { char *t; @@ -287,7 +287,7 @@ extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip) /* XXX check if necessary/exported. */ /* Resolve an IP address to a hostname. */ -extern struct hostent *addr2host( const char *addr, int family ) { +struct hostent *addr2host( const char *addr, int family ) { int len = 0; switch ( family ) { case AF_INET: diff --git a/ui/gtk.c b/ui/gtk.c index 97ab0a3..c84ef36 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -76,7 +76,7 @@ static void gtk_do_init(int *argc, char ***argv) } -extern int gtk_detect(ATTRIBUTE_UNUSED int *argc, ATTRIBUTE_UNUSED char ***argv) +int gtk_detect(ATTRIBUTE_UNUSED int *argc, ATTRIBUTE_UNUSED char ***argv) { if(getenv("DISPLAY") != NULL) { /* If we do this here, gtk_init exits on an error. This happens @@ -504,7 +504,7 @@ static void update_tree_row(struct mtr_ctl *ctl, int row, GtkTreeIter *iter) #endif } -extern void gtk_redraw(struct mtr_ctl *ctl) +void gtk_redraw(struct mtr_ctl *ctl) { int max = net_max(ctl); @@ -555,7 +555,7 @@ static void Window_fill(struct mtr_ctl *ctl, GtkWidget *Window) } -extern void gtk_open(struct mtr_ctl *ctl) +void gtk_open(struct mtr_ctl *ctl) { GdkPixbuf *icon; int argc = 1; @@ -586,12 +586,12 @@ extern void gtk_open(struct mtr_ctl *ctl) } -extern void gtk_close(void) +void gtk_close(void) { } -extern int gtk_keyaction(void) +int gtk_keyaction(void) { return 0; } @@ -642,7 +642,7 @@ static gboolean gtk_dns_data6(ATTRIBUTE_UNUSED GIOChannel *channel, #endif -extern void gtk_loop(struct mtr_ctl *ctl) +void gtk_loop(struct mtr_ctl *ctl) { GIOChannel *net_iochannel, *dns_iochannel; diff --git a/ui/mtr.c b/ui/mtr.c index c9f48b4..c635aec 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -617,7 +617,7 @@ static void init_rand(void) srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); } -extern int main(int argc, char **argv) +int main(int argc, char **argv) { struct hostent * host = NULL; struct addrinfo hints, *res; diff --git a/ui/net.c b/ui/net.c index e49de8e..bf64d5f 100644 --- a/ui/net.c +++ b/ui/net.c @@ -114,7 +114,7 @@ static int numhosts = 10; /* return the number of microseconds to wait before sending the next ping */ -extern int calc_deltatime (float waittime) +int calc_deltatime (float waittime) { waittime /= numhosts; return 1000000 * waittime; @@ -262,79 +262,79 @@ static void net_process_ping( Invoked when the read pipe from the mtr-packet subprocess is readable. If we have received a complete reply, process it. */ -extern void net_process_return(struct mtr_ctl *ctl) +void net_process_return(struct mtr_ctl *ctl) { handle_command_replies(ctl, &packet_command_pipe, net_process_ping); } -extern ip_t *net_addr(int at) +ip_t *net_addr(int at) { return (ip_t *)&(host[at].addr); } -extern ip_t *net_addrs(int at, int i) +ip_t *net_addrs(int at, int i) { return (ip_t *)&(host[at].addrs[i]); } -extern void *net_mpls(int at) +void *net_mpls(int at) { return (struct mplslen *)&(host[at].mplss); } -extern void *net_mplss(int at, int i) +void *net_mplss(int at, int i) { return (struct mplslen *)&(host[at].mplss[i]); } -extern int net_loss(int at) +int net_loss(int at) { - if ((host[at].xmit - host[at].transit) == 0) + if ((host[at].xmit - host[at].transit) == 0) return 0; /* times extra 1000 */ return 1000*(100 - (100.0 * host[at].returned / (host[at].xmit - host[at].transit)) ); } -extern int net_drop(int at) +int net_drop(int at) { return (host[at].xmit - host[at].transit) - host[at].returned; } -extern int net_last(int at) +int net_last(int at) { return (host[at].last); } -extern int net_best(int at) +int net_best(int at) { return (host[at].best); } -extern int net_worst(int at) +int net_worst(int at) { return (host[at].worst); } -extern int net_avg(int at) +int net_avg(int at) { return (host[at].avg); } -extern int net_gmean(int at) +int net_gmean(int at) { return (host[at].gmean); } -extern int net_stdev(int at) +int net_stdev(int at) { if( host[at].returned > 1 ) { return ( sqrt( host[at].ssd/(host[at].returned -1.0) ) ); @@ -344,31 +344,31 @@ extern int net_stdev(int at) } -extern int net_jitter(int at) +int net_jitter(int at) { return (host[at].jitter); } -extern int net_jworst(int at) +int net_jworst(int at) { return (host[at].jworst); } -extern int net_javg(int at) +int net_javg(int at) { return (host[at].javg); } -extern int net_jinta(int at) +int net_jinta(int at) { return (host[at].jinta); } -extern int net_max(struct mtr_ctl *ctl) +int net_max(struct mtr_ctl *ctl) { int at; int max; @@ -388,37 +388,37 @@ extern int net_max(struct mtr_ctl *ctl) } -extern int net_min (struct mtr_ctl *ctl) +int net_min (struct mtr_ctl *ctl) { return ( ctl->fstTTL - 1 ); } -extern int net_returned(int at) +int net_returned(int at) { return host[at].returned; } -extern int net_xmit(int at) +int net_xmit(int at) { return host[at].xmit; } -extern int net_up(int at) +int net_up(int at) { return host[at].up; } -extern char * net_localaddr (void) +char * net_localaddr (void) { return localaddr; } -extern void net_end_transit(void) +void net_end_transit(void) { int at; @@ -427,7 +427,7 @@ extern void net_end_transit(void) } } -extern int net_send_batch(struct mtr_ctl *ctl) +int net_send_batch(struct mtr_ctl *ctl) { int n_unknown=0, i; @@ -556,7 +556,7 @@ static void net_find_local_address(void) } -extern int net_open(struct mtr_ctl *ctl, struct hostent * hostent) +int net_open(struct mtr_ctl *ctl, struct hostent * hostent) { int err; @@ -597,7 +597,7 @@ extern int net_open(struct mtr_ctl *ctl, struct hostent * hostent) } -extern void net_reopen(struct mtr_ctl *ctl, struct hostent * addr) +void net_reopen(struct mtr_ctl *ctl, struct hostent * addr) { int at; @@ -626,7 +626,7 @@ extern void net_reopen(struct mtr_ctl *ctl, struct hostent * addr) } -extern void net_reset(struct mtr_ctl *ctl) +void net_reset(struct mtr_ctl *ctl) { static struct nethost template = { .saved_seq_offset = 2 - SAVED_PINGS @@ -652,19 +652,19 @@ extern void net_reset(struct mtr_ctl *ctl) /* Close the pipe to the packet generator process, and kill the process */ -extern void net_close(void) +void net_close(void) { close_command_pipe(&packet_command_pipe); } -extern int net_waitfd(void) +int net_waitfd(void) { return packet_command_pipe.read_fd; } -extern int* net_saved_pings(int at) +int* net_saved_pings(int at) { return host[at].saved; } @@ -681,15 +681,15 @@ static void net_save_increment(void) } -extern void net_save_xmit(int at) +void net_save_xmit(int at) { - if (host[at].saved[SAVED_PINGS-1] != -2) + if (host[at].saved[SAVED_PINGS-1] != -2) net_save_increment(); host[at].saved[SAVED_PINGS-1] = -1; } -extern void net_save_return(int at, int seq, int ms) +void net_save_return(int at, int seq, int ms) { int idx; idx = seq - host[at].saved_seq_offset; @@ -727,7 +727,7 @@ static void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ) { /* Address comparison. */ -extern int addrcmp( char * a, char * b, int family ) { +int addrcmp( char * a, char * b, int family ) { int rc = -1; switch ( family ) { @@ -745,7 +745,7 @@ extern int addrcmp( char * a, char * b, int family ) { } /* Address copy. */ -extern void addrcpy( char * a, char * b, int family ) { +void addrcpy( char * a, char * b, int family ) { switch ( family ) { case AF_INET: @@ -760,7 +760,7 @@ extern void addrcpy( char * a, char * b, int family ) { } /* for GTK frontend */ -extern void net_harvest_fds(struct mtr_ctl *ctl) +void net_harvest_fds(struct mtr_ctl *ctl) { fd_set writefd; int maxfd = 0; diff --git a/ui/raw.c b/ui/raw.c index 89cb2bb..a745cd7 100644 --- a/ui/raw.c +++ b/ui/raw.c @@ -35,14 +35,14 @@ /* Log an echo request, or a "ping" */ -extern void raw_rawxmit (int host, int seq) +void raw_rawxmit (int host, int seq) { printf ("x %d %d\n", host, seq); fflush (stdout); } /* Log an echo reply, or a "pong" */ -extern void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq) +void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq) { static int havename[MaxHost]; char *name; @@ -59,7 +59,7 @@ extern void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq) } -extern void raw_rawhost (struct mtr_ctl *ctl, int host, ip_t * ip_addr) +void raw_rawhost (struct mtr_ctl *ctl, int host, ip_t * ip_addr) { printf ("h %d %s\n", host, strlongip(ctl, ip_addr)); fflush (stdout); diff --git a/ui/report.c b/ui/report.c index b8fbf41..4e85c8f 100644 --- a/ui/report.c +++ b/ui/report.c @@ -38,7 +38,7 @@ #define MAX_FORMAT_STR 81 -extern void report_open(void) +void report_open(void) { const time_t now = time(NULL); const char *t = iso_time (&now); @@ -66,7 +66,7 @@ static void print_mpls(struct mplslen *mpls) { } #endif -extern void report_close(struct mtr_ctl *ctl) +void report_close(struct mtr_ctl *ctl) { int i, j, at, max, z, w; struct mplslen *mpls, *mplss; @@ -233,23 +233,23 @@ extern void report_close(struct mtr_ctl *ctl) } -extern void txt_open(void) +void txt_open(void) { } -extern void txt_close(struct mtr_ctl *ctl) +void txt_close(struct mtr_ctl *ctl) { report_close(ctl); } -extern void json_open(void) +void json_open(void) { } -extern void json_close(struct mtr_ctl *ctl) +void json_close(struct mtr_ctl *ctl) { int i, j, at, first, max; ip_t *addr; @@ -338,12 +338,12 @@ extern void json_close(struct mtr_ctl *ctl) -extern void xml_open(void) +void xml_open(void) { } -extern void xml_close(struct mtr_ctl *ctl) +void xml_close(struct mtr_ctl *ctl) { int i, j, at, max; ip_t *addr; @@ -404,11 +404,11 @@ extern void xml_close(struct mtr_ctl *ctl) } -extern void csv_open(void) +void csv_open(void) { } -extern void csv_close(struct mtr_ctl *ctl, time_t now) +void csv_close(struct mtr_ctl *ctl, time_t now) { int i, j, at, max; ip_t *addr; diff --git a/ui/select.c b/ui/select.c index c9de0fa..6e1431a 100644 --- a/ui/select.c +++ b/ui/select.c @@ -41,7 +41,7 @@ #include "display.h" #include "select.h" -extern void select_loop(struct mtr_ctl *ctl){ +void select_loop(struct mtr_ctl *ctl){ fd_set readfd; fd_set writefd; int anyset = 0; diff --git a/ui/split.c b/ui/split.c index dc4b34e..e75ca9d 100644 --- a/ui/split.c +++ b/ui/split.c @@ -64,7 +64,7 @@ static int LineCount; #define DEBUG 0 -extern void split_redraw(struct mtr_ctl *ctl) +void split_redraw(struct mtr_ctl *ctl) { int max; int at; @@ -126,7 +126,7 @@ extern void split_redraw(struct mtr_ctl *ctl) } -extern void split_open(void) +void split_open(void) { int i; #if DEBUG @@ -139,7 +139,7 @@ extern void split_open(void) } -extern void split_close(void) +void split_close(void) { #if DEBUG printf("split_close()\n"); @@ -147,7 +147,7 @@ extern void split_close(void) } -extern int split_keyaction(void) +int split_keyaction(void) { #ifdef HAVE_CURSES unsigned char c = getch(); diff --git a/ui/utils.c b/ui/utils.c index af12b1e..d8259a8 100644 --- a/ui/utils.c +++ b/ui/utils.c @@ -40,7 +40,7 @@ #include "utils.h" -extern char *trim(char *str, const char c) +char *trim(char *str, const char c) { char *p = str; size_t len; @@ -68,7 +68,7 @@ extern char *trim(char *str, const char c) } /* Parse string, and return positive signed int. */ -extern int strtonum_or_err(const char *str, const char *errmesg, const int type) +int strtonum_or_err(const char *str, const char *errmesg, const int type) { unsigned long int num; char *end = NULL; @@ -93,7 +93,7 @@ extern int strtonum_or_err(const char *str, const char *errmesg, const int type) return 0; } -extern float strtofloat_or_err(const char *str, const char *errmesg) +float strtofloat_or_err(const char *str, const char *errmesg) { double num; char *end = NULL; @@ -112,7 +112,7 @@ extern float strtofloat_or_err(const char *str, const char *errmesg) return 0; } -extern void *xmalloc(const size_t size) +void *xmalloc(const size_t size) { void *ret = malloc(size); @@ -121,7 +121,7 @@ extern void *xmalloc(const size_t size) return ret; } -extern char *xstrdup(const char *str) +char *xstrdup(const char *str) { char *ret; @@ -153,7 +153,7 @@ static inline int close_stream(FILE *stream) return 0; } /* Meant to be used atexit(close_stdout); */ -extern void close_stdout(void) +void close_stdout(void) { if (close_stream(stdout) != 0 && !(errno == EPIPE)) { error(0, errno, "write error"); @@ -165,7 +165,7 @@ extern void close_stdout(void) /* ctime() replacement that will reteturn ISO-8601 timestamp string such as: * 2016-08-29T19:25:02+01:00 */ -extern const char *iso_time(const time_t *t) +const char *iso_time(const time_t *t) { static char s[32]; struct tm *tm;