[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/56] block/vdi: Clean up local variable shadowing
From: |
Markus Armbruster |
Subject: |
[PULL 05/56] block/vdi: Clean up local variable shadowing |
Date: |
Fri, 29 Sep 2023 10:50:02 +0200 |
Local variables shadowing other local variables or parameters make the
code needlessly hard to understand. Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230921121312.1301864-6-armbru@redhat.com>
---
block/vdi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index 6c35309e04..934e1b849b 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -634,7 +634,6 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset,
int64_t bytes,
bmap_entry = le32_to_cpu(s->bmap[block_index]);
if (!VDI_IS_ALLOCATED(bmap_entry)) {
/* Allocate new block and write to it. */
- uint64_t data_offset;
qemu_co_rwlock_upgrade(&s->bmap_lock);
bmap_entry = le32_to_cpu(s->bmap[block_index]);
if (VDI_IS_ALLOCATED(bmap_entry)) {
@@ -700,7 +699,7 @@ nonallocating_write:
/* One or more new blocks were allocated. */
VdiHeader *header;
uint8_t *base;
- uint64_t offset;
+ uint64_t bmap_offset;
uint32_t n_sectors;
g_free(block);
@@ -723,11 +722,11 @@ nonallocating_write:
bmap_first /= (SECTOR_SIZE / sizeof(uint32_t));
bmap_last /= (SECTOR_SIZE / sizeof(uint32_t));
n_sectors = bmap_last - bmap_first + 1;
- offset = s->bmap_sector + bmap_first;
+ bmap_offset = s->bmap_sector + bmap_first;
base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE;
logout("will write %u block map sectors starting from entry %u\n",
n_sectors, bmap_first);
- ret = bdrv_co_pwrite(bs->file, offset * SECTOR_SIZE,
+ ret = bdrv_co_pwrite(bs->file, bmap_offset * SECTOR_SIZE,
n_sectors * SECTOR_SIZE, base, 0);
}
--
2.41.0
- [PULL 03/56] ui: Clean up local variable shadowing, (continued)
- [PULL 03/56] ui: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 28/56] hw/intc/openpic: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 30/56] pnv/psi: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 18/56] hw/microblaze: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 19/56] hw/nios2: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 14/56] hw/arm/armv7m: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 06/56] block: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 22/56] util/vhost-user-server: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 31/56] spapr: Clean up local variable shadowing in spapr_dt_cpus(), Markus Armbruster, 2023/09/29
- [PULL 45/56] aspeed/i3c: Rename variable shadowing a local, Markus Armbruster, 2023/09/29
- [PULL 05/56] block/vdi: Clean up local variable shadowing,
Markus Armbruster <=
- [PULL 11/56] target/mips: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 15/56] hw/arm/virt: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 09/56] target/arm/tcg: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 04/56] block/dirty-bitmap: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 02/56] migration: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 49/56] seccomp: avoid shadowing of 'action' variable, Markus Armbruster, 2023/09/29
- [PULL 47/56] intel_iommu: Fix shadow local variables on "size", Markus Armbruster, 2023/09/29
- [PULL 12/56] target/m68k: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 34/56] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector(), Markus Armbruster, 2023/09/29
- [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local, Markus Armbruster, 2023/09/29