aboutsummaryrefslogtreecommitdiff
path: root/src/target/register.c
diff options
context:
space:
mode:
authorMarek Vrbka <marek.vrbka@codasip.com>2023-06-06 15:32:09 +0200
committerTomas Vanek <vanekt@fbl.cz>2023-08-03 20:24:16 +0000
commitbab8b8c9eb7c0e892eaa375cb1f388a75165c627 (patch)
tree5a53fe962bf25df92c01a29ea472737306b02450 /src/target/register.c
parenta5108240f9e12633fea400f92d96cc75e03c86ca (diff)
downloadriscv-openocd-bab8b8c9eb7c0e892eaa375cb1f388a75165c627.zip
riscv-openocd-bab8b8c9eb7c0e892eaa375cb1f388a75165c627.tar.gz
riscv-openocd-bab8b8c9eb7c0e892eaa375cb1f388a75165c627.tar.bz2
register: refactor register_cache_invalidate()
register_cache_invalidate() is written a way which uses pointer arithmetic, which makes it harder to read. This patch replaces it with more readable way to iterate over array of structs. Change-Id: Ia420f70a3bb6998c690c8c600c71301dca9f9dbf Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7735 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
Diffstat (limited to 'src/target/register.c')
-rw-r--r--src/target/register.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/target/register.c b/src/target/register.c
index 2287125..e4f22f8 100644
--- a/src/target/register.c
+++ b/src/target/register.c
@@ -93,9 +93,8 @@ void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *c
/** Marks the contents of the register cache as invalid (and clean). */
void register_cache_invalidate(struct reg_cache *cache)
{
- struct reg *reg = cache->reg_list;
-
- for (unsigned int n = cache->num_regs; n != 0; n--, reg++) {
+ for (unsigned int n = 0; n < cache->num_regs; n++) {
+ struct reg *reg = &cache->reg_list[n];
if (!reg->exist)
continue;
reg->valid = false;