qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH 1/7] util: Add UUID API


From: Fam Zheng
Subject: Re: [Qemu-block] [PATCH 1/7] util: Add UUID API
Date: Mon, 8 Aug 2016 14:33:17 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, 08/08 08:30, Stefan Weil wrote:
> Am 02.08.2016 um 11:18 schrieb Fam Zheng:
> [...]
> > +void qemu_uuid_generate(qemu_uuid_t out)
> > +{
> > +    /* Version 4 UUID, RFC4122 4.4. */
> > +    QEMU_BUILD_BUG_ON(sizeof(qemu_uuid_t) != 16);
> > +    *((guint32 *)out + 0) = g_random_int();
> > +    *((guint32 *)out + 1) = g_random_int();
> > +    *((guint32 *)out + 2) = g_random_int();
> > +    *((guint32 *)out + 3) = g_random_int();
> 
> I suggest using uint32_t instead of guint32.
> Up to now, nearly all QEMU code uses the POSIX data types.

This is merely to keep consistent with the g_random_int() return type.  If the
two types had any chance to vary (surely they don't), the uint32_t way would
look like this:

        *((uint32_t *)out + 0) = (uint32_t)g_random_int();

So I think the current way is fine.

Fam



reply via email to

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