From f1a9a40c90b2439e43c3e0d82a17efccdeca5f5e Mon Sep 17 00:00:00 2001 From: thorkill Date: Thu, 2 Jul 2015 18:37:08 +0200 Subject: [PATCH] Marked all unsued parameters found by -Werror=unused-parameter with UNUSED() --- src/dummy_device.c | 2 ++ src/ed25519/ecdsa.c | 1 + src/event.c | 2 ++ src/fsck.c | 4 ++-- src/info.c | 2 ++ src/invitation.c | 4 ++++ src/logger.c | 3 ++- src/meta.c | 1 + src/net_packet.c | 3 +++ src/net_socket.c | 2 ++ src/openssl/rsagen.c | 1 + src/protocol.c | 1 + src/protocol_auth.c | 1 + src/protocol_key.c | 2 ++ src/protocol_misc.c | 2 ++ src/route.c | 1 + src/sptps.c | 8 ++++++++ src/sptps_keypair.c | 4 +++- src/sptps_speed.c | 5 +++++ src/sptps_test.c | 3 ++- src/tincctl.c | 22 ++++++++++++++++++++-- 21 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/dummy_device.c b/src/dummy_device.c index c43d5862..1066c95a 100644 --- a/src/dummy_device.c +++ b/src/dummy_device.c @@ -36,10 +36,12 @@ static void close_device(void) { } static bool read_packet(vpn_packet_t *packet) { + UNUSED(packet); return false; } static bool write_packet(vpn_packet_t *packet) { + UNUSED(packet); return true; } diff --git a/src/ed25519/ecdsa.c b/src/ed25519/ecdsa.c index f8aafe46..78de81cd 100644 --- a/src/ed25519/ecdsa.c +++ b/src/ed25519/ecdsa.c @@ -129,6 +129,7 @@ ecdsa_t *ecdsa_read_pem_private_key(FILE *fp) { } size_t ecdsa_size(ecdsa_t *ecdsa) { + UNUSED(ecdsa); return 64; } diff --git a/src/event.c b/src/event.c index 5f30b548..84794fb9 100644 --- a/src/event.c +++ b/src/event.c @@ -190,6 +190,8 @@ static void signal_handler(int signum) { static void signalio_handler(void *data, int flags) { unsigned char signum; + UNUSED(data); + UNUSED(flags); if(read(pipefd[0], &signum, 1) != 1) return; diff --git a/src/fsck.c b/src/fsck.c index 205a599c..d92d815a 100644 --- a/src/fsck.c +++ b/src/fsck.c @@ -74,6 +74,7 @@ static int strtailcmp(const char *str, const char *tail) { static void check_conffile(const char *fname, bool server) { FILE *f = fopen(fname, "r"); + UNUSED(server); if(!f) { fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno)); return; @@ -468,7 +469,7 @@ int fsck(const char *argv0) { } } closedir(dir); - + // Check for obsolete / unsafe / unknown configuration variables. check_conffile(tinc_conf, true); @@ -487,4 +488,3 @@ int fsck(const char *argv0) { return 0; } - diff --git a/src/info.c b/src/info.c index fea8a4d2..47582282 100644 --- a/src/info.c +++ b/src/info.c @@ -29,6 +29,8 @@ #include "logger.h" void logger(int level, int priority, const char *format, ...) { + UNUSED(level); + UNUSED(priority); va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); diff --git a/src/invitation.c b/src/invitation.c index 9f73fd64..fa67bd29 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -776,6 +776,8 @@ ask_netname: static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) { + UNUSED(handle); + UNUSED(type); while(len) { int result = send(sock, data, len, 0); if(result == -1 && errno == EINTR) @@ -789,6 +791,8 @@ static bool invitation_send(void *handle, uint8_t type, const void *data, size_t } static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint16_t len) { + UNUSED(handle); + UNUSED(type); switch(type) { case SPTPS_HANDSHAKE: return sptps_send_record(&sptps, 0, cookie, sizeof cookie); diff --git a/src/logger.c b/src/logger.c index e46d926f..b4cf0dcd 100644 --- a/src/logger.c +++ b/src/logger.c @@ -131,7 +131,8 @@ static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap // but both types have the name and hostname fields at the same offsets. connection_t *c = s->handle; if(c) - snprintf(message + len, sizeof message - len, " from %s (%s)", c->name, c->hostname); + snprintf(message + len, sizeof message - len, + " from %s (%s) [errno: %d]", c->name, c->hostname, s_errno); } real_logger(DEBUG_ALWAYS, LOG_ERR, message); diff --git a/src/meta.c b/src/meta.c index 95a61d5c..e53903b9 100644 --- a/src/meta.c +++ b/src/meta.c @@ -36,6 +36,7 @@ bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) { connection_t *c = handle; + UNUSED(type); if(!c) { logger(DEBUG_ALWAYS, LOG_ERR, "send_meta_sptps() called with NULL pointer!"); diff --git a/src/net_packet.c b/src/net_packet.c index a6cb893b..ab9c06ca 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1401,6 +1401,7 @@ void handle_incoming_vpn_data(void *data, int flags) { socklen_t addrlen = sizeof addr; node_t *from, *to; bool direct = false; + UNUSED(flags); pkt.offset = 0; int len = recvfrom(ls->udp.fd, DATA(&pkt), MAXSIZE, 0, &addr.sa, &addrlen); @@ -1515,6 +1516,8 @@ skip_harder: void handle_device_data(void *data, int flags) { vpn_packet_t packet; + UNUSED(data); + UNUSED(flags); packet.offset = DEFAULT_PACKET_OFFSET; packet.priority = 0; diff --git a/src/net_socket.c b/src/net_socket.c index 8acd4b45..ac90d8af 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -635,6 +635,7 @@ void handle_new_meta_connection(void *data, int flags) { sockaddr_t sa; int fd; socklen_t len = sizeof sa; + UNUSED(flags); fd = accept(l->tcp.fd, &sa.sa, &len); @@ -732,6 +733,7 @@ void handle_new_unix_connection(void *data, int flags) { sockaddr_t sa; int fd; socklen_t len = sizeof sa; + UNUSED(flags); fd = accept(io->fd, &sa.sa, &len); diff --git a/src/openssl/rsagen.c b/src/openssl/rsagen.c index 3a8c8ad2..a7e06656 100644 --- a/src/openssl/rsagen.c +++ b/src/openssl/rsagen.c @@ -31,6 +31,7 @@ typedef RSA rsa_t; /* This function prettyprints the key generation process */ static void indicator(int a, int b, void *p) { + UNUSED(p); switch (a) { case 0: fprintf(stderr, "."); diff --git a/src/protocol.c b/src/protocol.c index e5febc21..ce9b79aa 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -163,6 +163,7 @@ static timeout_t past_request_timeout; static void age_past_requests(void *data) { int left = 0, deleted = 0; + UNUSED(data); for splay_each(past_request_t, p, past_request_tree) { if(p->firstseen + pinginterval <= now.tv_sec) diff --git a/src/protocol_auth.c b/src/protocol_auth.c index d30d9e08..341a5eb7 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -155,6 +155,7 @@ bool send_id(connection_t *c) { } static bool finalize_invitation(connection_t *c, const char *data, uint16_t len) { + UNUSED(len); if(strchr(data, '\n')) { logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname); return false; diff --git a/src/protocol_key.c b/src/protocol_key.c index 2032a6e7..949b6f2a 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -95,6 +95,7 @@ static bool send_sptps_data_myself(void *handle, uint8_t type, const void *data, static bool send_initial_sptps_data(void *handle, uint8_t type, const void *data, size_t len) { node_t *to = handle; + UNUSED(type); to->sptps.send_data = send_sptps_data_myself; char buf[len * 4 / 3 + 5]; b64encode(data, buf, len); @@ -125,6 +126,7 @@ bool send_req_key(node_t *to) { /* REQ_KEY is overloaded to allow arbitrary requests to be routed between two nodes. */ static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, node_t *to, int reqno) { + UNUSED(c); /* If this is a SPTPS packet, see if sending UDP info helps. Note that we only do this if we're the destination or the static relay; otherwise every hop would initiate its own UDP info message, resulting in elevated chatter. */ diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 3b008332..b2695436 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -91,6 +91,8 @@ bool send_termreq(connection_t *c) { } bool termreq_h(connection_t *c, const char *request) { + UNUSED(c); + UNUSED(request); return false; } diff --git a/src/route.c b/src/route.c index bb30b302..4ac14224 100644 --- a/src/route.c +++ b/src/route.c @@ -193,6 +193,7 @@ static void swap_mac_addresses(vpn_packet_t *packet) { static void age_subnets(void *data) { bool left = false; + UNUSED(data); for splay_each(subnet_t, s, myself->subnet_tree) { if(s->expires && s->expires < now.tv_sec) { diff --git a/src/sptps.c b/src/sptps.c index d26c5827..16850afe 100644 --- a/src/sptps.c +++ b/src/sptps.c @@ -52,9 +52,16 @@ unsigned int sptps_replaywin = 16; */ void sptps_log_quiet(sptps_t *s, int s_errno, const char *format, va_list ap) { + UNUSED(s); + UNUSED(s_errno); + UNUSED(format); + UNUSED(ap); } void sptps_log_stderr(sptps_t *s, int s_errno, const char *format, va_list ap) { + UNUSED(s); + UNUSED(s_errno); + vfprintf(stderr, format, ap); fputc('\n', stderr); } @@ -230,6 +237,7 @@ static bool send_ack(sptps_t *s) { // Receive an ACKnowledgement record. static bool receive_ack(sptps_t *s, const char *data, uint16_t len) { + UNUSED(data); if(len) return error(s, EIO, "Invalid ACK record length"); diff --git a/src/sptps_keypair.c b/src/sptps_keypair.c index 9e4cedc6..4df8e05e 100644 --- a/src/sptps_keypair.c +++ b/src/sptps_keypair.c @@ -30,6 +30,8 @@ static char *program_name; void logger(int level, int priority, const char *format, ...) { va_list ap; + UNUSED(level); + UNUSED(priority); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); @@ -86,7 +88,7 @@ int main(int argc, char *argv[]) { ecdsa_t *key = ecdsa_generate(); if(!key) return 1; - + FILE *fp = fopen(argv[1], "w"); if(fp) { if(!ecdsa_write_pem_private_key(key, fp)) { diff --git a/src/sptps_speed.c b/src/sptps_speed.c index 47a50fa9..ef4103e7 100644 --- a/src/sptps_speed.c +++ b/src/sptps_speed.c @@ -30,11 +30,16 @@ static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { int fd = *(int *)handle; + UNUSED(type); send(fd, data, len, 0); return true; } static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { + UNUSED(handle); + UNUSED(type); + UNUSED(data); + UNUSED(len); return true; } diff --git a/src/sptps_test.c b/src/sptps_test.c index 2823400f..f71d73cd 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -30,7 +30,6 @@ #include "sptps.h" #include "utils.h" - static bool verbose; static bool readonly; static bool writeonly; @@ -39,6 +38,7 @@ static int out = 1; static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { char hex[len * 2 + 1]; + UNUSED(type); bin2hex(data, hex, len); if(verbose) fprintf(stderr, "Sending %d bytes of data:\n%s\n", (int)len, hex); @@ -49,6 +49,7 @@ static bool send_data(void *handle, uint8_t type, const void *data, size_t len) } static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { + UNUSED(handle); if(verbose) fprintf(stderr, "Received type %d record of %hu bytes:\n", type, len); if(!writeonly) diff --git a/src/tincctl.c b/src/tincctl.c index 36c407f8..cdcf8388 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -924,6 +924,7 @@ static int cmd_start(int argc, char *argv[]) { } static int cmd_stop(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -967,6 +968,7 @@ static int cmd_restart(int argc, char *argv[]) { } static int cmd_reload(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -1209,6 +1211,7 @@ static int cmd_dump(int argc, char *argv[]) { } static int cmd_purge(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -1249,6 +1252,7 @@ static int cmd_debug(int argc, char *argv[]) { } static int cmd_retry(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -1313,6 +1317,7 @@ static int cmd_disconnect(int argc, char *argv[]) { } static int cmd_top(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -1345,6 +1350,7 @@ static int cmd_pcap(int argc, char *argv[]) { #ifdef SIGINT static void sigint_handler(int sig) { + UNUSED(sig); fprintf(stderr, "\n"); shutdown(fd, SHUT_RDWR); } @@ -1375,6 +1381,7 @@ static int cmd_log(int argc, char *argv[]) { } static int cmd_pid(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -1991,6 +1998,7 @@ static int cmd_generate_rsa_keys(int argc, char *argv[]) { #endif static int cmd_generate_ed25519_keys(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2003,11 +2011,14 @@ static int cmd_generate_ed25519_keys(int argc, char *argv[]) { } static int cmd_help(int argc, char *argv[]) { + UNUSED(argc); + UNUSED(argv); usage(false); return 0; } static int cmd_version(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2116,6 +2127,7 @@ static int export(const char *name, FILE *out) { } static int cmd_export(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2134,6 +2146,7 @@ static int cmd_export(int argc, char *argv[]) { } static int cmd_export_all(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2168,6 +2181,7 @@ static int cmd_export_all(int argc, char *argv[]) { } static int cmd_import(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2287,8 +2301,8 @@ static int cmd_network(int argc, char *argv[]) { DIR *dir = opendir(confdir); if(!dir) { fprintf(stderr, "Could not read directory %s: %s\n", confdir, strerror(errno)); - return 1; - } + return 1; + } struct dirent *ent; while((ent = readdir(dir))) { @@ -2312,6 +2326,7 @@ static int cmd_network(int argc, char *argv[]) { } static int cmd_fsck(int argc, char *argv[]) { + UNUSED(argv); if(argc > 1) { fprintf(stderr, "Too many arguments!\n"); return 1; @@ -2464,11 +2479,14 @@ static char *complete_info(const char *text, int state) { } static char *complete_nothing(const char *text, int state) { + UNUSED(text); + UNUSED(state); return NULL; } static char **completion (const char *text, int start, int end) { char **matches = NULL; + UNUSED(end); if(!start) matches = rl_completion_matches(text, complete_command);