qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified of


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset
Date: Mon, 3 Oct 2016 10:12:50 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 10/03/2016 08:50 AM, Tomáš Golembiovský wrote:
>> Additional context:
>>
>>     off_t dev_offset = 0;
>>
>>     off_t fd_size;
>>
>>>  
>>> +    if (dev_offset >= fd_size) {
>>> +        error_report("Offset (%lu) has to be smaller than the image size 
>>> (%lu)",
>>> +                     dev_offset, fd_size);  
>>
>> Whoops, this fails to compile on 32-bit platforms.  %lu is not
>> necessarily synonymous with off_t values.
> 
> After some digging I figured off_t is in fact signed type. That makes
> the formatting wrong everywhere. Unfortunately I didn't find any good
> definition of the type. Any suggestion what format flag should I use? Or
> should I just use a temporary variable of known size for that?

Easiest is probably casting to a type with an easier format flag, as in
either of:

error_report("offset %lld ...", (long long) dev_offset)
error_report("offset %jd ...", (intmax_t) dev_offset)

off_t is particularly problematic because there is no magic % sequence
reserved for it, nothing in <inttypes.h> for it, and there are 32-bit
compilation environments where it is still 32 bits (although qemu
prefers to explicitly request large-file compilation so that off_t is
always 64 bits)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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