Skip to content

Commit

Permalink
command, hosted/cli: Undo both NULL checks and "Unknown"-checks aroun…
Browse files Browse the repository at this point in the history
…d target_voltage

* Given all in-tree implementations now return something else than NULL,
  the callers can no longer bother checking for NULL.
* It is technically valid (and the honest truth) to print "Unknown" voltage
  • Loading branch information
ALTracer committed Jul 17, 2024
1 parent c83e3c9 commit 833c5db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
15 changes: 3 additions & 12 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ static bool cmd_jtag_scan(target_s *target, int argc, const char **argv)
(void)argc;
(void)argv;

/* Call the sampling function only once, check for NULL, check for unimplemented and suppress the output */
const char *const target_voltage = platform_target_voltage();
if (target_voltage && strcmp(target_voltage, "Unknown") != 0)
gdb_outf("Target voltage: %s\n", target_voltage);
gdb_outf("Target voltage: %s\n", platform_target_voltage());

if (connect_assert_nrst)
platform_nrst_set_val(true); /* will be deasserted after attach */
Expand Down Expand Up @@ -256,10 +253,7 @@ bool cmd_swd_scan(target_s *target, int argc, const char **argv)
volatile uint32_t targetid = 0;
if (argc > 1)
targetid = strtoul(argv[1], NULL, 0);
/* Call the sampling function only once, check for NULL, check for unimplemented and suppress the output */
const char *const target_voltage = platform_target_voltage();
if (target_voltage && strcmp(target_voltage, "Unknown") != 0)
gdb_outf("Target voltage: %s\n", target_voltage);
gdb_outf("Target voltage: %s\n", platform_target_voltage());

if (connect_assert_nrst)
platform_nrst_set_val(true); /* will be deasserted after attach */
Expand Down Expand Up @@ -300,10 +294,7 @@ bool cmd_auto_scan(target_s *t, int argc, const char **argv)
(void)argc;
(void)argv;

/* Call the sampling function only once, check for NULL, check for unimplemented and suppress the output */
const char *const target_voltage = platform_target_voltage();
if (target_voltage && strcmp(target_voltage, "Unknown") != 0)
gdb_outf("Target voltage: %s\n", target_voltage);
gdb_outf("Target voltage: %s\n", platform_target_voltage());

if (connect_assert_nrst)
platform_nrst_set_val(true); /* will be deasserted after attach */
Expand Down
5 changes: 1 addition & 4 deletions src/platforms/hosted/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,7 @@ int cl_execute(bmda_cli_options_s *opt)
platform_nrst_set_val(opt->opt_connect_under_reset);
if (opt->opt_mode == BMP_MODE_TEST)
DEBUG_INFO("Running in Test Mode\n");
/* Call the sampling function only once, check for NULL, check for unimplemented and suppress the output */
const char *const target_voltage = platform_target_voltage();
if (target_voltage && strcmp(target_voltage, "Unknown") != 0)
DEBUG_INFO("Target voltage: %s\n", target_voltage);
DEBUG_INFO("Target voltage: %s\n", platform_target_voltage());

if (!scan_for_targets(opt)) {
DEBUG_ERROR("No target found\n");
Expand Down

0 comments on commit 833c5db

Please sign in to comment.