On Wed, 08/10 16:25, Richard Henderson wrote:
> On 08/09/2016 12:19 PM, Fam Zheng wrote:
> >+/* Version 4 UUID (pseudo random numbers), RFC4122 4.4. */
> >+
> >+typedef struct {
> >+ unsigned char data[16];
> >+} QemuUUID;
> ...
> >+void qemu_uuid_generate(QemuUUID *uuid)
> >+{
> >+ int i;
> >+ uint32_t *out = (uint32_t *)&uuid->data[0];
>
> You can't do this cast without adding alignment on the QemuUUID structure.
>
> >+ for (i = 0; i < 4; ++i) {
> >+ out[i] = g_random_int();
> >+ }
>
> But if there's no other need for uint32_t access to QemuUUID, you could either
>
> (1) write into a local uint32_t[4] array and memcpy over, or
> (2) use stl_he_p from qemu/bswap.h, which will handle the unaligned store.
>
Will change to local array. Thanks!
Fam