Commit bea3c9e3371ae6d36fa67631b24d5167b2747f55

Con Kolivas 2014-03-18T22:51:18

Fix missing htobe16 on windows and meaningless >u32 string warning.

diff --git a/NEWS b/NEWS
index a885f4b..c32b547 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 Version 4.2.0 - 18th March 2014
 
+- Fix missing htobe16 on windows and meaningless >u32 string warning.
 - Software ntime roll for all hashfast devices.
 - Silence harmless warning.
 - Drop a failed restart icarus device to allow it to be rehotplugged if
diff --git a/miner.h b/miner.h
index e47efc8..90a17d3 100644
--- a/miner.h
+++ b/miner.h
@@ -167,6 +167,7 @@ static inline int fsync (int fd)
 #  define le64toh(x) (x)
 #  define be32toh(x) bswap_32(x)
 #  define be64toh(x) bswap_64(x)
+#  define htobe16(x) bswap_16(x)
 #  define htobe32(x) bswap_32(x)
 #  define htobe64(x) bswap_64(x)
 # elif __BYTE_ORDER == __BIG_ENDIAN
@@ -178,6 +179,7 @@ static inline int fsync (int fd)
 #  define htole64(x) bswap_64(x)
 #  define be32toh(x) (x)
 #  define be64toh(x) (x)
+#  define htobe16(x) (x)
 #  define htobe32(x) (x)
 #  define htobe64(x) (x)
 #else
diff --git a/util.c b/util.c
index 0f1bb76..f6a3ecb 100644
--- a/util.c
+++ b/util.c
@@ -758,20 +758,14 @@ unsigned char *ser_string(char *s, int *slen)
 		*u16 = htobe16(len);
 		memcpy(ret + 3, s, len);
 		*slen = len + 3;
-	} else if (len < 0x100000000ul) {
+	} else {
+		/* size_t is only 32 bit on many platforms anyway */
 		uint32_t *u32 = (uint32_t *)&ret[1];
 
 		ret[0] = 254;
 		*u32 = htobe32(len);
 		memcpy(ret + 5, s, len);
 		*slen = len + 5;
-	} else {
-		uint64_t *u64 = (uint64_t *)&ret[1];
-
-		ret[0] = 255;
-		*u64 = htobe64(len);
-		memcpy(ret + 9, s, len);
-		*slen = len + 9;
 	}
 	return ret;
 }