Fix compiler warnings on Windows.

This commit is contained in:
Guus Sliepen 2013-02-20 14:39:24 +01:00
parent 1bb969c930
commit 3847b78ba5
8 changed files with 23 additions and 17 deletions

View file

@ -52,13 +52,8 @@ static int timeout_compare(const timeout_t *a, const timeout_t *b) {
return 0; 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 io_tree = {.compare = (splay_compare_t)io_compare};
static splay_tree_t timeout_tree = {.compare = (splay_compare_t)timeout_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) { void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags) {
if(io->cb) if(io->cb)
@ -130,8 +125,13 @@ void timeout_del(timeout_t *timeout) {
} }
#ifndef HAVE_MINGW #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 io_t signalio;
static int pipefd[2] = {-1, -1}; static int pipefd[2] = {-1, -1};
static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare};
static void signal_handler(int signum) { static void signal_handler(int signum) {
unsigned char num = signum; unsigned char num = signum;

View file

@ -47,7 +47,7 @@ extern char *myport;
static DWORD WINAPI tapreader(void *bla) { static DWORD WINAPI tapreader(void *bla) {
int status; int status;
long len; DWORD len;
OVERLAPPED overlapped; OVERLAPPED overlapped;
vpn_packet_t packet; vpn_packet_t packet;
@ -62,7 +62,7 @@ static DWORD WINAPI tapreader(void *bla) {
overlapped.OffsetHigh = 0; overlapped.OffsetHigh = 0;
ResetEvent(overlapped.hEvent); 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(!status) {
if(GetLastError() == ERROR_IO_PENDING) { if(GetLastError() == ERROR_IO_PENDING) {
@ -92,7 +92,7 @@ static bool setup_device(void) {
char adapterid[1024]; char adapterid[1024];
char adaptername[1024]; char adaptername[1024];
char tapname[1024]; char tapname[1024];
long len; DWORD len;
unsigned long status; unsigned long status;
bool found = false; bool found = false;
@ -123,7 +123,7 @@ static bool setup_device(void) {
continue; continue;
len = sizeof adaptername; len = sizeof adaptername;
err = RegQueryValueEx(key2, "Name", 0, 0, adaptername, &len); err = RegQueryValueEx(key2, "Name", 0, 0, (LPBYTE)adaptername, &len);
RegCloseKey(key2); RegCloseKey(key2);
@ -223,7 +223,7 @@ static bool read_packet(vpn_packet_t *packet) {
} }
static bool write_packet(vpn_packet_t *packet) { static bool write_packet(vpn_packet_t *packet) {
long outlen; DWORD outlen;
OVERLAPPED overlapped = {0}; OVERLAPPED overlapped = {0};
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s",

View file

@ -165,7 +165,7 @@ static void close_device(void) {
static bool read_packet(vpn_packet_t *packet) { static bool read_packet(vpn_packet_t *packet) {
int lenin; 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, logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno)); device, strerror(errno));
return false; 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", logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s",
packet->len, device_info); 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, logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device,
strerror(errno)); strerror(errno));
return false; return false;

View file

@ -39,7 +39,7 @@ void make_names(void) {
#ifdef HAVE_MINGW #ifdef HAVE_MINGW
HKEY key; HKEY key;
char installdir[1024] = ""; char installdir[1024] = "";
long len = sizeof installdir; DWORD len = sizeof installdir;
#endif #endif
if(netname) if(netname)
@ -49,7 +49,7 @@ void make_names(void) {
#ifdef HAVE_MINGW #ifdef HAVE_MINGW
if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { 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); confdir = xstrdup(installdir);
if(!logfilename) if(!logfilename)
xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname); xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname);

View file

@ -287,6 +287,7 @@ void handle_meta_connection_data(connection_t *c) {
} }
} }
#ifndef HAVE_MINGW
static void sigterm_handler(void *data) { static void sigterm_handler(void *data) {
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
event_exit(); 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)); logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
retry(); retry();
} }
#endif
int reload_configuration(void) { int reload_configuration(void) {
char *fname; char *fname;

View file

@ -377,7 +377,7 @@ static void handle_meta_io(void *data, int flags) {
int result; int result;
socklen_t len = sizeof 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) if(!result)
finish_connecting(c); finish_connecting(c);

View file

@ -259,8 +259,8 @@ bool execute_script(const char *name, char **envp) {
} }
} }
#ifdef WEXITSTATUS
if(status != -1) { if(status != -1) {
#ifdef WEXITSTATUS
if(WIFEXITED(status)) { /* Child exited by itself */ if(WIFEXITED(status)) { /* Child exited by itself */
if(WEXITSTATUS(status)) { if(WEXITSTATUS(status)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d", 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); logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name);
return false; return false;
} }
#endif
} else { } else {
logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno));
return false; return false;
} }
#endif
#endif #endif
return true; return true;
} }

View file

@ -67,14 +67,18 @@ static bool show_version = false;
/* If nonzero, use null ciphers and skip all key exchanges. */ /* If nonzero, use null ciphers and skip all key exchanges. */
bool bypass_security = false; bool bypass_security = false;
#ifdef HAVE_MLOCKALL
/* If nonzero, disable swapping for this process. */ /* If nonzero, disable swapping for this process. */
static bool do_mlock = false; static bool do_mlock = false;
#endif
#ifndef HAVE_MINGW
/* If nonzero, chroot to netdir after startup. */ /* If nonzero, chroot to netdir after startup. */
static bool do_chroot = false; static bool do_chroot = false;
/* If !NULL, do setuid to given user after startup */ /* If !NULL, do setuid to given user after startup */
static const char *switchuser = NULL; static const char *switchuser = NULL;
#endif
/* If nonzero, write log entries to a separate file. */ /* If nonzero, write log entries to a separate file. */
bool use_logfile = false; bool use_logfile = false;