summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-11-17 22:33:32 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-11-18 10:30:31 +0100
commit97f243938906f8704dea395d2f68b880abce8779 (patch)
treec2638fed18c640bc2f59642ad9793ffb9d8df004
parent2e87407eb91407e64f3d23de07b9dc91735a6a49 (diff)
downloadupower-97f243938906f8704dea395d2f68b880abce8779.tar.gz
hidpp-device: avoid unaligned memory access
Fixes a -Wcast-align warning and a -fsanitize=undefined error. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--src/linux/hidpp-device.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 19a0ae6..106f55a 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -818,7 +818,7 @@ hidpp_device_refresh (HidppDevice *device,
/* get serial number, this can be queried from the receiver */
if ((refresh_flags & HIDPP_REFRESH_FLAGS_SERIAL) > 0) {
- guint32 *serialp;
+ guint32 serial;
msg.type = HIDPP_MSG_TYPE_SHORT;
msg.device_idx = HIDPP_RECEIVER_ADDRESS;
@@ -834,8 +834,8 @@ hidpp_device_refresh (HidppDevice *device,
if (!ret)
goto out;
- serialp = (guint32 *) &msg.l.params[1];
- priv->serial = g_strdup_printf ("%08X", g_ntohl(*serialp));
+ memcpy (&serial, msg.l.params + 1, sizeof(serial));
+ priv->serial = g_strdup_printf ("%08X", g_ntohl(serial));
}
/* get battery status */