summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-09-13 15:55:43 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-13 15:55:43 +0200
commitae35c47cfa4d97d823a356276125ac0db7b89ead (patch)
tree3e2cf61a22316c16ae4512295f126d9560e123ae /src
parent16e3906899910187ab2649816c7b8e597e00ab0d (diff)
downloadneard-ae35c47cfa4d97d823a356276125ac0db7b89ead.tar.gz
neard-ae35c47cfa4d97d823a356276125ac0db7b89ead.tar.bz2
neard-ae35c47cfa4d97d823a356276125ac0db7b89ead.zip
bluetooth: Fix OOB alignement issue
Use the BlueZ alignement macro access for that matter. It could eventually be exported through near.h if needed.
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bluetooth.c b/src/bluetooth.c
index aa044ba..60c65e3 100644
--- a/src/bluetooth.c
+++ b/src/bluetooth.c
@@ -63,6 +63,14 @@
#define COD_SIZE 3
#define OOB_SP_SIZE 16
+#define get_unaligned(ptr) \
+({ \
+ struct __attribute__((packed)) { \
+ typeof(*(ptr)) __v; \
+ } *__p = (typeof(__p)) (ptr); \
+ __p->__v; \
+})
+
struct near_oob_data {
char *def_adapter;
@@ -628,7 +636,8 @@ int __near_bluetooth_parse_oob_record(uint8_t version, uint8_t *bt_data,
* the NDEF forum NDEF spec define a payload length as single
* byte (and the payload size IS the oob data size).
*/
- bt_oob_data_size = GUINT16_FROM_LE(*(uint16_t *) bt_data);
+ bt_oob_data_size =
+ GUINT16_FROM_LE(get_unaligned((uint16_t *) bt_data));
if (bt_oob_data_size > 0xFF) /* Big Endian */
bt_oob_data_size = GUINT16_FROM_BE(bt_oob_data_size);