qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v5 3/3] qcow2: add zstd cluster compression


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH v5 3/3] qcow2: add zstd cluster compression
Date: Thu, 5 Sep 2019 09:31:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]