From: Guus Sliepen Date: Wed, 20 Feb 2013 13:39:24 +0000 (+0100) Subject: Fix compiler warnings on Windows. X-Git-Tag: release-1.1pre6~2 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=3847b78ba5900fe4311e9ef62474e32e1a6750e5;p=tinc Fix compiler warnings on Windows. --- diff --git a/src/event.c b/src/event.c index 0dde994f..6b730f6d 100644 --- a/src/event.c +++ b/src/event.c @@ -52,13 +52,8 @@ static int timeout_compare(const timeout_t *a, const timeout_t *b) { return 0; } -static int signal_compare(const signal_t *a, const signal_t *b) { - return a->signum - b->signum; -} - static splay_tree_t io_tree = {.compare = (splay_compare_t)io_compare}; static splay_tree_t timeout_tree = {.compare = (splay_compare_t)timeout_compare}; -static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare}; void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags) { if(io->cb) @@ -130,8 +125,13 @@ void timeout_del(timeout_t *timeout) { } #ifndef HAVE_MINGW +static int signal_compare(const signal_t *a, const signal_t *b) { + return a->signum - b->signum; +} + static io_t signalio; static int pipefd[2] = {-1, -1}; +static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare}; static void signal_handler(int signum) { unsigned char num = signum; diff --git a/src/mingw/device.c b/src/mingw/device.c index d13b824a..aa059720 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -47,7 +47,7 @@ extern char *myport; static DWORD WINAPI tapreader(void *bla) { int status; - long len; + DWORD len; OVERLAPPED overlapped; vpn_packet_t packet; @@ -62,7 +62,7 @@ static DWORD WINAPI tapreader(void *bla) { overlapped.OffsetHigh = 0; ResetEvent(overlapped.hEvent); - status = ReadFile(device_handle, packet.data, MTU, &len, &overlapped); + status = ReadFile(device_handle, (void *)packet.data, MTU, &len, &overlapped); if(!status) { if(GetLastError() == ERROR_IO_PENDING) { @@ -92,7 +92,7 @@ static bool setup_device(void) { char adapterid[1024]; char adaptername[1024]; char tapname[1024]; - long len; + DWORD len; unsigned long status; bool found = false; @@ -123,7 +123,7 @@ static bool setup_device(void) { continue; len = sizeof adaptername; - err = RegQueryValueEx(key2, "Name", 0, 0, adaptername, &len); + err = RegQueryValueEx(key2, "Name", 0, 0, (LPBYTE)adaptername, &len); RegCloseKey(key2); @@ -223,7 +223,7 @@ static bool read_packet(vpn_packet_t *packet) { } static bool write_packet(vpn_packet_t *packet) { - long outlen; + DWORD outlen; OVERLAPPED overlapped = {0}; logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", diff --git a/src/multicast_device.c b/src/multicast_device.c index bd9ef1db..e58d293e 100644 --- a/src/multicast_device.c +++ b/src/multicast_device.c @@ -165,7 +165,7 @@ static void close_device(void) { static bool read_packet(vpn_packet_t *packet) { int lenin; - if((lenin = recv(device_fd, packet->data, MTU, 0)) <= 0) { + if((lenin = recv(device_fd, (void *)packet->data, MTU, 0)) <= 0) { logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; @@ -191,7 +191,7 @@ static bool write_packet(vpn_packet_t *packet) { logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", packet->len, device_info); - if(sendto(device_fd, packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) { + if(sendto(device_fd, (void *)packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) { logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; diff --git a/src/names.c b/src/names.c index 688e96d3..cc72a112 100644 --- a/src/names.c +++ b/src/names.c @@ -39,7 +39,7 @@ void make_names(void) { #ifdef HAVE_MINGW HKEY key; char installdir[1024] = ""; - long len = sizeof installdir; + DWORD len = sizeof installdir; #endif if(netname) @@ -49,7 +49,7 @@ void make_names(void) { #ifdef HAVE_MINGW if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { - if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) { + if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) { confdir = xstrdup(installdir); if(!logfilename) xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname); diff --git a/src/net.c b/src/net.c index 97b1e5df..0d374e6e 100644 --- a/src/net.c +++ b/src/net.c @@ -287,6 +287,7 @@ void handle_meta_connection_data(connection_t *c) { } } +#ifndef HAVE_MINGW static void sigterm_handler(void *data) { logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); event_exit(); @@ -302,6 +303,7 @@ static void sigalrm_handler(void *data) { logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); retry(); } +#endif int reload_configuration(void) { char *fname; diff --git a/src/net_socket.c b/src/net_socket.c index cb2a6dfe..a28be54a 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -377,7 +377,7 @@ static void handle_meta_io(void *data, int flags) { int result; socklen_t len = sizeof result; - getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); + getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len); if(!result) finish_connecting(c); diff --git a/src/process.c b/src/process.c index 0f399e79..cbb190a5 100644 --- a/src/process.c +++ b/src/process.c @@ -259,8 +259,8 @@ bool execute_script(const char *name, char **envp) { } } -#ifdef WEXITSTATUS if(status != -1) { +#ifdef WEXITSTATUS if(WIFEXITED(status)) { /* Child exited by itself */ if(WEXITSTATUS(status)) { logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d", @@ -275,11 +275,11 @@ bool execute_script(const char *name, char **envp) { logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name); return false; } +#endif } else { logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); return false; } -#endif #endif return true; } diff --git a/src/tincd.c b/src/tincd.c index 1feab407..8412c8f7 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -67,14 +67,18 @@ static bool show_version = false; /* If nonzero, use null ciphers and skip all key exchanges. */ bool bypass_security = false; +#ifdef HAVE_MLOCKALL /* If nonzero, disable swapping for this process. */ static bool do_mlock = false; +#endif +#ifndef HAVE_MINGW /* If nonzero, chroot to netdir after startup. */ static bool do_chroot = false; /* If !NULL, do setuid to given user after startup */ static const char *switchuser = NULL; +#endif /* If nonzero, write log entries to a separate file. */ bool use_logfile = false;