From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXhnW-0003S2-Cy for qemu-devel@nongnu.org; Thu, 11 Aug 2016 00:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXhnU-0007ar-K4 for qemu-devel@nongnu.org; Thu, 11 Aug 2016 00:40:49 -0400 Date: Thu, 11 Aug 2016 12:33:40 +0800 From: Fam Zheng Message-ID: <20160811043340.GA11440@al.usersys.redhat.com> References: <1470725407-5051-1-git-send-email-famz@redhat.com> <1470725407-5051-2-git-send-email-famz@redhat.com> <42d478eb-5577-e318-f33e-b1a3c640a3ff@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42d478eb-5577-e318-f33e-b1a3c640a3ff@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v3 1/9] util: Add UUID API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org, sw@weilnetz.de, jcody@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, pbonzini@redhat.com, mreitz@redhat.com 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