From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWeEb-0007je-PD for qemu-devel@nongnu.org; Mon, 08 Aug 2016 02:40:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWeEa-0007gb-Tx for qemu-devel@nongnu.org; Mon, 08 Aug 2016 02:40:25 -0400 Date: Mon, 8 Aug 2016 14:33:17 +0800 From: Fam Zheng Message-ID: <20160808063317.GA24378@al.usersys.redhat.com> References: <1470129518-21087-1-git-send-email-famz@redhat.com> <1470129518-21087-2-git-send-email-famz@redhat.com> <78def4e2-aec9-d7c7-6e35-4a6c9da23057@weilnetz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <78def4e2-aec9-d7c7-6e35-4a6c9da23057@weilnetz.de> Subject: Re: [Qemu-devel] [PATCH 1/7] util: Add UUID API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, kwolf@redhat.com, mreitz@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, qemu-block@nongnu.org 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