This is an automated email from Gerrit. "zapb <d...@zapb.de>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9007
-- gerrit commit d9a192f4e37ea32923a4687b9514dca775292a19 Author: Marc Schink <d...@zapb.de> Date: Sun Jul 20 11:33:38 2025 +0000 target: Make use of str_enabled_disabled() The data type changes introduced in [1,2] lead to implicit casts from a boolean to an integer value in the string selection between "enabled" and "disabled". Use str_enabled_disabled() to get rid of this implicit cast. [1] https://review.openocd.org/c/openocd/+/8988 [2] https://review.openocd.org/c/openocd/+/8992 Change-Id: Ia98abdd43b42f394f5bf0aa845017dfbb0e087fd Signed-off-by: Marc Schink <d...@zapb.de> diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 933b49bebc..702d6cfb10 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -14,6 +14,7 @@ #include "arm720t.h" #include <helper/time_support.h> +#include <helper/string_choices.h> #include "target_type.h" #include "register.h" #include "arm_opcodes.h" @@ -227,14 +228,10 @@ static int arm720t_arch_state(struct target *target) { struct arm720t_common *arm720t = target_to_arm720(target); - static const char *state[] = { - "disabled", "enabled" - }; - arm_arch_state(target); LOG_USER("MMU: %s, Cache: %s", - state[arm720t->armv4_5_mmu.mmu_enabled], - state[arm720t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled]); + str_enabled_disabled(arm720t->armv4_5_mmu.mmu_enabled), + str_enabled_disabled(arm720t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled)); return ERROR_OK; } diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 4dd5763539..67c212e0bf 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -12,6 +12,7 @@ #include "arm920t.h" #include <helper/time_support.h> +#include <helper/string_choices.h> #include "target_type.h" #include "register.h" #include "arm_opcodes.h" @@ -509,10 +510,6 @@ static int arm920t_verify_pointer(struct command_invocation *cmd, /** Logs summary of ARM920 state for a halted target. */ int arm920t_arch_state(struct target *target) { - static const char *state[] = { - "disabled", "enabled" - }; - struct arm920t_common *arm920t = target_to_arm920(target); if (arm920t->common_magic != ARM920T_COMMON_MAGIC) { @@ -522,9 +519,9 @@ int arm920t_arch_state(struct target *target) arm_arch_state(target); LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s", - state[arm920t->armv4_5_mmu.mmu_enabled], - state[arm920t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled], - state[arm920t->armv4_5_mmu.armv4_5_cache.i_cache_enabled]); + str_enabled_disabled(arm920t->armv4_5_mmu.mmu_enabled), + str_enabled_disabled(arm920t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled), + str_enabled_disabled(arm920t->armv4_5_mmu.armv4_5_cache.i_cache_enabled)); return ERROR_OK; } diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 587f25061f..a3fff2ae5e 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -14,6 +14,7 @@ #include "arm926ejs.h" #include <helper/time_support.h> +#include <helper/string_choices.h> #include "target_type.h" #include "register.h" #include "arm_opcodes.h" @@ -505,10 +506,6 @@ static int arm926ejs_verify_pointer(struct command_invocation *cmd, /** Logs summary of ARM926 state for a halted target. */ int arm926ejs_arch_state(struct target *target) { - static const char *state[] = { - "disabled", "enabled" - }; - struct arm926ejs_common *arm926ejs = target_to_arm926(target); if (arm926ejs->common_magic != ARM926EJS_COMMON_MAGIC) { @@ -518,9 +515,9 @@ int arm926ejs_arch_state(struct target *target) arm_arch_state(target); LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s", - state[arm926ejs->armv4_5_mmu.mmu_enabled], - state[arm926ejs->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled], - state[arm926ejs->armv4_5_mmu.armv4_5_cache.i_cache_enabled]); + str_enabled_disabled(arm926ejs->armv4_5_mmu.mmu_enabled), + str_enabled_disabled(arm926ejs->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled), + str_enabled_disabled(arm926ejs->armv4_5_mmu.armv4_5_cache.i_cache_enabled)); return ERROR_OK; } diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 2bbafd420f..c5829095e5 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -18,6 +18,7 @@ #include "register.h" #include <helper/binarybuffer.h> +#include <helper/string_choices.h> #include <helper/command.h> #include <stdlib.h> @@ -480,10 +481,6 @@ int armv7a_init_arch_info(struct target *target, struct armv7a_common *armv7a) int armv7a_arch_state(struct target *target) { - static const char *state[] = { - "disabled", "enabled" - }; - struct armv7a_common *armv7a = target_to_armv7a(target); struct arm *arm = &armv7a->arm; @@ -496,13 +493,13 @@ int armv7a_arch_state(struct target *target) if (armv7a->is_armv7r) { LOG_TARGET_USER(target, "D-Cache: %s, I-Cache: %s", - state[armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled], - state[armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled]); + str_enabled_disabled(armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled), + str_enabled_disabled(armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled)); } else { LOG_TARGET_USER(target, "MMU: %s, D-Cache: %s, I-Cache: %s", - state[armv7a->armv7a_mmu.mmu_enabled], - state[armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled], - state[armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled]); + str_enabled_disabled(armv7a->armv7a_mmu.mmu_enabled), + str_enabled_disabled(armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled), + str_enabled_disabled(armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled)); } if (arm->core_mode == ARM_MODE_ABT) diff --git a/src/target/xscale.c b/src/target/xscale.c index 783628b128..50e03f202e 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -22,6 +22,7 @@ #include "arm_simulator.h" #include "arm_disassembler.h" #include <helper/time_support.h> +#include <helper/string_choices.h> #include "register.h" #include "image.h" #include "arm_opcodes.h" @@ -774,10 +775,6 @@ static int xscale_arch_state(struct target *target) struct xscale_common *xscale = target_to_xscale(target); struct arm *arm = &xscale->arm; - static const char *state[] = { - "disabled", "enabled" - }; - static const char *arch_dbg_reason[] = { "", "\n(processor reset)", "\n(trace buffer full)" }; @@ -789,9 +786,9 @@ static int xscale_arch_state(struct target *target) arm_arch_state(target); LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s%s", - state[xscale->armv4_5_mmu.mmu_enabled], - state[xscale->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled], - state[xscale->armv4_5_mmu.armv4_5_cache.i_cache_enabled], + str_enabled_disabled(xscale->armv4_5_mmu.mmu_enabled), + str_enabled_disabled(xscale->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled), + str_enabled_disabled(xscale->armv4_5_mmu.armv4_5_cache.i_cache_enabled), arch_dbg_reason[xscale->arch_debug_reason]); return ERROR_OK; --