diff options
author | Ryan Tucker <ryan.tucker@nuand.com> | 2017-06-28 15:25:37 -0400 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2018-08-15 19:53:26 +0200 |
commit | 814fe0809cbe0570e00d8f0227fb15934e0acb5c (patch) | |
tree | 93dcfd4b472841ff64b0ca841c90cefc4627e1c7 /lib | |
parent | 077697cb2d70f514be6da5a581891cb4e44ba908 (diff) |
bladerf: fix get_gain_names population
Instead of haphazardly iterating through the gain strings, just use the
count returned.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bladerf/bladerf_common.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index f6938ac..a68de17 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -749,22 +749,22 @@ std::vector<std::string> bladerf_common::get_gain_names(size_t chan) const size_t max_count = 16; std::vector < std::string > names; char *gain_names[max_count]; - int status; + int count; names += SYSTEM_GAIN_NAME; - status = bladerf_get_gain_stages(_dev.get(), - static_cast<bladerf_channel>(chan), - (const char **) &gain_names, - max_count); - if (status < 0) { + count = bladerf_get_gain_stages(_dev.get(), + static_cast<bladerf_channel>(chan), + reinterpret_cast<const char **>(&gain_names), + max_count); + if (count < 0) { throw std::runtime_error(_pfx + "failed to get gain stages: " + - bladerf_strerror(status)); + bladerf_strerror(count)); } - for (char **p = gain_names; *p != NULL && **p != '\0'; ++p) { - char *tmp = *p; + for (int i = 0; i < count; ++i) { + char *tmp = gain_names[i]; names += std::string(tmp); }; |