On 2021-12-17 2:02 PM, Mark Brown wrote:
To simplify the code a bit and allow future reuse factor the checks that values we read are valid out of test_ctl_get_value() into a separate function which can be reused later. As part of this extend the test to check all the values for the control, not just the first one. Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
...
+/* + * Check that the provided value meets the constraints for the + * provided control. + */ +bool ctl_value_valid(struct ctl_data *ctl, snd_ctl_elem_value_t *val) +{ + int i; + bool valid = true; + + for (i = 0; i < snd_ctl_elem_info_get_count(ctl->info); i++) + if (!ctl_value_index_valid(ctl, val, i)) + valid = false;
Correct me I'm wrong, but it seems a 'return false' would suffice. Is the continuation of looping still needed once a single check found above evaluates to true?
Regards, Czarek
+ + return valid; +}