mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 04:35:43 +01:00
Fixed simple ID parser (when index is ommited)
This commit is contained in:
parent
9f29bedbfd
commit
49829cb0fe
1 changed files with 7 additions and 3 deletions
|
@ -694,7 +694,7 @@ static int parse_simple_id(const char *str, snd_mixer_selem_id_t *sid)
|
||||||
str++;
|
str++;
|
||||||
if (!(*str))
|
if (!(*str))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
size = 0;
|
size = 1; /* for '\0' */
|
||||||
if (*str != '"' && *str != '\'') {
|
if (*str != '"' && *str != '\'') {
|
||||||
while (*str && *str != ',') {
|
while (*str && *str != ',') {
|
||||||
if (size < sizeof(buf)) {
|
if (size < sizeof(buf)) {
|
||||||
|
@ -715,8 +715,11 @@ static int parse_simple_id(const char *str, snd_mixer_selem_id_t *sid)
|
||||||
if (*str == c)
|
if (*str == c)
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
if (*str == '\0')
|
if (*str == '\0') {
|
||||||
return 0;
|
snd_mixer_selem_id_set_index(sid, 0);
|
||||||
|
*ptr = 0;
|
||||||
|
goto _set;
|
||||||
|
}
|
||||||
if (*str != ',')
|
if (*str != ',')
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
*ptr = 0; /* terminate the string */
|
*ptr = 0; /* terminate the string */
|
||||||
|
@ -724,6 +727,7 @@ static int parse_simple_id(const char *str, snd_mixer_selem_id_t *sid)
|
||||||
if (!isdigit(*str))
|
if (!isdigit(*str))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
snd_mixer_selem_id_set_index(sid, atoi(str));
|
snd_mixer_selem_id_set_index(sid, atoi(str));
|
||||||
|
_set:
|
||||||
snd_mixer_selem_id_set_name(sid, buf);
|
snd_mixer_selem_id_set_name(sid, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue