2
0
mirror of git://git.code.sf.net/p/openocd/code synced 2025-08-16 17:57:47 +10:00

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 <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9007
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Marc Schink 2025-07-20 11:33:38 +00:00 committed by Antonio Borneo
parent bd32290864
commit c2b8f994bf
6 changed files with 25 additions and 43 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -18,6 +18,7 @@
#include "register.h"
#include <helper/binarybuffer.h>
#include <helper/string_choices.h>
#include <helper/command.h>
#include <helper/nvp.h>
@ -1359,10 +1360,6 @@ static int armv8_aarch64_state(struct target *target)
int armv8_arch_state(struct target *target)
{
static const char * const state[] = {
"disabled", "enabled"
};
struct armv8_common *armv8 = target_to_armv8(target);
struct arm *arm = &armv8->arm;
@ -1377,9 +1374,9 @@ int armv8_arch_state(struct target *target)
arm_arch_state(target);
LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s",
state[armv8->armv8_mmu.mmu_enabled],
state[armv8->armv8_mmu.armv8_cache.d_u_cache_enabled],
state[armv8->armv8_mmu.armv8_cache.i_cache_enabled]);
str_enabled_disabled(armv8->armv8_mmu.mmu_enabled),
str_enabled_disabled(armv8->armv8_mmu.armv8_cache.d_u_cache_enabled),
str_enabled_disabled(armv8->armv8_mmu.armv8_cache.i_cache_enabled));
if (arm->core_mode == ARM_MODE_ABT)
armv8_show_fault_registers(target);

View File

@ -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;