summaryrefslogtreecommitdiffstats
path: root/src/host/osmocon
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-11-06 22:05:03 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-11-06 22:10:42 +0100
commita73c98a3abd2dc20145325436cefa2705c0db8f1 (patch)
tree5d266a9bfd35eda78b6b6dfe0c8e34a2169e87e2 /src/host/osmocon
parent6d1f1163381707a7f4172e2a19e5646b38fb12c9 (diff)
osmocom: Address warning about aliasing
We alias the uint8_t buf[..] to a uint16_t* which is violating the aliases rule of C. Use an explicit memcpy to copy the first two byte of the buffer. GCC 4.6.2 (debian) is clever enough to use a normal load does not generate a memcpy call. osmocon.c: In function ‘un_tool_read’: osmocon.c:1239:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
Diffstat (limited to 'src/host/osmocon')
-rw-r--r--src/host/osmocon/osmocon.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c
index 189984fb..5f289928 100644
--- a/src/host/osmocon/osmocon.c
+++ b/src/host/osmocon/osmocon.c
@@ -1236,7 +1236,8 @@ static int un_tool_read(struct osmo_fd *fd, unsigned int flags)
c += rc;
}
- length = ntohs(*(uint16_t*)buf);
+ memcpy(&length, buf, sizeof length);
+ length = ntohs(length);
c = 0;
while(c < length) {