Fix the comment about float levels.

And now that the comment parses, fix the check to respect it.

I seriously doubt anyone will ever use this, but you never know.
pull/1297/head
George Baltz N3GB 2023-05-13 14:36:03 -04:00
rodzic d3c2ebcc1f
commit e5f6b4e9d2
2 zmienionych plików z 14 dodań i 5 usunięć

Wyświetl plik

@ -1619,7 +1619,7 @@ typedef struct chan_list chan_t;
*
* The granularity is undefined if min = 0, max = 0, and step = 0.
*
* For float settings, if min.f = 0 and max.f = 0 (and step.f! = 0), max.f is
* For float settings, if min.f = 0 and max.f = 0 (and step.f != 0), max.f is
* assumed to be actually equal to 1.0.
*
* If step = 0 (and min and/or max are not null), then this means step can

Wyświetl plik

@ -972,6 +972,7 @@ static const struct
int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
{
gran_t *this_gran;
float maxval;
this_gran = &rig->caps->level_gran[rig_setting2idx(level)];
@ -982,13 +983,21 @@ int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
if (RIG_LEVEL_IS_FLOAT(level))
{
/* If min==max==0, all values are OK here but may be checked later */
if (this_gran->min.f == 0.0f && this_gran->max.f == 0.0f)
/* If min==max==step==0, all values are OK here */
maxval = this_gran->max.f;
if (this_gran->min.f == 0.0f && maxval == 0.0f)
{
return RIG_OK;
/* if step==0 also, we're good */
if (this_gran->step.f == 0.0f)
{
return RIG_OK;
}
/* non-zero step, check for max of 1.0 */
maxval = 1.0f;
}
if (val.f < this_gran->min.f || val.f > this_gran->max.f)
if (val.f < this_gran->min.f || val.f > maxval)
{
return -RIG_EINVAL;
}