From: Gerhard Sittig Date: Sun, 6 Feb 2022 20:32:28 +0000 (+0100) Subject: show: use getter result to determine "current" presence (voltage range) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5e6a040273d5b6aadb77a2a8736bc32b08d74649;p=sigrok-cli.git show: use getter result to determine "current" presence (voltage range) Improve the condition which presents the "(current)" decoration when voltage ranges are listed in --show output. Use an explicit boolean which is derived from the config getter's return code. Avoid "forcing" a comparison against a zero value, which can be a valid item in the list of supported voltages. This is similar to commit 0171a4a7a49f. See more context (-U10) for the motivation of the change. Was observed with the kingst-la2016 driver. --- diff --git a/show.c b/show.c index 5243e53..85b4409 100644 --- a/show.c +++ b/show.c @@ -418,7 +418,7 @@ void show_dev_detail(void) char *tmp_str, *s, c; const char **stropts; double tmp_flt; - gboolean have_tmp_flt; + gboolean have_tmp_flt, have_curr; const double *fltopts; if (parse_driver(opt_drv, &driver_from_opt, NULL)) { @@ -718,12 +718,11 @@ void show_dev_detail(void) continue; } + have_curr = FALSE; if (maybe_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) { g_variant_get(gvar, "(dd)", &dcur_low, &dcur_high); g_variant_unref(gvar); - } else { - dcur_low = 0; - dcur_high = 0; + have_curr = TRUE; } num_elements = g_variant_n_children(gvar_list); @@ -734,6 +733,8 @@ void show_dev_detail(void) if (i) printf(", "); printf("%.1f-%.1f", dlow, dhigh); + if (!have_curr) + continue; if (dlow == dcur_low && dhigh == dcur_high) printf(" (current)"); }