mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 16:56:31 +01:00
alsactl: init - set_ctl_value() - fix bytes parsing
Use the correct error value handling from hextodigit(). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
42ca978078
commit
e55534d8a5
1 changed files with 4 additions and 3 deletions
|
@ -465,12 +465,13 @@ static int set_ctl_value(struct space *space, const char *value, int all)
|
|||
return -EINVAL;
|
||||
}
|
||||
for (idx = 0; idx < count; idx += 2) {
|
||||
val = hextodigit(*(value++)) << 4;
|
||||
val |= hextodigit(*(value++));
|
||||
if (val > 255) {
|
||||
int nibble1 = hextodigit(*(value++));
|
||||
int nibble2 = hextodigit(*(value++));
|
||||
if (nibble1 < 0 || nibble2 < 0) {
|
||||
Perror(space, "bad ctl hexa value");
|
||||
return -EINVAL;
|
||||
}
|
||||
val = (nibble1 << 4) | nibble2;
|
||||
snd_ctl_elem_value_set_byte(space->ctl_value, idx, val);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue