From: Michael Stapelberg Date: Thu, 28 Apr 2011 19:44:29 +0000 (+0200) Subject: Fix unaligned memory access on sparc (Thanks David Coppa) X-Git-Tag: tree-pr3~63 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a1492839642fb109e2cca6ec2f747b246ad5ea65;p=i3%2Fi3 Fix unaligned memory access on sparc (Thanks David Coppa) --- diff --git a/src/ipc.c b/src/ipc.c index e63718cb..d0dc1920 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -597,7 +597,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) { n -= strlen(I3_IPC_MAGIC); /* The next 32 bit after the magic are the message size */ - uint32_t message_size = *((uint32_t*)message); + uint32_t message_size; + memcpy(&message_size, (uint32_t*)message, sizeof(uint32_t)); message += sizeof(uint32_t); n -= sizeof(uint32_t); @@ -607,7 +608,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) { } /* The last 32 bits of the header are the message type */ - uint32_t message_type = *((uint32_t*)message); + uint32_t message_type; + memcpy(&message_type, (uint32_t*)message, sizeof(uint32_t)); message += sizeof(uint32_t); n -= sizeof(uint32_t);