Skip to content

Commit

Permalink
command: Fixed all the clang-tidy lints about naming for the target p…
Browse files Browse the repository at this point in the history
…arameters to the commands
  • Loading branch information
dragonmux committed Oct 6, 2024
1 parent 3a7f153 commit e37df3e
Showing 1 changed file with 54 additions and 55 deletions.
109 changes: 54 additions & 55 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,34 @@
#include "usb.h"
#endif

static bool cmd_version(target_s *t, int argc, const char **argv);
static bool cmd_help(target_s *t, int argc, const char **argv);
static bool cmd_version(target_s *target, int argc, const char **argv);
static bool cmd_help(target_s *target, int argc, const char **argv);

static bool cmd_jtag_scan(target_s *target, int argc, const char **argv);
static bool cmd_swd_scan(target_s *target, int argc, const char **argv);
static bool cmd_auto_scan(target_s *t, int argc, const char **argv);
static bool cmd_frequency(target_s *t, int argc, const char **argv);
static bool cmd_targets(target_s *t, int argc, const char **argv);
static bool cmd_morse(target_s *t, int argc, const char **argv);
static bool cmd_halt_timeout(target_s *t, int argc, const char **argv);
static bool cmd_connect_reset(target_s *t, int argc, const char **argv);
static bool cmd_reset(target_s *t, int argc, const char **argv);
static bool cmd_tdi_low_reset(target_s *t, int argc, const char **argv);
static bool cmd_auto_scan(target_s *target, int argc, const char **argv);
static bool cmd_frequency(target_s *target, int argc, const char **argv);
static bool cmd_targets(target_s *target, int argc, const char **argv);
static bool cmd_morse(target_s *target, int argc, const char **argv);
static bool cmd_halt_timeout(target_s *target, int argc, const char **argv);
static bool cmd_connect_reset(target_s *target, int argc, const char **argv);
static bool cmd_reset(target_s *target, int argc, const char **argv);
static bool cmd_tdi_low_reset(target_s *target, int argc, const char **argv);
#ifdef PLATFORM_HAS_POWER_SWITCH
static bool cmd_target_power(target_s *t, int argc, const char **argv);
static bool cmd_target_power(target_s *target, int argc, const char **argv);
#endif
#ifdef PLATFORM_HAS_TRACESWO
static bool cmd_swo(target_s *t, int argc, const char **argv);
static bool cmd_swo(target_s *target, int argc, const char **argv);
#endif
static bool cmd_heapinfo(target_s *t, int argc, const char **argv);
static bool cmd_heapinfo(target_s *target, int argc, const char **argv);
#ifdef ENABLE_RTT
static bool cmd_rtt(target_s *t, int argc, const char **argv);
static bool cmd_rtt(target_s *target, int argc, const char **argv);
#endif
#if defined(PLATFORM_HAS_DEBUG) && PC_HOSTED == 0
static bool cmd_debug_bmp(target_s *t, int argc, const char **argv);
static bool cmd_debug_bmp(target_s *target, int argc, const char **argv);
#endif
#if PC_HOSTED == 1
static bool cmd_shutdown_bmda(target_s *t, int argc, const char **argv);
static bool cmd_shutdown_bmda(target_s *target, int argc, const char **argv);
#endif

#ifdef _MSC_VER
Expand Down Expand Up @@ -138,7 +138,7 @@ bool debug_bmp;
#endif
unsigned cortexm_wait_timeout = 2000; /* Timeout to wait for Cortex to react on halt command. */

int command_process(target_s *const t, char *const cmd_buffer)
int command_process(target_s *const target, char *const cmd_buffer)
{
/* Initial estimate for argc */
size_t argc = 1;
Expand All @@ -165,24 +165,24 @@ int command_process(target_s *const t, char *const cmd_buffer)
* So 'mon ver' will match 'monitor version'
*/
if ((argc == 0) || !strncmp(argv[0], cmd->cmd, strlen(argv[0])))
return !cmd->handler(t, argc, argv);
return !cmd->handler(target, argc, argv);
}

#ifdef PLATFORM_HAS_CUSTOM_COMMANDS
for (const command_s *cmd = platform_cmd_list; cmd->cmd; ++cmd) {
if (!strncmp(argv[0], cmd->cmd, strlen(argv[0])))
return !cmd->handler(t, argc, argv);
return !cmd->handler(target, argc, argv);
}
#endif

if (!t)
if (!target)
return -1;
return target_command(t, argc, argv);
return target_command(target, argc, argv);
}

bool cmd_version(target_s *t, int argc, const char **argv)
bool cmd_version(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
(void)argc;
(void)argv;
#if PC_HOSTED == 1
Expand All @@ -204,12 +204,12 @@ bool cmd_version(target_s *t, int argc, const char **argv)
return true;
}

bool cmd_help(target_s *t, int argc, const char **argv)
bool cmd_help(target_s *target, int argc, const char **argv)
{
(void)argc;
(void)argv;

if (!t || t->tc->destroy_callback) {
if (!target || target->tc->destroy_callback) {
gdb_out("General commands:\n");
for (const command_s *cmd = cmd_list; cmd->cmd; cmd++)
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
Expand All @@ -218,11 +218,11 @@ bool cmd_help(target_s *t, int argc, const char **argv)
for (const command_s *cmd = platform_cmd_list; cmd->cmd; ++cmd)
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
#endif
if (!t)
if (!target)
return true;
}

target_command_help(t);
target_command_help(target);
return true;
}

Expand Down Expand Up @@ -308,9 +308,9 @@ bool cmd_swd_scan(target_s *target, int argc, const char **argv)
return true;
}

bool cmd_auto_scan(target_s *t, int argc, const char **argv)
bool cmd_auto_scan(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
(void)argc;
(void)argv;

Expand Down Expand Up @@ -360,9 +360,9 @@ bool cmd_auto_scan(target_s *t, int argc, const char **argv)
return true;
}

bool cmd_frequency(target_s *t, int argc, const char **argv)
bool cmd_frequency(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
if (argc == 2) {
char *multiplier = NULL;
uint32_t frequency = strtoul(argv[1], &multiplier, 10);
Expand Down Expand Up @@ -415,9 +415,9 @@ bool cmd_targets(target_s *target, int argc, const char **argv)
return true;
}

bool cmd_morse(target_s *t, int argc, const char **argv)
bool cmd_morse(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
(void)argc;
(void)argv;
if (morse_msg) {
Expand All @@ -442,9 +442,9 @@ bool parse_enable_or_disable(const char *value, bool *out)
return true;
}

static bool cmd_connect_reset(target_s *t, int argc, const char **argv)
static bool cmd_connect_reset(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
bool print_status = false;
if (argc == 1)
print_status = true;
Expand All @@ -460,18 +460,18 @@ static bool cmd_connect_reset(target_s *t, int argc, const char **argv)
return true;
}

static bool cmd_halt_timeout(target_s *t, int argc, const char **argv)
static bool cmd_halt_timeout(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
if (argc > 1)
cortexm_wait_timeout = strtoul(argv[1], NULL, 0);
gdb_outf("Cortex-M timeout to wait for device halts: %u\n", cortexm_wait_timeout);
return true;
}

static bool cmd_reset(target_s *t, int argc, const char **argv)
static bool cmd_reset(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
uint32_t pulse_len_ms = 0;
if (argc > 1)
pulse_len_ms = strtoul(argv[1], NULL, 0);
Expand All @@ -482,9 +482,9 @@ static bool cmd_reset(target_s *t, int argc, const char **argv)
return true;
}

static bool cmd_tdi_low_reset(target_s *t, int argc, const char **argv)
static bool cmd_tdi_low_reset(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
(void)argc;
(void)argv;
jtag_proc.jtagtap_next(true, false);
Expand All @@ -493,9 +493,9 @@ static bool cmd_tdi_low_reset(target_s *t, int argc, const char **argv)
}

#ifdef PLATFORM_HAS_POWER_SWITCH
static bool cmd_target_power(target_s *t, int argc, const char **argv)
static bool cmd_target_power(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
if (argc == 1)
gdb_outf("Target Power: %s\n", platform_target_get_power() ? "enabled" : "disabled");
else if (argc == 2) {
Expand Down Expand Up @@ -523,9 +523,8 @@ static const char *on_or_off(const bool value)
return value ? "on" : "off";
}

static bool cmd_rtt(target_s *t, int argc, const char **argv)
static bool cmd_rtt(target_s *target, int argc, const char **argv)
{
(void)t;
const size_t command_len = argc > 1 ? strlen(argv[1]) : 0;
if (argc == 1 || (argc == 2 && strncmp(argv[1], "enabled", command_len) == 0)) {
rtt_enabled = true;
Expand All @@ -540,7 +539,7 @@ static bool cmd_rtt(target_s *t, int argc, const char **argv)
gdb_out("off");
else
gdb_outf("\"%s\"", rtt_ident);
gdb_outf(" halt: %s", on_or_off(target_mem_access_needs_halt(t)));
gdb_outf(" halt: %s", on_or_off(target_mem_access_needs_halt(target)));
gdb_out(" channels: ");
if (rtt_auto_channel)
gdb_out("auto ");
Expand Down Expand Up @@ -688,9 +687,9 @@ static bool cmd_swo_disable(void)
return true;
}

static bool cmd_swo(target_s *t, int argc, const char **argv)
static bool cmd_swo(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
bool enable_swo = false;
if (argc >= 2 && !parse_enable_or_disable(argv[1], &enable_swo)) {
gdb_out("Usage: traceswo <enable|disable> [2000000] [decode [0 1 3 31]]\n");
Expand All @@ -704,9 +703,9 @@ static bool cmd_swo(target_s *t, int argc, const char **argv)
#endif

#if defined(PLATFORM_HAS_DEBUG) && PC_HOSTED == 0
static bool cmd_debug_bmp(target_s *t, int argc, const char **argv)
static bool cmd_debug_bmp(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
if (argc == 2 && !parse_enable_or_disable(argv[1], &debug_bmp))
return false;
if (argc > 2) {
Expand All @@ -720,9 +719,9 @@ static bool cmd_debug_bmp(target_s *t, int argc, const char **argv)
#endif

#if PC_HOSTED == 1
static bool cmd_shutdown_bmda(target_s *t, int argc, const char **argv)
static bool cmd_shutdown_bmda(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
(void)argc;
(void)argv;
shutdown_bmda = true;
Expand All @@ -738,9 +737,9 @@ static bool cmd_shutdown_bmda(target_s *t, int argc, const char **argv)
* - If the target system crashes, increase heap or stack
* See newlib/libc/sys/arm/crt0.S "Issue Angel SWI to read stack info"
*/
static bool cmd_heapinfo(target_s *t, int argc, const char **argv)
static bool cmd_heapinfo(target_s *target, int argc, const char **argv)
{
if (t == NULL)
if (target == NULL)
gdb_out("not attached\n");
else if (argc == 5) {
target_addr_t heap_base = strtoul(argv[1], NULL, 16);
Expand All @@ -750,7 +749,7 @@ static bool cmd_heapinfo(target_s *t, int argc, const char **argv)
gdb_outf("heap_base: %08" PRIx32 " heap_limit: %08" PRIx32 " stack_base: %08" PRIx32 " stack_limit: "
"%08" PRIx32 "\n",
heap_base, heap_limit, stack_base, stack_limit);
target_set_heapinfo(t, heap_base, heap_limit, stack_base, stack_limit);
target_set_heapinfo(target, heap_base, heap_limit, stack_base, stack_limit);
} else
gdb_outf("%s\n", "Set semihosting heapinfo: HEAP_BASE HEAP_LIMIT STACK_BASE STACK_LIMIT");
return true;
Expand Down

0 comments on commit e37df3e

Please sign in to comment.