[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 54/56] softmmu/device_tree: Fixup local variables shadowing
From: |
Markus Armbruster |
Subject: |
[PULL 54/56] softmmu/device_tree: Fixup local variables shadowing |
Date: |
Fri, 29 Sep 2023 10:50:51 +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-5-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
softmmu/device_tree.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index 30aa3aea9f..eb5166ca36 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -418,9 +418,9 @@ int qemu_fdt_setprop_string_array(void *fdt, const char
*node_path,
}
p = str = g_malloc0(total_len);
for (i = 0; i < len; i++) {
- int len = strlen(array[i]) + 1;
- pstrcpy(p, len, array[i]);
- p += len;
+ int offset = strlen(array[i]) + 1;
+ pstrcpy(p, offset, array[i]);
+ p += offset;
}
ret = qemu_fdt_setprop(fdt, node_path, prop, str, total_len);
--
2.41.0
- [PULL 24/56] sysemu/device_tree: Clean up local variable shadowing, (continued)
- [PULL 24/56] sysemu/device_tree: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 27/56] hw/core/machine: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 44/56] aspeed: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [PULL 43/56] aspeed/i2c: Clean up local variable shadowing, Markus Armbruster, 2023/09/29
- [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 <=
- [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, 2023/09/29
- [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