[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2
From: |
Alberto Garcia |
Subject: |
Re: [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty() |
Date: |
Tue, 05 May 2015 15:06:52 +0200 |
User-agent: |
Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) |
On Fri 01 May 2015 04:31:52 PM CEST, Stefan Hajnoczi wrote:
>> int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
>> {
>> - int i;
>> + int i = (*table - c->table_array) / c->table_size;
>>
>> - for (i = 0; i < c->size; i++) {
>> - if (table_addr(c, i) == *table) {
>> - goto found;
>> - }
>> + if (c->entries[i].offset == 0) {
>> + return -ENOENT;
>> }
>> - return -ENOENT;
>>
>> -found:
>> c->entries[i].ref--;
>> *table = NULL;
>>
>
> When is this function called with a bogus table pointer?
I also could not image any such scenario, but I decided to be
conservative and keep the error handling code. I'll double check all
places where it's used and remove the relevant code.
Berto