summaryrefslogtreecommitdiff
path: root/lib/sdp.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-11-23 11:09:12 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2012-12-11 07:41:07 +0200
commit28cf717c04ac33e5110f0c07dea28a920cf71fe3 (patch)
treeae6ba7f66f899b73bbb8f8234ea55db1f7c71205 /lib/sdp.c
parent630d78a5b9eed4c5f3a219c93cc000ca8d3187d7 (diff)
downloadbluez-28cf717c04ac33e5110f0c07dea28a920cf71fe3.tar.gz
sdp: Fix build errors due to unaligned memory access
This fix following compilation errors on ARM. CC lib/sdp.lo lib/sdp.c: In function 'sdp_device_record_unregister_binary': lib/sdp.c:2984:11: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c:2984:11: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c: In function 'sdp_device_record_update': lib/sdp.c:3089:11: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c:3089:11: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c: In function 'sdp_process': lib/sdp.c:4139:22: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c:4146:14: error: cast increases required alignment of target type [-Werror=cast-align] lib/sdp.c:4146:14: error: cast increases required alignment of target type [-Werror=cast-align] cc1: all warnings being treated as errors make[1]: *** [lib/sdp.lo] Error 1
Diffstat (limited to 'lib/sdp.c')
-rw-r--r--lib/sdp.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/sdp.c b/lib/sdp.c
index dbffec06d..a760b733a 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -2984,7 +2984,6 @@ int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device
rsphdr = (sdp_pdu_hdr_t *) rspbuf;
p = rspbuf + sizeof(sdp_pdu_hdr_t);
- status = bt_get_unaligned((uint16_t *) p);
if (rsphdr->pdu_id == SDP_ERROR_RSP) {
/* For this case the status always is invalid record handle */
@@ -2993,6 +2992,12 @@ int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device
} else if (rsphdr->pdu_id != SDP_SVC_REMOVE_RSP) {
errno = EPROTO;
status = -1;
+ } else {
+ uint16_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
+ status = tmp;
}
end:
free(reqbuf);
@@ -3089,7 +3094,6 @@ int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp
rsphdr = (sdp_pdu_hdr_t *) rspbuf;
p = rspbuf + sizeof(sdp_pdu_hdr_t);
- status = bt_get_unaligned((uint16_t *) p);
if (rsphdr->pdu_id == SDP_ERROR_RSP) {
/* The status can be invalid sintax or invalid record handle */
@@ -3098,6 +3102,12 @@ int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp
} else if (rsphdr->pdu_id != SDP_SVC_UPDATE_RSP) {
errno = EPROTO;
status = -1;
+ } else {
+ uint16_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
+ status = tmp;
}
end:
free(reqbuf);
@@ -4139,14 +4149,18 @@ int sdp_process(sdp_session_t *session)
rsp_count = sizeof(tsrc) + sizeof(csrc) + csrc * 4;
} else {
/* point to the first csrc */
- uint16_t *pcsrc = (uint16_t *) (t->rsp_concat_buf.data + 2);
+ uint8_t *pcsrc = t->rsp_concat_buf.data + 2;
+ uint16_t tcsrc, tcsrc2;
/* FIXME: update the interface later. csrc doesn't need be passed to clients */
pdata += sizeof(uint16_t); /* point to csrc */
/* the first csrc contains the sum of partial csrc responses */
- *pcsrc += bt_get_unaligned((uint16_t *) pdata);
+ memcpy(&tcsrc, pcsrc, sizeof(tcsrc));
+ memcpy(&tcsrc2, pdata, sizeof(tcsrc2));
+ tcsrc += tcsrc2;
+ memcpy(pcsrc, &tcsrc, sizeof(tcsrc));
pdata += sizeof(uint16_t); /* point to the first handle */
rsp_count = csrc * 4;