From: Hans de Goede <hdegoede@redhat.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>, Hans de Goede <hdegoede@redhat.com>,
alsa-devel@alsa-project.org,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
Date: Tue, 19 Nov 2019 11:48:19 +0100 [thread overview]
Message-ID: <20191119104822.15053-1-hdegoede@redhat.com> (raw)
Prior to commit aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format,
keep backward compatibility").
The filename build in parse_verb_file() was build like this:
<prefix>/<uc_mgr->conf_file_name>/<file>
Where uc_mgr->conf_file_name would contain either the card_name or the
card's longname depending on the detection of a longname based config in
uc_mgr_import_master_config().
While the filename used in load_master_config() was build like this:
<prefix>/<card_name>/<card_name>.conf
And uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that succeeds it overwrites
uc_mgr->conf_file_name with the longname so that the subsequent uses
of uc_mgr->conf_file_name in parse_verb_file() correctly use the longname.
But the new configuration_filename() helper added in commit aba2260ae7b5
_always_ builds the filename like this:
<prefix>/<uc_mgr->conf_file_name>/<file><suffix>
This breaks the loading of the master-config by its longname, as when
the longname is tried uc_mgr->conf_file_name still contains the card_name.
This commit fixes this by adding a dir parameter to configuration_filename()
and restoring the old behavior by passing card_name as dir in
load_master_config().
Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/ucm/parser.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index ed790dc0..17aab054 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -76,9 +76,10 @@ static void configuration_filename2(char *fn, size_t fn_len, int format,
static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
char *fn, size_t fn_len,
- const char *file, const char *suffix)
+ const char *dir, const char *file,
+ const char *suffix)
{
- const char *env, *dir;
+ const char *env;
if (uc_mgr->conf_format > 0) {
/* known format */
@@ -94,13 +95,11 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
}
}
if (env) {
- snprintf(fn, fn_len, "%s/%s/%s%s",
- env, uc_mgr->conf_file_name, file, suffix);
+ snprintf(fn, fn_len, "%s/%s/%s%s", env, dir, file, suffix);
fn[fn_len-1] = '\0';
return;
}
- dir = uc_mgr->conf_file_name;
if (uc_mgr->conf_format > 0) {
__format:
configuration_filename2(fn, fn_len, uc_mgr->conf_format,
@@ -1181,7 +1180,8 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
}
/* open Verb file for reading */
- configuration_filename(uc_mgr, filename, sizeof(filename), file, "");
+ configuration_filename(uc_mgr, filename, sizeof(filename),
+ uc_mgr->conf_file_name, file, "");
err = uc_mgr_config_load(uc_mgr->conf_format, filename, &cfg);
if (err < 0) {
uc_error("error: failed to open verb file %s : %d",
@@ -1576,7 +1576,7 @@ static int load_master_config(snd_use_case_mgr_t *uc_mgr,
}
configuration_filename(uc_mgr, filename, sizeof(filename),
- card_name, ".conf");
+ card_name, card_name, ".conf");
/* if the configuration file does not exist, silently return */
if (fcheck && access(filename, R_OK) != 0)
--
2.23.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next reply other threads:[~2019-11-19 10:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 10:48 Hans de Goede [this message]
2019-11-19 10:48 ` [alsa-devel] [PATCH alsa-lib 2/4] ucm: Fix fallback to card_name (shortname) config for ucm1 profiles Hans de Goede
2019-11-19 10:48 ` [alsa-devel] [PATCH alsa-lib 3/4] ucm: Only look in ucm[1] or ucm2 dir once we've found a config file in one Hans de Goede
2019-11-19 10:48 ` [alsa-devel] [PATCH alsa-lib 4/4] ucm: parser: Fix snprintf usage Hans de Goede
2019-11-19 12:23 ` [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Jaroslav Kysela
2019-11-19 12:40 ` Hans de Goede
2019-11-19 13:21 ` Jaroslav Kysela
2019-11-19 15:32 ` Hans de Goede
2019-11-25 10:12 ` Takashi Iwai
2019-11-25 10:51 ` Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191119104822.15053-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=alsa-devel@alsa-project.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).