aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/gatttool.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-08-19 13:41:13 -0300
committerVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-08-19 17:28:03 -0300
commit83ac94801ba3ccc58ea74cd7d48433ca4359dc90 (patch)
tree8cf82f2bf2badb3834cc24e9a0219fc69fa62400 /attrib/gatttool.c
parentc27ffa545b6e3efbd0271d302d0531487d366bc3 (diff)
downloadbluez-83ac94801ba3ccc58ea74cd7d48433ca4359dc90.tar.gz
bluez-83ac94801ba3ccc58ea74cd7d48433ca4359dc90.tar.xz
bluez-83ac94801ba3ccc58ea74cd7d48433ca4359dc90.zip
Fix gatttool to use the alignment safe access functions
Diffstat (limited to 'attrib/gatttool.c')
-rw-r--r--attrib/gatttool.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index fa72b32b..20fe555f 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -193,29 +193,26 @@ static void primary_cb(guint8 status, const guint8 *pdu, guint16 plen,
goto done;
for (i = 0, end = 0; i < list->num; i++) {
- uint16_t *u16, length, start;
+ uint8_t *value = list->data[i];
+ uint8_t length;
+ uint16_t start;
int j;
- u16 = (uint16_t *) list->data[i];
-
/* Each element contains: attribute handle, end group handle
* and attribute value */
- length = list->len - 2 * sizeof(*u16);
- start = btohs(*u16);
- u16++;
- end = btohs(*u16);
- u16++;
+ length = list->len - 2 * sizeof(uint16_t);
+ start = att_get_u16((uint16_t *) value);
+ end = att_get_u16((uint16_t *) &value[2]);
g_print("attr handle = 0x%04x, end grp handle = 0x%04x, ",
start, end);
g_print("attr value (UUID) = ");
if (length == 2)
- g_print("0x%04x\n", btohs(*u16));
+ g_print("0x%04x\n", att_get_u16((uint16_t *)
+ &value[4]));
else {
- uint8_t *value = (uint8_t *) u16;
-
/* FIXME: pretty print 128-bit UUIDs */
- for (j = 0; j < length; j++)
+ for (j = 4; j < length; j++)
g_print("%02x ", value[j]);
g_print("\n");
}
@@ -267,28 +264,24 @@ static void char_discovered_cb(guint8 status, const guint8 *pdu, guint16 plen,
return;
for (i = 0; i < list->num; i++) {
- uint16_t *u16;
- uint8_t *u8;
+ uint8_t *value = list->data[i];
- u8 = list->data[i];
- u16 = (uint16_t *) u8;
- last = btohs(*u16);
- u16 = (void *) &u8[3];
+ last = att_get_u16((uint16_t *) value);
g_print("handle = 0x%04x, char properties = 0x%02x, "
- "char value handle = 0x%04x, ", last, u8[2],
- btohs(*u16));
+ "char value handle = 0x%04x, ", last, value[2],
+ att_get_u16((uint16_t *) &value[3]));
g_print("uuid = ");
if (list->len == 7) {
- u16 = (void *) &u8[5];
- g_print("0x%04x\n", btohs(*u16));
+ g_print("0x%04x\n", att_get_u16((uint16_t *)
+ &value[5]));
} else {
int j;
/* FIXME: pretty print 128-bit UUIDs */
for (j = 5; j < list->len; j++)
- g_print("%02x ", u8[j]);
+ g_print("%02x ", value[j]);
g_print("\n");
}
}