From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXRBF-00008b-Pz for qemu-devel@nongnu.org; Wed, 10 Aug 2016 06:56:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXRBE-0001cC-Ds for qemu-devel@nongnu.org; Wed, 10 Aug 2016 06:56:13 -0400 Sender: Richard Henderson References: <1470725407-5051-1-git-send-email-famz@redhat.com> <1470725407-5051-2-git-send-email-famz@redhat.com> From: Richard Henderson Message-ID: <42d478eb-5577-e318-f33e-b1a3c640a3ff@twiddle.net> Date: Wed, 10 Aug 2016 16:25:56 +0530 MIME-Version: 1.0 In-Reply-To: <1470725407-5051-2-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: Fam Zheng , qemu-devel@nongnu.org Cc: 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 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. r~