From 567fc631f056195218773cb926b1e60ed7531741 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 26 Jul 2022 12:29:47 +0100 Subject: [PATCH] command: Refactored display_target() --- src/command.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/command.c b/src/command.c index 93ae95d..638e298 100644 --- a/src/command.c +++ b/src/command.c @@ -356,14 +356,13 @@ bool cmd_frequency(target *t, int argc, const char **argv) static void display_target(int i, target *t, void *context) { (void)context; - if (!strcmp(target_driver_name(t), "ARM Cortex-M")) { - gdb_outf("***%2d%sUnknown %s Designer 0x%03x Partno 0x%03x %s\n", i, target_attached(t) ? " * " : " ", - target_driver_name(t), target_designer(t), target_idcode(t), - (target_core_name(t)) ? target_core_name(t) : ""); - } else { - gdb_outf("%2d %c %s %s\n", i, target_attached(t) ? '*' : ' ', target_driver_name(t), - (target_core_name(t)) ? target_core_name(t) : ""); - } + const char attached = target_attached(t) ? '*' : ' '; + const char *const core_name = target_core_name(t); + if (!strcmp(target_driver_name(t), "ARM Cortex-M")) + gdb_outf("***%2d %c Unknown %s Designer 0x%03x Partno 0x%03x %s\n", i, attached, target_driver_name(t), + target_designer(t), target_idcode(t), core_name ? core_name : ""); + else + gdb_outf("%2d %c %s %s\n", i, attached, target_driver_name(t), core_name ? core_name : ""); } bool cmd_targets(target *t, int argc, const char **argv)