[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Rewrite qcow2_alloc_bytes()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Rewrite qcow2_alloc_bytes() |
Date: |
Wed, 04 Feb 2015 15:07:50 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 02/04/2015 02:59 PM, Eric Blake wrote:
>> qcow2_alloc_bytes() is a function with insufficient error handling and
>> an unnecessary goto. This patch rewrites it.
>> - redo:
>> +
>> free_in_cluster = s->cluster_size -
>> offset_into_cluster(s, s->free_byte_offset);
>
> Based on [0], free_in_cluster is either s->cluster_size
> (s->free_byte_offset was 0 and we have no tail) or smaller than
> s->cluster_size (s->free_byte_offset was non-zero).
Maybe even worth an assert?
assert(free_in_cluster < s->cluster_size + !s->free_byte_offset);
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature