From c33dde4ac1dd8ec376d5ee2d5f0544b45b1484e4 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 4 Sep 2008 21:58:09 +0000 Subject: [PATCH] Fix mingw build with --enable-gcc-warnings set. svn:r16759 --- src/common/address.c | 4 ++-- src/common/compat.c | 6 +++--- src/or/eventdns.c | 2 +- src/or/geoip.c | 2 +- src/or/main.c | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common/address.c b/src/common/address.c index c7483af09c..a9f731e9a2 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -64,7 +64,7 @@ tor_addr_to_sockaddr(const tor_addr_t *a, { if (a->family == AF_INET) { struct sockaddr_in *sin; - if (len < sizeof(struct sockaddr_in)) + if (len < (int)sizeof(struct sockaddr_in)) return -1; sin = (struct sockaddr_in *)sa_out; sin->sin_family = AF_INET; @@ -73,7 +73,7 @@ tor_addr_to_sockaddr(const tor_addr_t *a, return sizeof(struct sockaddr_in); } else if (a->family == AF_INET6) { struct sockaddr_in6 *sin6; - if (len < sizeof(struct sockaddr_in6)) + if (len < (int)sizeof(struct sockaddr_in6)) return -1; sin6 = (struct sockaddr_in6 *)sa_out; memset(sin6, 0, sizeof(struct sockaddr_in6)); diff --git a/src/common/compat.c b/src/common/compat.c index ded66493c5..31029844d1 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -497,7 +497,7 @@ tor_lockfile_lock(const char *filename, int blocking, int *locked_out) } #ifdef WIN32 _lseek(fd, 0, SEEK_SET); - if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLOCK, 0) < 0) { + if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLCK, 0) < 0) { if (errno != EDEADLOCK) log_warn(LD_FS,"Couldn't lock \"%s\": %s", filename, strerror(errno)); else @@ -529,8 +529,8 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile) log_info(LD_FS, "Unlocking \"%s\"", lockfile->filename); #ifdef WIN32 - _lseek(fd, 0, SEEK_SET); - if (_locking(fd, _LK_UNLCK, 0) < 0) { + _lseek(lockfile->fd, 0, SEEK_SET); + if (_locking(lockfile->fd, _LK_UNLCK, 0) < 0) { log_warn(LD_FS,"Error unlocking \"%s\": %s", lockfile->filename, strerror(errno)); } diff --git a/src/or/eventdns.c b/src/or/eventdns.c index 354d60ee03..ba0f7a7d11 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -2178,7 +2178,7 @@ _evdns_nameserver_add_impl(const struct sockaddr *address, server = server->next; } while (server != started_at); } - if (addrlen > sizeof(ns->address)) { + if (addrlen > (int)sizeof(ns->address)) { return 2; } diff --git a/src/or/geoip.c b/src/or/geoip.c index b795bccee7..e15f0ba523 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -443,7 +443,7 @@ geoip_get_client_history(time_t now, geoip_client_action_t action) #endif HT_FOREACH(ent, clientmap, &client_history) { int country; - if (((*ent)->last_seen & ACTION_MASK) != action) + if (((*ent)->last_seen & ACTION_MASK) != (int)action) continue; country = geoip_get_country_by_ip((*ent)->ipaddr); if (country < 0) diff --git a/src/or/main.c b/src/or/main.c index 1d57cff5ed..a91937c7a9 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1868,7 +1868,11 @@ try_locking(or_options_t *options, int err_if_locked) log_warn(LD_GENERAL, "It looks like another Tor process is running " "with the same data directory. Waiting 5 seconds to see " "if it goes away."); +#ifndef WIN32 sleep(5); +#else + Sleep(5000); +#endif r = try_locking(options, 0); if (r<0) { log_err(LD_GENERAL, "No, it's still there. Exiting.");