On 08/12/2016 03:01 AM, Fam Zheng wrote:
On Thu, 08/11 23:21, Richard Henderson wrote:
On 08/11/2016 05:50 AM, Fam Zheng wrote:
+void qemu_uuid_bswap(QemuUUID *uuid)
+{
+    bswap32s((uint32_t *)&uuid->data[0]);
+    bswap16s((uint16_t *)&uuid->data[4]);
+    bswap16s((uint16_t *)&uuid->data[6]);
+}

You have alignment problems here too.  Perhaps you really did want
to add uint32_t (and uint16_t?) as union members to QemuUUID.

But that may not be enough for embedded QemuUUID in a packed structure, such as
in block/vdi.c. So I'll also add an assertion here.

What sort of assertion do you think is going to work?

Any of the locally declared or globally declared QemuUUID variables may certainly be placed at any address by the compiler.

If you really really need unaligned addresses, I strongly advise you to use the unaligned access routines in qemu/bswap.h.


r~


Reply via email to