On 11 January 2016 at 17:18, John Snow <js...@redhat.com> wrote: > On 01/11/2016 06:18 AM, Peter Maydell wrote: >> On 9 January 2016 at 00:51, John Snow <js...@redhat.com> 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