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) {
UNUSED(packet);
return false;
}
static bool write_packet(vpn_packet_t *packet) {
UNUSED(packet);
return true;
}

View file

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

View file

@ -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;

View file

@ -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;
}

View file

@ -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);

View file

@ -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);

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.
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);

View file

@ -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!");

View file

@ -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;

View file

@ -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);

View file

@ -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, ".");

View file

@ -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)

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) {
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;

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) {
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. */

View file

@ -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;
}

View file

@ -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) {

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) {
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");

View file

@ -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)) {

View file

@ -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;
}

View file

@ -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)

View file

@ -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);