Received: from eggs.gnu.org ([2001:4830:134:3::10]:39152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bY5oO-0000QX-Tp for qemu-devel@nongnu.org; Fri, 12 Aug 2016 02:19:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bY5oN-0003sL-UP for qemu-devel@nongnu.org; Fri, 12 Aug 2016 02:19:20 -0400 Sender: Richard Henderson References: <1470891017-5800-1-git-send-email-famz@redhat.com> <1470891017-5800-2-git-send-email-famz@redhat.com> <2c193764-6c6a-25fe-f59d-9a5fd9fa838d@twiddle.net> <20160812020126.GC2759@al.usersys.redhat.com> From: Richard Henderson Message-ID: <05636fe4-675d-bfcc-4a8b-03831db1e7ed@twiddle.net> Date: Fri, 12 Aug 2016 07:19:12 +0100 MIME-Version: 1.0 In-Reply-To: <20160812020126.GC2759@al.usersys.redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 1/9] util: Add UUID API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng 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 08/12/2016 03:01 AM, Fam Zheng wrote: > On Thu, 08/11 23:21, Richard Henderson wrote: >> On 08/11/2016 05:50 AM, Fam Zheng wrote: >>> +void qemu_uuid_bswap(QemuUUID *uuid) >>> +{ >>> + bswap32s((uint32_t *)&uuid->data[0]); >>> + bswap16s((uint16_t *)&uuid->data[4]); >>> + bswap16s((uint16_t *)&uuid->data[6]); >>> +} >> >> You have alignment problems here too. Perhaps you really did want >> to add uint32_t (and uint16_t?) as union members to QemuUUID. > > But that may not be enough for embedded QemuUUID in a packed structure, such as > in block/vdi.c. So I'll also add an assertion here. What sort of assertion do you think is going to work? Any of the locally declared or globally declared QemuUUID variables may certainly be placed at any address by the compiler. If you really really need unaligned addresses, I strongly advise you to use the unaligned access routines in qemu/bswap.h. r~