qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/9] util: Add UUID API


From: Fam Zheng
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/9] util: Add UUID API
Date: Thu, 11 Aug 2016 12:33:40 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]