From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIgOm-0005sJ-RH for qemu-devel@nongnu.org; Mon, 11 Jan 2016 12:36:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIgOm-0006oa-1j for qemu-devel@nongnu.org; Mon, 11 Jan 2016 12:36:56 -0500 Received: from mail-vk0-x22e.google.com ([2607:f8b0:400c:c05::22e]:36318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIgOl-0006oU-QQ for qemu-devel@nongnu.org; Mon, 11 Jan 2016 12:36:55 -0500 Received: by mail-vk0-x22e.google.com with SMTP id n1so73888113vkb.3 for ; Mon, 11 Jan 2016 09:36:55 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <5693E3D9.60401@redhat.com> References: <1452300718-10660-1-git-send-email-jsnow@redhat.com> <5693E3D9.60401@redhat.com> From: Peter Maydell Date: Mon, 11 Jan 2016 17:36:35 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PULL 00/11] Ide patches List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: QEMU Developers On 11 January 2016 at 17:18, John Snow wrote: > On 01/11/2016 06:18 AM, Peter Maydell wrote: >> On 9 January 2016 at 00:51, John Snow wrote: >> This kind of thing: >> > > "This kind of thing" as one might say while holding up a rotting fish > with just two fingers, held at arm's length. Not the intended tone :-) >> unsigned char *cbd = cmd->atapi_cmd; >> uint32_t *lba32; >> >> lba32 = (uint32_t *)&(cbd[2]); >> *lba32 = cpu_to_be32(lba); >> >> isn't valid. You probably want >> stl_be_p(&cbd[2], lba); > Thanks for the pointer. Out of curiosity, is there no standard way to > perform this kind of operation in C? I want to adjust my bad habits. In > QEMU I can remember to use these macros now that I know they're there, > but not sure what I'd use in other projects. memcpy directly? You can use memcpy, or you can hand-assemble values in and out of byte arrays, I think. memcpy() is generally recommended, because the compiler does a decent job with it. thanks -- PMM