Marked all unsued parameters found by -Werror=unused-parameter with UNUSED()

This commit is contained in:
thorkill 2015-07-02 18:37:08 +02:00
parent 1391b2d7dc
commit f1a9a40c90
21 changed files with 67 additions and 7 deletions

View file

@ -36,10 +36,12 @@ static void close_device(void) {
} }
static bool read_packet(vpn_packet_t *packet) { static bool read_packet(vpn_packet_t *packet) {
UNUSED(packet);
return false; return false;
} }
static bool write_packet(vpn_packet_t *packet) { static bool write_packet(vpn_packet_t *packet) {
UNUSED(packet);
return true; return true;
} }

View file

@ -129,6 +129,7 @@ ecdsa_t *ecdsa_read_pem_private_key(FILE *fp) {
} }
size_t ecdsa_size(ecdsa_t *ecdsa) { size_t ecdsa_size(ecdsa_t *ecdsa) {
UNUSED(ecdsa);
return 64; return 64;
} }

View file

@ -190,6 +190,8 @@ static void signal_handler(int signum) {
static void signalio_handler(void *data, int flags) { static void signalio_handler(void *data, int flags) {
unsigned char signum; unsigned char signum;
UNUSED(data);
UNUSED(flags);
if(read(pipefd[0], &signum, 1) != 1) if(read(pipefd[0], &signum, 1) != 1)
return; return;

View file

@ -74,6 +74,7 @@ static int strtailcmp(const char *str, const char *tail) {
static void check_conffile(const char *fname, bool server) { static void check_conffile(const char *fname, bool server) {
FILE *f = fopen(fname, "r"); FILE *f = fopen(fname, "r");
UNUSED(server);
if(!f) { if(!f) {
fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno)); fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno));
return; return;
@ -468,7 +469,7 @@ int fsck(const char *argv0) {
} }
} }
closedir(dir); closedir(dir);
// Check for obsolete / unsafe / unknown configuration variables. // Check for obsolete / unsafe / unknown configuration variables.
check_conffile(tinc_conf, true); check_conffile(tinc_conf, true);
@ -487,4 +488,3 @@ int fsck(const char *argv0) {
return 0; return 0;
} }

View file

@ -29,6 +29,8 @@
#include "logger.h" #include "logger.h"
void logger(int level, int priority, const char *format, ...) { void logger(int level, int priority, const char *format, ...) {
UNUSED(level);
UNUSED(priority);
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vfprintf(stderr, format, ap); vfprintf(stderr, format, ap);

View file

@ -776,6 +776,8 @@ ask_netname:
static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) { static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) {
UNUSED(handle);
UNUSED(type);
while(len) { while(len) {
int result = send(sock, data, len, 0); int result = send(sock, data, len, 0);
if(result == -1 && errno == EINTR) 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) { static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint16_t len) {
UNUSED(handle);
UNUSED(type);
switch(type) { switch(type) {
case SPTPS_HANDSHAKE: case SPTPS_HANDSHAKE:
return sptps_send_record(&sptps, 0, cookie, sizeof cookie); return sptps_send_record(&sptps, 0, cookie, sizeof cookie);

View file

@ -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. // but both types have the name and hostname fields at the same offsets.
connection_t *c = s->handle; connection_t *c = s->handle;
if(c) 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); real_logger(DEBUG_ALWAYS, LOG_ERR, message);

View file

@ -36,6 +36,7 @@
bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) { bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) {
connection_t *c = handle; connection_t *c = handle;
UNUSED(type);
if(!c) { if(!c) {
logger(DEBUG_ALWAYS, LOG_ERR, "send_meta_sptps() called with NULL pointer!"); logger(DEBUG_ALWAYS, LOG_ERR, "send_meta_sptps() called with NULL pointer!");

View file

@ -1401,6 +1401,7 @@ void handle_incoming_vpn_data(void *data, int flags) {
socklen_t addrlen = sizeof addr; socklen_t addrlen = sizeof addr;
node_t *from, *to; node_t *from, *to;
bool direct = false; bool direct = false;
UNUSED(flags);
pkt.offset = 0; pkt.offset = 0;
int len = recvfrom(ls->udp.fd, DATA(&pkt), MAXSIZE, 0, &addr.sa, &addrlen); 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) { void handle_device_data(void *data, int flags) {
vpn_packet_t packet; vpn_packet_t packet;
UNUSED(data);
UNUSED(flags);
packet.offset = DEFAULT_PACKET_OFFSET; packet.offset = DEFAULT_PACKET_OFFSET;
packet.priority = 0; packet.priority = 0;

View file

@ -635,6 +635,7 @@ void handle_new_meta_connection(void *data, int flags) {
sockaddr_t sa; sockaddr_t sa;
int fd; int fd;
socklen_t len = sizeof sa; socklen_t len = sizeof sa;
UNUSED(flags);
fd = accept(l->tcp.fd, &sa.sa, &len); fd = accept(l->tcp.fd, &sa.sa, &len);
@ -732,6 +733,7 @@ void handle_new_unix_connection(void *data, int flags) {
sockaddr_t sa; sockaddr_t sa;
int fd; int fd;
socklen_t len = sizeof sa; socklen_t len = sizeof sa;
UNUSED(flags);
fd = accept(io->fd, &sa.sa, &len); fd = accept(io->fd, &sa.sa, &len);

View file

@ -31,6 +31,7 @@ typedef RSA rsa_t;
/* This function prettyprints the key generation process */ /* This function prettyprints the key generation process */
static void indicator(int a, int b, void *p) { static void indicator(int a, int b, void *p) {
UNUSED(p);
switch (a) { switch (a) {
case 0: case 0:
fprintf(stderr, "."); fprintf(stderr, ".");

View file

@ -163,6 +163,7 @@ static timeout_t past_request_timeout;
static void age_past_requests(void *data) { static void age_past_requests(void *data) {
int left = 0, deleted = 0; int left = 0, deleted = 0;
UNUSED(data);
for splay_each(past_request_t, p, past_request_tree) { for splay_each(past_request_t, p, past_request_tree) {
if(p->firstseen + pinginterval <= now.tv_sec) if(p->firstseen + pinginterval <= now.tv_sec)

View file

@ -155,6 +155,7 @@ bool send_id(connection_t *c) {
} }
static bool finalize_invitation(connection_t *c, const char *data, uint16_t len) { static bool finalize_invitation(connection_t *c, const char *data, uint16_t len) {
UNUSED(len);
if(strchr(data, '\n')) { if(strchr(data, '\n')) {
logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname); logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname);
return false; return false;

View file

@ -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) { static bool send_initial_sptps_data(void *handle, uint8_t type, const void *data, size_t len) {
node_t *to = handle; node_t *to = handle;
UNUSED(type);
to->sptps.send_data = send_sptps_data_myself; to->sptps.send_data = send_sptps_data_myself;
char buf[len * 4 / 3 + 5]; char buf[len * 4 / 3 + 5];
b64encode(data, buf, len); 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. */ /* 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) { 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. /* 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; 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. */ otherwise every hop would initiate its own UDP info message, resulting in elevated chatter. */

View file

@ -91,6 +91,8 @@ bool send_termreq(connection_t *c) {
} }
bool termreq_h(connection_t *c, const char *request) { bool termreq_h(connection_t *c, const char *request) {
UNUSED(c);
UNUSED(request);
return false; return false;
} }

View file

@ -193,6 +193,7 @@ static void swap_mac_addresses(vpn_packet_t *packet) {
static void age_subnets(void *data) { static void age_subnets(void *data) {
bool left = false; bool left = false;
UNUSED(data);
for splay_each(subnet_t, s, myself->subnet_tree) { for splay_each(subnet_t, s, myself->subnet_tree) {
if(s->expires && s->expires < now.tv_sec) { if(s->expires && s->expires < now.tv_sec) {

View file

@ -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) { 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) { 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); vfprintf(stderr, format, ap);
fputc('\n', stderr); fputc('\n', stderr);
} }
@ -230,6 +237,7 @@ static bool send_ack(sptps_t *s) {
// Receive an ACKnowledgement record. // Receive an ACKnowledgement record.
static bool receive_ack(sptps_t *s, const char *data, uint16_t len) { static bool receive_ack(sptps_t *s, const char *data, uint16_t len) {
UNUSED(data);
if(len) if(len)
return error(s, EIO, "Invalid ACK record length"); return error(s, EIO, "Invalid ACK record length");

View file

@ -30,6 +30,8 @@ static char *program_name;
void logger(int level, int priority, const char *format, ...) { void logger(int level, int priority, const char *format, ...) {
va_list ap; va_list ap;
UNUSED(level);
UNUSED(priority);
va_start(ap, format); va_start(ap, format);
vfprintf(stderr, format, ap); vfprintf(stderr, format, ap);
va_end(ap); va_end(ap);
@ -86,7 +88,7 @@ int main(int argc, char *argv[]) {
ecdsa_t *key = ecdsa_generate(); ecdsa_t *key = ecdsa_generate();
if(!key) if(!key)
return 1; return 1;
FILE *fp = fopen(argv[1], "w"); FILE *fp = fopen(argv[1], "w");
if(fp) { if(fp) {
if(!ecdsa_write_pem_private_key(key, fp)) { if(!ecdsa_write_pem_private_key(key, fp)) {

View file

@ -30,11 +30,16 @@
static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { static bool send_data(void *handle, uint8_t type, const void *data, size_t len) {
int fd = *(int *)handle; int fd = *(int *)handle;
UNUSED(type);
send(fd, data, len, 0); send(fd, data, len, 0);
return true; return true;
} }
static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { 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; return true;
} }

View file

@ -30,7 +30,6 @@
#include "sptps.h" #include "sptps.h"
#include "utils.h" #include "utils.h"
static bool verbose; static bool verbose;
static bool readonly; static bool readonly;
static bool writeonly; 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) { static bool send_data(void *handle, uint8_t type, const void *data, size_t len) {
char hex[len * 2 + 1]; char hex[len * 2 + 1];
UNUSED(type);
bin2hex(data, hex, len); bin2hex(data, hex, len);
if(verbose) if(verbose)
fprintf(stderr, "Sending %d bytes of data:\n%s\n", (int)len, hex); 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) { static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) {
UNUSED(handle);
if(verbose) if(verbose)
fprintf(stderr, "Received type %d record of %hu bytes:\n", type, len); fprintf(stderr, "Received type %d record of %hu bytes:\n", type, len);
if(!writeonly) if(!writeonly)

View file

@ -924,6 +924,7 @@ static int cmd_start(int argc, char *argv[]) {
} }
static int cmd_stop(int argc, char *argv[]) { static int cmd_stop(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -967,6 +968,7 @@ static int cmd_restart(int argc, char *argv[]) {
} }
static int cmd_reload(int argc, char *argv[]) { static int cmd_reload(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -1209,6 +1211,7 @@ static int cmd_dump(int argc, char *argv[]) {
} }
static int cmd_purge(int argc, char *argv[]) { static int cmd_purge(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -1249,6 +1252,7 @@ static int cmd_debug(int argc, char *argv[]) {
} }
static int cmd_retry(int argc, char *argv[]) { static int cmd_retry(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -1313,6 +1317,7 @@ static int cmd_disconnect(int argc, char *argv[]) {
} }
static int cmd_top(int argc, char *argv[]) { static int cmd_top(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -1345,6 +1350,7 @@ static int cmd_pcap(int argc, char *argv[]) {
#ifdef SIGINT #ifdef SIGINT
static void sigint_handler(int sig) { static void sigint_handler(int sig) {
UNUSED(sig);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
shutdown(fd, SHUT_RDWR); shutdown(fd, SHUT_RDWR);
} }
@ -1375,6 +1381,7 @@ static int cmd_log(int argc, char *argv[]) {
} }
static int cmd_pid(int argc, char *argv[]) { static int cmd_pid(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -1991,6 +1998,7 @@ static int cmd_generate_rsa_keys(int argc, char *argv[]) {
#endif #endif
static int cmd_generate_ed25519_keys(int argc, char *argv[]) { static int cmd_generate_ed25519_keys(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2003,11 +2011,14 @@ static int cmd_generate_ed25519_keys(int argc, char *argv[]) {
} }
static int cmd_help(int argc, char *argv[]) { static int cmd_help(int argc, char *argv[]) {
UNUSED(argc);
UNUSED(argv);
usage(false); usage(false);
return 0; return 0;
} }
static int cmd_version(int argc, char *argv[]) { static int cmd_version(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2116,6 +2127,7 @@ static int export(const char *name, FILE *out) {
} }
static int cmd_export(int argc, char *argv[]) { static int cmd_export(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2134,6 +2146,7 @@ static int cmd_export(int argc, char *argv[]) {
} }
static int cmd_export_all(int argc, char *argv[]) { static int cmd_export_all(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2168,6 +2181,7 @@ static int cmd_export_all(int argc, char *argv[]) {
} }
static int cmd_import(int argc, char *argv[]) { static int cmd_import(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2287,8 +2301,8 @@ static int cmd_network(int argc, char *argv[]) {
DIR *dir = opendir(confdir); DIR *dir = opendir(confdir);
if(!dir) { if(!dir) {
fprintf(stderr, "Could not read directory %s: %s\n", confdir, strerror(errno)); fprintf(stderr, "Could not read directory %s: %s\n", confdir, strerror(errno));
return 1; return 1;
} }
struct dirent *ent; struct dirent *ent;
while((ent = readdir(dir))) { while((ent = readdir(dir))) {
@ -2312,6 +2326,7 @@ static int cmd_network(int argc, char *argv[]) {
} }
static int cmd_fsck(int argc, char *argv[]) { static int cmd_fsck(int argc, char *argv[]) {
UNUSED(argv);
if(argc > 1) { if(argc > 1) {
fprintf(stderr, "Too many arguments!\n"); fprintf(stderr, "Too many arguments!\n");
return 1; return 1;
@ -2464,11 +2479,14 @@ static char *complete_info(const char *text, int state) {
} }
static char *complete_nothing(const char *text, int state) { static char *complete_nothing(const char *text, int state) {
UNUSED(text);
UNUSED(state);
return NULL; return NULL;
} }
static char **completion (const char *text, int start, int end) { static char **completion (const char *text, int start, int end) {
char **matches = NULL; char **matches = NULL;
UNUSED(end);
if(!start) if(!start)
matches = rl_completion_matches(text, complete_command); matches = rl_completion_matches(text, complete_command);