aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-04 13:01:28 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-04 13:01:28 +0200
commit444d7d8e65447ca871db00828d2eda1490c2bbe7 (patch)
treea8befaab7c54ced487002a45b5e90dee989b8b6a
parent686191a1c9be0f6dcfe92782332c4507b70e37e1 (diff)
ipa: Fix compiler warnings about aliasing
Use memcpy to copy from the OML message into the stack and then convert the network byte order. network_listen.c: In function ‘test_rep’: network_listen.c:145:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] test_rep_len = ntohs(*(uint16_t *) &foh->data[3]); ^ network_listen.c:153:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]); ^ network_listen.c:164:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]); ^ network_listen.c:130:11: warning: variable ‘test_rep_len’ set but not used [-Wunused-but-set-variable] uint16_t test_rep_len, ferr_list_len;
-rw-r--r--openbsc/src/ipaccess/network_listen.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/openbsc/src/ipaccess/network_listen.c b/openbsc/src/ipaccess/network_listen.c
index 6749c4aa3..3b44ceb74 100644
--- a/openbsc/src/ipaccess/network_listen.c
+++ b/openbsc/src/ipaccess/network_listen.c
@@ -142,7 +142,8 @@ static int test_rep(void *_msg)
DEBUGPC(DNM, "test_no=0x%02x ", foh->data[1]);
/* data[2] == NM_ATT_TEST_REPORT */
/* data[3..4]: test_rep_len */
- test_rep_len = ntohs(*(uint16_t *) &foh->data[3]);
+ memcpy(&test_rep_len, &foh->data[3], sizeof(uint16_t));
+ test_rep_len = ntohs(test_rep_len);
/* data[5]: ip.access test result */
DEBUGPC(DNM, "tst_res=%s\n", ipacc_testres_name(foh->data[5]));
@@ -150,7 +151,8 @@ static int test_rep(void *_msg)
switch (foh->data[6]) {
case NM_IPAC_EIE_FREQ_ERR_LIST:
/* data[7..8]: length of ferr_list */
- ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
+ memcpy(&ferr_list_len, &foh->data[7], sizeof(uint16_t));
+ ferr_list_len = ntohs(ferr_list_len);
/* data[9...]: frequency error list elements */
for (i = 0; i < ferr_list_len; i+= sizeof(*ife)) {
@@ -161,7 +163,8 @@ static int test_rep(void *_msg)
break;
case NM_IPAC_EIE_CHAN_USE_LIST:
/* data[7..8]: length of ferr_list */
- ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
+ memcpy(&ferr_list_len, &foh->data[7], sizeof(uint16_t));
+ ferr_list_len = ntohs(ferr_list_len);
/* data[9...]: channel usage list elements */
for (i = 0; i < ferr_list_len; i+= 2) {