Fix missing htobe16 on windows and meaningless >u32 string warning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
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;
}