mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
ucm: allow '-' prefix to avoid errors when the variable is not defined
It may be useful to check if variable is not defined. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
11ec9e497e
commit
5062565e82
1 changed files with 7 additions and 0 deletions
|
|
@ -549,13 +549,20 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
|
||||||
static char *rval_var(snd_use_case_mgr_t *uc_mgr, const char *id)
|
static char *rval_var(snd_use_case_mgr_t *uc_mgr, const char *id)
|
||||||
{
|
{
|
||||||
const char *v;
|
const char *v;
|
||||||
|
bool ignore_not_found = false;
|
||||||
|
|
||||||
if (uc_mgr->conf_format < 3) {
|
if (uc_mgr->conf_format < 3) {
|
||||||
uc_error("variable substitution is supported in v3+ syntax");
|
uc_error("variable substitution is supported in v3+ syntax");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id[0] == '-') {
|
||||||
|
ignore_not_found = true;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
v = uc_mgr_get_variable(uc_mgr, id);
|
v = uc_mgr_get_variable(uc_mgr, id);
|
||||||
|
if (v == NULL && ignore_not_found)
|
||||||
|
v = "";
|
||||||
if (v)
|
if (v)
|
||||||
return strdup(v);
|
return strdup(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue