From: Guus Sliepen Date: Sun, 3 Mar 2013 19:44:18 +0000 (+0100) Subject: Fix compiler warnings on Windows. X-Git-Tag: release-1.0.20~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fb5fcc575d25a51acf73d476f63ce72f30cda6c2;p=oweals%2Ftinc.git Fix compiler warnings on Windows. --- diff --git a/src/mingw/device.c b/src/mingw/device.c index b958831..6705108 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a MinGW environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2011 Guus Sliepen + 2002-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,7 @@ extern char *myport; static DWORD WINAPI tapreader(void *bla) { int status; - long len; + DWORD len; OVERLAPPED overlapped; vpn_packet_t packet; @@ -91,7 +91,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; @@ -122,7 +122,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); @@ -222,7 +222,7 @@ static bool read_packet(vpn_packet_t *packet) { } static bool write_packet(vpn_packet_t *packet) { - long lenout; + DWORD lenout; OVERLAPPED overlapped = {0}; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", diff --git a/src/multicast_device.c b/src/multicast_device.c index 0b232db..99fafcc 100644 --- a/src/multicast_device.c +++ b/src/multicast_device.c @@ -1,7 +1,7 @@ /* device.c -- multicast socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2012 Guus Sliepen + 2002-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +158,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(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; @@ -184,7 +184,7 @@ static bool write_packet(vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(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(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; diff --git a/src/net_setup.c b/src/net_setup.c index ddb0bcf..5a7c606 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1,7 +1,7 @@ /* net_setup.c -- Setup. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2013 Guus Sliepen 2006 Scott Lamb 2010 Brandon Black @@ -163,7 +163,6 @@ bool read_rsa_public_key(connection_t *c) { static bool read_rsa_private_key(void) { FILE *fp; char *fname, *key, *pubkey; - struct stat s; if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key)) { if(!get_config_string(lookup_config(config_tree, "PublicKey"), &pubkey)) { @@ -199,6 +198,8 @@ static bool read_rsa_private_key(void) { } #if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) + struct stat s; + if(fstat(fileno(fp), &s)) { logger(LOG_ERR, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno)); diff --git a/src/net_socket.c b/src/net_socket.c index e763499..48e0783 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -1,7 +1,7 @@ /* net_socket.c -- Handle various kinds of sockets. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2013 Guus Sliepen 2006 Scott Lamb 2009 Florian Forster @@ -64,7 +64,7 @@ static void configure_tcp(connection_t *c) { unsigned long arg = 1; if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) { - logger(LOG_ERR, "ioctlsocket for %s: %d", c->hostname, sockstrerror(sockerrno)); + logger(LOG_ERR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno)); } #endif diff --git a/src/process.c b/src/process.c index b76e81c..020dfa0 100644 --- a/src/process.c +++ b/src/process.c @@ -1,7 +1,7 @@ /* process.c -- process management functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2011 Guus Sliepen + 2000-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,8 +47,6 @@ extern bool use_logfile; static sigset_t emptysigset; #endif -static int saved_debug_level = -1; - static void memory_full(int size) { logger(LOG_ERR, "Memory exhausted (couldn't allocate %d bytes), exitting.", size); exit(1); @@ -167,7 +165,7 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN"); break; default: - logger(LOG_WARNING, "Got unexpected request %d", request); + logger(LOG_WARNING, "Got unexpected request %d", (int)request); return ERROR_CALL_NOT_IMPLEMENTED; } @@ -187,10 +185,8 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { } VOID WINAPI run_service(DWORD argc, LPTSTR* argv) { - int err = 1; extern int main2(int argc, char **argv); - status.dwServiceType = SERVICE_WIN32; status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; status.dwWin32ExitCode = 0; @@ -201,7 +197,6 @@ VOID WINAPI run_service(DWORD argc, LPTSTR* argv) { if (!statushandle) { logger(LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError())); - err = 1; } else { status.dwWaitHint = 30000; status.dwCurrentState = SERVICE_START_PENDING; @@ -211,11 +206,10 @@ VOID WINAPI run_service(DWORD argc, LPTSTR* argv) { status.dwCurrentState = SERVICE_RUNNING; SetServiceStatus(statushandle, &status); - err = main2(argc, argv); + main2(argc, argv); status.dwWaitHint = 0; status.dwCurrentState = SERVICE_STOPPED; - //status.dwWin32ExitCode = err; SetServiceStatus(statushandle, &status); } @@ -413,8 +407,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(LOG_ERR, "Script %s exited with non-zero status %d", @@ -429,11 +423,11 @@ bool execute_script(const char *name, char **envp) { logger(LOG_ERR, "Script %s terminated abnormally", name); return false; } +#endif } else { logger(LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); return false; } -#endif #endif return true; } @@ -494,6 +488,8 @@ static RETSIGTYPE sighup_handler(int a) { } static RETSIGTYPE sigint_handler(int a) { + static int saved_debug_level = -1; + logger(LOG_NOTICE, "Got %s signal", "INT"); if(saved_debug_level != -1) { diff --git a/src/route.c b/src/route.c index 4ae56a5..e196f44 100644 --- a/src/route.c +++ b/src/route.c @@ -1,7 +1,7 @@ /* route.c -- routing Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -340,7 +340,7 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et todo = ntohs(ip.ip_len) - ip_size; if(ether_size + ip_size + todo != packet->len) { - ifdebug(TRAFFIC) logger(LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%zd)", packet->len, ether_size + ip_size + todo); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%d)", packet->len, (int)(ether_size + ip_size + todo)); return; } diff --git a/src/tincd.c b/src/tincd.c index 53f91e8..aaad1da 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -1,7 +1,7 @@ /* tincd.c -- the main file for tincd Copyright (C) 1998-2005 Ivo Timmermans - 2000-2012 Guus Sliepen + 2000-2013 Guus Sliepen 2008 Max Rijevski 2009 Michael Tokarev 2010 Julien Muchembled @@ -391,7 +391,7 @@ static void make_names(void) { #ifdef HAVE_MINGW HKEY key; char installdir[1024] = ""; - long len = sizeof(installdir); + DWORD len = sizeof(installdir); #endif if(netname) @@ -401,7 +401,7 @@ static 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)) { if(!logfilename) xasprintf(&logfilename, "%s/log/%s.log", identname); if(!confbase) { @@ -513,7 +513,7 @@ int main(int argc, char **argv) { if(show_version) { printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE, VERSION, __DATE__, __TIME__, PROT_CURRENT); - printf("Copyright (C) 1998-2012 Ivo Timmermans, Guus Sliepen and others.\n" + printf("Copyright (C) 1998-2013 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n"