On 9/5/19 2:44 AM, Denis Plotnikov wrote:
>>> + >>> + s_size = be32_to_cpu(*(const uint32_t *) src); >> As written, this looks like you may be dereferencing an unaligned >> pointer. It so happens that be32_to_cpu() applies & to your * to get >> back at the raw pointer, and then is careful to handle unaligned >> pointers, so it works; but it would look a lot nicer as merely: >> >> s_size = be32_to_cpu(src); > > yes, but I can't use be32_to_cpu(*src) since src is a void pointer Then we need the correct ld*_p function; sorry for leading you down the wrong path. Looks like the right one is: s_size = ldl_be_p(src) (include/qemu/bswap.h has some good comments, but you have to know they exist...) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature