summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-12-15 08:01:59 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-12-15 08:27:32 +0100
commitb2ee119f7aeaa96f7305dbda55f7cc14d4d840c5 (patch)
treefc191ebf7ee9e51f3641b9ea5cd6dd53ed39e2fe
parentEnable WebSocket support in the Mongoose HTTP server (diff)
downloadrtems-b2ee119f7aeaa96f7305dbda55f7cc14d4d840c5.tar.bz2
sys/endian.h: Fix 16-bit int problems
-rw-r--r--cpukit/include/sys/endian.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/cpukit/include/sys/endian.h b/cpukit/include/sys/endian.h
index abd6f01760..b78d8c711a 100644
--- a/cpukit/include/sys/endian.h
+++ b/cpukit/include/sys/endian.h
@@ -91,7 +91,7 @@ be16dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return ((p[0] << 8) | p[1]);
+ return (((unsigned)p[0] << 8) | p[1]);
}
static __inline uint32_t
@@ -99,7 +99,8 @@ be32dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+ return (((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) |
+ ((uint32_t)p[2] << 8) | p[3]);
}
static __inline uint64_t
@@ -115,7 +116,7 @@ le16dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return ((p[1] << 8) | p[0]);
+ return (((unsigned)p[1] << 8) | p[0]);
}
static __inline uint32_t
@@ -123,7 +124,8 @@ le32dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
+ return (((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16) |
+ ((uint32_t)p[1] << 8) | p[0]);
}
static __inline uint64_t