From: Alistair Francis <alistair23@gmail.com>
To: david@gibson.dropbear.id.au, qemu-riscv@nongnu.org,
qemu-devel@nongnu.org
Cc: bmeng.cn@gmail.com, alistair.francis@wdc.com,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
palmer@dabbelt.com, alistair23@gmail.com,
dbarboza@ventanamicro.com,
Alistair Francis <Alistair.Francis@wdc.com>,
liweiwei@iscas.ac.cn, Bin Meng <bin.meng@windriver.com>
Subject: [PATCH 3/4] target/riscv: vector_helper: Fixup local variables shadowing
Date: Mon, 25 Sep 2023 14:30:22 +1000 [thread overview]
Message-ID: <20230925043023.71448-4-alistair.francis@wdc.com> (raw)
In-Reply-To: <20230925043023.71448-1-alistair.francis@wdc.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>
---
target/riscv/vector_helper.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 3fb05cc3d6..cba02c1320 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -516,7 +516,7 @@ ProbeSuccess:
k++;
continue;
}
- target_ulong addr = base + ((i * nf + k) << log2_esz);
+ addr = base + ((i * nf + k) << log2_esz);
ldst_elem(env, adjust_addr(env, addr), i + k * max_elems, vd, ra);
k++;
}
@@ -4791,9 +4791,10 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \
uint32_t total_elems = vext_get_total_elems(env, desc, esz); \
uint32_t vta = vext_vta(desc); \
uint32_t vma = vext_vma(desc); \
- target_ulong i_max, i; \
+ target_ulong i_max, i_min, i; \
\
- i_max = MAX(MIN(s1 < vlmax ? vlmax - s1 : 0, vl), env->vstart); \
+ i_min = MIN(s1 < vlmax ? vlmax - s1 : 0, vl); \
+ i_max = MAX(i_min, env->vstart); \
for (i = env->vstart; i < i_max; ++i) { \
if (!vm && !vext_elem_mask(v0, i)) { \
/* set masked-off elements to 1s */ \
--
2.41.0
next prev parent reply other threads:[~2023-09-25 4:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 4:30 [PATCH 0/4] RISC-V: Work towards enabling -Wshadow=local Alistair Francis
2023-09-25 4:30 ` [PATCH 1/4] hw/riscv: opentitan: Fixup local variables shadowing Alistair Francis
2023-09-25 9:08 ` Daniel Henrique Barboza
2023-09-25 4:30 ` [PATCH 2/4] target/riscv: cpu: " Alistair Francis
2023-09-25 9:09 ` Daniel Henrique Barboza
2023-09-25 4:30 ` Alistair Francis [this message]
2023-09-25 9:09 ` [PATCH 3/4] target/riscv: vector_helper: " Daniel Henrique Barboza
2023-09-25 4:30 ` [PATCH 4/4] softmmu/device_tree: " Alistair Francis
2023-09-25 9:10 ` Daniel Henrique Barboza
2023-09-25 9:11 ` [PATCH 0/4] RISC-V: Work towards enabling -Wshadow=local Daniel Henrique Barboza
2023-09-29 6:56 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230925043023.71448-4-alistair.francis@wdc.com \
--to=alistair23@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=bmeng.cn@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=dbarboza@ventanamicro.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).