blob/blobmsg: use 32 bit load/store for 64 bit access, unaligned attributes cause...
[project/libubox.git] / blob.h
diff --git a/blob.h b/blob.h
index a8ddce9..557899d 100644 (file)
--- a/blob.h
+++ b/blob.h
@@ -191,8 +191,10 @@ blob_get_u32(const struct blob_attr *attr)
 static inline uint64_t
 blob_get_u64(const struct blob_attr *attr)
 {
-       uint64_t *tmp = (uint64_t*)attr->data;
-       return be64_to_cpu(*tmp);
+       uint32_t *ptr = blob_data(attr);
+       uint64_t tmp = ((uint64_t) be32_to_cpu(ptr[0])) << 32;
+       tmp |= be32_to_cpu(ptr[1]);
+       return tmp;
 }
 
 static inline int8_t