summaryrefslogtreecommitdiff
path: root/src/sdpd-service.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-09-04 16:41:29 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-09-05 12:23:22 +0300
commit809b7c317f5270b278d2cb29c69e056c815cad01 (patch)
treed2e9ddad69d833a30ad56873e0c117826b6ed889 /src/sdpd-service.c
parent3b2112823ce123ed8b775889de52db586bb72b69 (diff)
downloadbluez-809b7c317f5270b278d2cb29c69e056c815cad01.tar.gz
sdpd-service: Fix build errors due to unaligned memory access
This fix number of build errors on ARM similar to one below. CC src/bluetooth-sdpd-service.o src/sdpd-service.c: In function service_remove_req: src/sdpd-service.c:517:20: error: cast increases required alignment of target type [-Werror=cast-align] src/sdpd-service.c:517:20: error: cast increases required alignment of target type [-Werror=cast-align] src/sdpd-service.c:536:2: error: cast increases required alignment of target type [-Werror=cast-align] src/sdpd-service.c:536:2: error: cast increases required alignment of target type [-Werror=cast-align] cc1: all warnings being treated as errors
Diffstat (limited to 'src/sdpd-service.c')
-rw-r--r--src/sdpd-service.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 39e05ab18..b43ddc22f 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -317,7 +317,7 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p,
return NULL;
}
- lookAheadAttrId = ntohs(bt_get_unaligned((uint16_t *) (p + sizeof(uint8_t))));
+ lookAheadAttrId = bt_get_be16(p + sizeof(uint8_t));
SDPDBG("Look ahead attr id : %d", lookAheadAttrId);
@@ -327,9 +327,8 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p,
SDPDBG("Unexpected end of packet");
return NULL;
}
- handle = ntohl(bt_get_unaligned((uint32_t *) (p +
- sizeof(uint8_t) + sizeof(uint16_t) +
- sizeof(uint8_t))));
+ handle = bt_get_be32(p + sizeof(uint8_t) + sizeof(uint16_t) +
+ sizeof(uint8_t));
SDPDBG("SvcRecHandle : 0x%x", handle);
rec = sdp_record_find(handle);
} else if (handleExpected != 0xffffffff)
@@ -363,7 +362,7 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p,
seqlen, localExtractedLength);
dtd = *(uint8_t *) p;
- attrId = ntohs(bt_get_unaligned((uint16_t *) (p + attrSize)));
+ attrId = bt_get_be16(p + attrSize);
attrSize += sizeof(uint16_t);
SDPDBG("DTD of attrId : %d Attr id : 0x%x", dtd, attrId);
@@ -454,13 +453,13 @@ success:
update_db_timestamp();
/* Build a rsp buffer */
- bt_put_unaligned(htonl(rec->handle), (uint32_t *) rsp->data);
+ bt_put_be32(rec->handle, rsp->data);
rsp->data_size = sizeof(uint32_t);
return 0;
invalid:
- bt_put_unaligned(htons(SDP_INVALID_SYNTAX), (uint16_t *) rsp->data);
+ bt_put_be16(SDP_INVALID_SYNTAX, rsp->data);
rsp->data_size = sizeof(uint16_t);
return -1;
@@ -475,7 +474,7 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
int status = 0, scanned = 0;
uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
int bufsize = req->len - sizeof(sdp_pdu_hdr_t);
- uint32_t handle = ntohl(bt_get_unaligned((uint32_t *) p));
+ uint32_t handle = bt_get_be32(p);
SDPDBG("Svc Rec Handle: 0x%x", handle);
@@ -503,7 +502,7 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
done:
p = rsp->data;
- bt_put_unaligned(htons(status), (uint16_t *) p);
+ bt_put_be16(status, p);
rsp->data_size = sizeof(uint16_t);
return status;
}
@@ -514,7 +513,7 @@ done:
int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
{
uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
- uint32_t handle = ntohl(bt_get_unaligned((uint32_t *) p));
+ uint32_t handle = bt_get_be32(p);
sdp_record_t *rec;
int status = 0;
@@ -533,7 +532,7 @@ int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
}
p = rsp->data;
- bt_put_unaligned(htons(status), (uint16_t *) p);
+ bt_put_be16(status, p);
rsp->data_size = sizeof(uint16_t);
return status;