qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V4 2/6] qcow2: add error message in qcow2_write_


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH V4 2/6] qcow2: add error message in qcow2_write_snapshots()
Date: Mon, 04 Nov 2013 12:46:15 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 11/03/2013 06:48 PM, Wenchao Xia wrote:
>> On 14.10.2013 23:52, Wenchao Xia wrote:
>>> The function still returns int since qcow2_snapshot_delete() will
>>> return the number.
>>>


>>> @@ -227,24 +239,40 @@ static int
>>> qcow2_write_snapshots(BlockDriverState *bs)
>>>
>>>           ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h));
>>>           if (ret < 0) {
>>> +            error_setg(errp,
>>> +                       "Failed in write of snapshot header at %"
>>> +                       PRIi64 " with size %" PRIu64 ": %d (%s)",
>>> +                       offset, sizeof(h), ret, strerror(-ret));
>>
>> Again, on 32 bit systems, sizeof(size_t) is generally 4 and not 8 (you
>> may want to cast sizeof(h) to int and just use %d).
>>
> 
>   Maybe caset as (int64_t)sizeof(h) to avoid possible incomplete value?

If we have objects larger than 2G (such that sizeof(h) would require
more than 31 bits), we have other issues to worry about.  Casting to int
and using %d is safe enough.

-- 
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]