summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2022-05-17 14:35:51 +0200
committerJaroslav Kysela <perex@perex.cz>2022-05-17 14:36:03 +0200
commit5062565e824f02c9838bd781862a9396c52d4111 (patch)
tree696baa44b2d8166ca08349d7d3209c398fbb6be2
parent11ec9e497ee542dc987ab191abee16440336bfe4 (diff)
downloadalsa-lib-5062565e824f02c9838bd781862a9396c52d4111.tar.gz
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>
-rw-r--r--src/ucm/ucm_subs.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
index 8b42b889..a7d79430 100644
--- a/src/ucm/ucm_subs.c
+++ b/src/ucm/ucm_subs.c
@@ -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)
{
const char *v;
+ bool ignore_not_found = false;
if (uc_mgr->conf_format < 3) {
uc_error("variable substitution is supported in v3+ syntax");
return NULL;
}
+ if (id[0] == '-') {
+ ignore_not_found = true;
+ id++;
+ }
v = uc_mgr_get_variable(uc_mgr, id);
+ if (v == NULL && ignore_not_found)
+ v = "";
if (v)
return strdup(v);
return NULL;