diff --git a/src/logsimh.c b/src/logsimh.c
index 95069a2172c52a3a7eab43233c4f029c7d887a2e..dc65bbbd768b71e7d04ad63a3f25c2450abd09d2 100644
--- a/src/logsimh.c
+++ b/src/logsimh.c
@@ -1446,9 +1446,9 @@ static void getpindata(pdrec **pindata, long numpins, uchar *proc, struct LOC_co
 }
 
 
-static long setbytes(long bits, struct LOC_compilepage *LINK)
+static size_t setbytes(size_t bits, struct LOC_compilepage *LINK)
 {
-	return ((bits + 63) / 32 * 4);
+	return ((bits + 63) / 32 * sizeof(long));
 }
 
 /* Local variables for parsegates: */
@@ -1488,7 +1488,8 @@ static void subupdate(log_grec *g1, struct LOC_parsegates *LINK)
 static void parsegates(struct LOC_compilepage *LINK)
 {
 	struct LOC_parsegates V;
-	long i, j, num, best, setsize, first, numg, previnstrcount;
+	long i, j, num, best, first, numg, previnstrcount;
+	size_t setsize;
 	long *defs, *tdefs;
 	log_grec *g1;
 	gaterec *glist;
@@ -2890,7 +2891,7 @@ static void trymoveif(struct LOC_simplstmt *LINK)
 	long *defv1, *usev1, *defv2, *usev2;
 	int good1, good2, localchg;
 	instrops otherif;
-	long i;
+	size_t i;
 
 	otherif = numbertoif(~iftonumber(LINK->ip, LINK), LINK);
 	defv1 = NULL;