[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 52/56] target/riscv: cpu: Fixup local variables shadowing
From: |
Markus Armbruster |
Subject: |
[PULL 52/56] target/riscv: cpu: Fixup local variables shadowing |
Date: |
Fri, 29 Sep 2023 10:50:49 +0200 |
From: Alistair Francis <alistair23@gmail.com>
Local variables shadowing other local variables or parameters make the
code needlessly hard to understand. Bugs love to hide in such code.
Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
on polling error".
This patch removes the local variable shadowing. Tested by adding:
--extra-cflags='-Wshadow=local -Wno-error=shadow=local
-Wno-error=shadow=compatible-local'
To configure
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230925043023.71448-3-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
target/riscv/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index f227c7664e..4140899c52 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -704,7 +704,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int
flags)
CSR_MPMMASK,
};
- for (int i = 0; i < ARRAY_SIZE(dump_csrs); ++i) {
+ for (i = 0; i < ARRAY_SIZE(dump_csrs); ++i) {
int csrno = dump_csrs[i];
target_ulong val = 0;
RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
@@ -747,7 +747,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int
flags)
CSR_VTYPE,
CSR_VLENB,
};
- for (int i = 0; i < ARRAY_SIZE(dump_rvv_csrs); ++i) {
+ for (i = 0; i < ARRAY_SIZE(dump_rvv_csrs); ++i) {
int csrno = dump_rvv_csrs[i];
target_ulong val = 0;
RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
--
2.41.0
- [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize(), (continued)
- [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize(), Markus Armbruster, 2023/09/29
- [PULL 37/56] test-throttle: don't shadow 'index' variable in do_test_accounting(), Markus Armbruster, 2023/09/29
- [PULL 46/56] aspeed/timer: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 56/56] disas/m68k: clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 55/56] hw/nvme: Clean up local variable shadowing in nvme_ns_init(), Markus Armbruster, 2023/09/29
- [PULL 50/56] qemu-nbd: changes towards enabling -Wshadow=local, Markus Armbruster, 2023/09/29
- [PULL 54/56] softmmu/device_tree: Fixup local variables shadowing, Markus Armbruster, 2023/09/29
- [PULL 51/56] hw/riscv: opentitan: Fixup local variables shadowing, Markus Armbruster, 2023/09/29
- [PULL 40/56] hw/misc/arm_sysctl.c: Avoid shadowing local variable, Markus Armbruster, 2023/09/29
- [PULL 42/56] hw/arm/smmuv3-internal.h: Don't use locals in statement macros, Markus Armbruster, 2023/09/29
- [PULL 52/56] target/riscv: cpu: Fixup local variables shadowing,
Markus Armbruster <=
- [PULL 53/56] target/riscv: vector_helper: Fixup local variables shadowing, Markus Armbruster, 2023/09/29
- [PULL 48/56] crypto: remove shadowed 'ret' variable, Markus Armbruster, 2023/09/29