|
From: openocd-gerrit <ope...@us...> - 2025-11-02 13:50:56
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 22afaae7fa7b4db9918e3f1265297ffa260e818e (commit)
from 1ee0499cd80582e5e4c0eafb5b0cadd3c6478f57 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 22afaae7fa7b4db9918e3f1265297ffa260e818e
Author: Lucien Dufour <luc...@du...>
Date: Wed Aug 27 14:19:18 2025 +0200
Use C99 style for loop var
Use ARRAY_SIZE() to ensure ranges are correct.
Also, the C99 style is hopefully more readable.
Change-Id: I3d6bfbdc8e723791ba14d5a32e311c61bc2dfd77
Signed-off-by: Lucien Dufour <luc...@du...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9097
Reviewed-by: Tomas Vanek <va...@fb...>
Tested-by: jenkins
Reviewed-by: zapb <de...@za...>
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index 8e03184d3..d1a81614e 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -659,15 +659,14 @@ static const struct reg_arch_type arm_reg_type = {
struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm)
{
- int num_regs = ARRAY_SIZE(arm_core_regs);
- int num_core_regs = num_regs;
+ unsigned int num_regs = ARRAY_SIZE(arm_core_regs);
+ unsigned int num_core_regs = num_regs;
if (arm->arm_vfp_version == ARM_VFP_V3)
num_regs += ARRAY_SIZE(arm_vfp_v3_regs);
struct reg_cache *cache = malloc(sizeof(struct reg_cache));
struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
struct arm_reg *reg_arch_info = calloc(num_regs, sizeof(struct arm_reg));
- int i;
if (!cache || !reg_list || !reg_arch_info) {
free(cache);
@@ -681,7 +680,7 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm)
cache->reg_list = reg_list;
cache->num_regs = 0;
- for (i = 0; i < num_core_regs; i++) {
+ for (unsigned int i = 0; i < num_core_regs; i++) {
/* Skip registers this core doesn't expose */
if (arm_core_regs[i].mode == ARM_MODE_MON
&& arm->core_type != ARM_CORE_TYPE_SEC_EXT
@@ -737,8 +736,7 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm)
cache->num_regs++;
}
- int j;
- for (i = num_core_regs, j = 0; i < num_regs; i++, j++) {
+ for (unsigned int i = num_core_regs, j = 0; i < num_regs; i++, j++) {
reg_arch_info[i].num = arm_vfp_v3_regs[j].id;
reg_arch_info[i].mode = arm_vfp_v3_regs[j].mode;
reg_arch_info[i].target = target;
@@ -1413,7 +1411,6 @@ int armv4_5_run_algorithm_inner(struct target *target,
uint32_t context[17];
uint32_t cpsr;
int exit_breakpoint_size = 0;
- int i;
int retval = ERROR_OK;
LOG_TARGET_DEBUG(target, "Running algorithm");
@@ -1442,7 +1439,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
/* save r0..pc, cpsr-or-spsr, and then cpsr-for-sure;
* they'll be restored later.
*/
- for (i = 0; i <= 16; i++) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(context); i++) {
struct reg *r;
r = &ARMV4_5_CORE_REG_MODE(arm->core_cache,
@@ -1454,7 +1451,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
}
cpsr = buf_get_u32(arm->cpsr->value, 0, 32);
- for (i = 0; i < num_mem_params; i++) {
+ for (int i = 0; i < num_mem_params; i++) {
if (mem_params[i].direction == PARAM_IN)
continue;
retval = target_write_buffer(target, mem_params[i].address, mem_params[i].size,
@@ -1463,7 +1460,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
return retval;
}
- for (i = 0; i < num_reg_params; i++) {
+ for (int i = 0; i < num_reg_params; i++) {
if (reg_params[i].direction == PARAM_IN)
continue;
@@ -1524,7 +1521,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
if (retval != ERROR_OK)
return retval;
- for (i = 0; i < num_mem_params; i++) {
+ for (int i = 0; i < num_mem_params; i++) {
if (mem_params[i].direction != PARAM_OUT) {
int retvaltemp = target_read_buffer(target, mem_params[i].address,
mem_params[i].size,
@@ -1534,7 +1531,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
}
}
- for (i = 0; i < num_reg_params; i++) {
+ for (int i = 0; i < num_reg_params; i++) {
if (reg_params[i].direction != PARAM_OUT) {
struct reg *reg = register_get_by_name(arm->core_cache,
@@ -1559,7 +1556,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
}
/* restore everything we saved before (17 or 18 registers) */
- for (i = 0; i <= 16; i++) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(context); i++) {
uint32_t regvalue;
regvalue = buf_get_u32(ARMV4_5_CORE_REG_MODE(arm->core_cache,
arm_algorithm_info->core_mode, i).value, 0, 32);
-----------------------------------------------------------------------
Summary of changes:
src/target/armv4_5.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|