diff --git a/keyring.c b/keyring.c
index 871aa677..0a369c6e 100644
--- a/keyring.c
+++ b/keyring.c
@@ -486,7 +486,7 @@ static int _load_decode_hex(const char **hex, unsigned char **buf, size_t *len)
       return -1;
   }
   else if (hexlen != *len)
-    return WHYF("invalid hex value, incorrect length (expecting %u bytes, got %u)", *len, hexlen);
+    return WHYF("invalid hex value, incorrect length (expecting %zu bytes, got %zu)", *len, hexlen);
   strn_fromhex(*buf, *len, *hex, hex);
   assert(*hex == end);
   return 0;
@@ -966,7 +966,7 @@ static keyring_identity *keyring_unpack_identity(unsigned char *slot, const char
     }
     if (keypair_len > rotbuf_remain(&rbuf)) {
       if (config.debug.keyring)
-	DEBUGF("invalid keypair length %u", keypair_len);
+	DEBUGF("invalid keypair length %zu", keypair_len);
       keyring_free_identity(id);
       return NULL;
     }
diff --git a/log.c b/log.c
index bb246c45..85f7a99a 100644
--- a/log.c
+++ b/log.c
@@ -238,7 +238,7 @@ static void _log_prefix(_log_iterator *it, int level)
       if (strftime(buf, sizeof buf, "%T", &it->tm) == 0)
 	xputs("EMPTYTIME___ ", it->xpf);
       else
-	xprintf(it->xpf, "%s.%03u ", buf, it->tv.tv_usec / 1000);
+	xprintf(it->xpf, "%s.%03u ", buf, (unsigned int)it->tv.tv_usec / 1000);
     }
   }
 }
@@ -667,7 +667,7 @@ void logString(int level, struct __sourceloc whence, const char *str)
 	_log_iterator_rewind(&it);
 	while (_log_iterator_next(&it, level)) {
 	  _log_prefix_whence(&it, whence);
-	  xprintf(it.xpf, "%.*s", p - s, s);
+	  xprintf(it.xpf, "%.*s", (int)(p - s), s);
 	}
 	s = p + 1;
       }
@@ -676,7 +676,7 @@ void logString(int level, struct __sourceloc whence, const char *str)
       _log_iterator_rewind(&it);
       while (_log_iterator_next(&it, level)) {
 	_log_prefix_whence(&it, whence);
-	xprintf(it.xpf, "%.*s", p - s, s);
+	xprintf(it.xpf, "%.*s", (int)(p - s), s);
       }
     }
   }
diff --git a/serval.h b/serval.h
index 4af7510d..5c27884f 100644
--- a/serval.h
+++ b/serval.h
@@ -199,9 +199,9 @@ struct decode_context;
 typedef struct keypair {
   int type;
   unsigned char *private_key;
-  unsigned private_key_len;
+  size_t private_key_len;
   unsigned char *public_key;
-  unsigned public_key_len;
+  size_t public_key_len;
 } keypair;
 
 /* Contains just the list of private:public key pairs and types,