mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 22:34:33 +01:00
kselftest: alsa: Validate values read from enumerations
Enumerations should return a value between 0 and items-1, check that this is the case. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
This commit is contained in:
1 parent
3f48b137d8
commit
10f2f19466
1 file changed
+17
@@ -276,6 +276,23 @@ bool ctl_value_index_valid(struct ctl_data *ctl, snd_ctl_elem_value_t *val,
|
||||
}
|
||||
break;
|
||||
|
||||
case SND_CTL_ELEM_TYPE_ENUMERATED:
|
||||
int_val = snd_ctl_elem_value_get_enumerated(val, index);
|
||||
|
||||
if (int_val < 0) {
|
||||
ksft_print_msg("%s.%d negative value %ld for enumeration\n",
|
||||
ctl->name, index, int_val);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (int_val >= snd_ctl_elem_info_get_items(ctl->info)) {
|
||||
ksft_print_msg("%s.%d value %ld more than item count %ld\n",
|
||||
ctl->name, index, int_val,
|
||||
snd_ctl_elem_info_get_items(ctl->info));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* No tests for other types */
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user