diff --git a/src/common/address.c b/src/common/address.c
index c7483af09c524a6ee9289f987c71bbce20475a92..a9f731e9a271d2b5bd1b27626c02b5e73bcb1861 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 ded66493c51d1c1b3afe2e1640ef776f86999448..31029844d159e5410529f0033d5737c9cbd62469 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 354d60ee035ed8588027477a3730abf4cc87e389..ba0f7a7d11cfa97867224ed8aa1bd8c29e00bcf4 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 b795bccee7b4982863e8a659ba021c9bb0faeb1e..e15f0ba523884505069735cf50ec2f408233d945 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 1d57cff5edeee824ad7d4cec08fcf671da2003d5..a91937c7a9afda091d322ac82e1f755e9efee106 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.");