vdi: change goto to loop

Finally reindent all code and change goto statements to a loop.

Acked-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Paolo Bonzini 2012-03-19 18:07:51 +01:00 committed by Kevin Wolf
parent 4eea78e634
commit eb9566d13e
1 changed files with 69 additions and 74 deletions

View File

@ -474,11 +474,11 @@ static int vdi_co_read(BlockDriverState *bs,
uint32_t block_index;
uint32_t sector_in_block;
uint32_t n_sectors;
int ret;
int ret = 0;
logout("\n");
restart:
while (ret >= 0 && nb_sectors > 0) {
block_index = sector_num / s->block_sectors;
sector_in_block = sector_num % s->block_sectors;
n_sectors = s->block_sectors - sector_in_block;
@ -506,9 +506,6 @@ restart:
nb_sectors -= n_sectors;
sector_num += n_sectors;
buf += n_sectors * SECTOR_SIZE;
if (ret >= 0 && nb_sectors > 0) {
goto restart;
}
return ret;
@ -525,11 +522,11 @@ static int vdi_co_write(BlockDriverState *bs,
uint32_t bmap_first = VDI_UNALLOCATED;
uint32_t bmap_last = VDI_UNALLOCATED;
uint8_t *block = NULL;
int ret;
int ret = 0;
logout("\n");
restart:
while (ret >= 0 && nb_sectors > 0) {
block_index = sector_num / s->block_sectors;
sector_in_block = sector_num % s->block_sectors;
n_sectors = s->block_sectors - sector_in_block;
@ -574,8 +571,6 @@ restart:
buf += n_sectors * SECTOR_SIZE;
logout("%u sectors written\n", n_sectors);
if (ret >= 0 && nb_sectors > 0) {
goto restart;
}
logout("finished data write\n");