Skip to content

Commit

Permalink
show: use getter result to determine "current" presence (voltage range)
Browse files Browse the repository at this point in the history
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 0171a4a. See more context (-U10) for the
motivation of the change. Was observed with the kingst-la2016 driver.
  • Loading branch information
gsigh committed Feb 6, 2022
1 parent 382d359 commit 5e6a040
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions show.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand All @@ -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)");
}
Expand Down

0 comments on commit 5e6a040

Please sign in to comment.