alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
@ 2019-11-19 10:48 Hans de Goede
  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
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 10:48 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Hans de Goede, alsa-devel, Pierre-Louis Bossart

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [alsa-devel] [PATCH alsa-lib 2/4] ucm: Fix fallback to card_name (shortname) config for ucm1 profiles
  2019-11-19 10:48 [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Hans de Goede
@ 2019-11-19 10:48 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 10:48 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Hans de Goede, alsa-devel, Pierre-Louis Bossart

uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that fails then calls it again with the
card_name.

Before this commit configuration_filename() would force conf_format to 2
when it the access(fn, R_OK) test failed for the ucm1 longname
master-config filename.

This would cause configuration_filename() to blindly return a filename
under <prefix>/ucm2 without seeing if that is actually there and without
trying to fallback to the old profiles under <prefix>/ucm, breaking the
loading of UCM1 profiles by card_name.

This commit fixes this by modifying configuration_filename() to not set
conf_format when checking for the UCM1 config filename fails.
Instead, to make sure that any errors about opening the file still report
the new path, configuration_filename() now resets the filename to the UCM2
path if the access() check has failed for both the UCM2 and UCM1 paths,
without touching conf_format.

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 | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index 17aab054..a7e80de3 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -101,7 +101,6 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 	}
 
 	if (uc_mgr->conf_format > 0) {
-__format:
 		configuration_filename2(fn, fn_len, uc_mgr->conf_format,
 					dir, file, suffix);
 		return;
@@ -112,11 +111,11 @@ __format:
 		return;
 
 	configuration_filename2(fn, fn_len, 0, dir, file, suffix);
-	if (access(fn, R_OK)) {
-		/* make sure that the error message refers to the new path */
-		uc_mgr->conf_format = 2;
-		goto __format;
-	}
+	if (access(fn, R_OK) == 0)
+		return;
+
+	/* make sure that the error message refers to the new path */
+	configuration_filename2(fn, fn_len, 2, dir, file, suffix);
 }
 
 /*
-- 
2.23.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [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
  2019-11-19 10:48 [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Hans de Goede
  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 ` 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
  3 siblings, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 10:48 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Hans de Goede, alsa-devel, Pierre-Louis Bossart

Unless environment variables are set, then configuration_filename()
when initially called by load_master_config() will first try to find
the requested master-config under <prefix>/alsa/ucm2 and then under
<prefix>/alsa/ucm.

Once a master-config is found this way, we should set conf_format to
match, so that subsequent lookups only look under the same directory
as where the master-config was found.

This fixes 2 problems:
1. uc_mgr_config_load() looking under <prefix>/alsa/ucm for includes for
   UCM2 profiles because it is called with uc_mgr->conf_format as format
   and before this commit that would stay 0 when autodetecion is used.

2. parse_verb_file() possibly loading an UCM2 verb-file for an UCM1 profile,
   the chance of this happening is small as this means that even though
   there is no UCM2 master-config there is an UCM2 profile dir matching
   uc_mgr->conf_file_name, which would be weird.

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 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index a7e80de3..319e3c1a 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -107,12 +107,18 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 	}
 
 	configuration_filename2(fn, fn_len, 2, dir, file, suffix);
-	if (access(fn, R_OK) == 0)
+	if (access(fn, R_OK) == 0) {
+		/* Found an ucm2 file, only look in the ucm2 dir from now on */
+		uc_mgr->conf_format = 2;
 		return;
+	}
 
 	configuration_filename2(fn, fn_len, 0, dir, file, suffix);
-	if (access(fn, R_OK) == 0)
+	if (access(fn, R_OK) == 0) {
+		/* Found an ucm1 file, only look in the ucm dir from now on */
+		uc_mgr->conf_format = 1;
 		return;
+	}
 
 	/* make sure that the error message refers to the new path */
 	configuration_filename2(fn, fn_len, 2, dir, file, suffix);
-- 
2.23.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [alsa-devel] [PATCH alsa-lib 4/4] ucm: parser: Fix snprintf usage
  2019-11-19 10:48 [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Hans de Goede
  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 ` 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
  3 siblings, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 10:48 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Hans de Goede, alsa-devel, Pierre-Louis Bossart

There is no need to manually 0 terminate the buffer with snprintf,
only strncpy has the very unfortunate behavior of not guaranteeing 0
termination.

Likewise there is no need to substract one from the buffer size of
the buffer passed to snprintf.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/ucm/parser.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index 319e3c1a..305d36c5 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -71,7 +71,6 @@ static void configuration_filename2(char *fn, size_t fn_len, int format,
 	snprintf(fn, fn_len, "%s/ucm%s/%s/%s%s",
 		 snd_config_topdir(), format >= 2 ? "2" : "",
 		 dir, file, suffix);
-	fn[fn_len-1] = '\0';
 }
 
 static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
@@ -96,7 +95,6 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 	}
 	if (env) {
 		snprintf(fn, fn_len, "%s/%s/%s%s", env, dir, file, suffix);
-		fn[fn_len-1] = '\0';
 		return;
 	}
 
@@ -1712,11 +1710,10 @@ int uc_mgr_scan_master_configs(const char **_list[])
 	struct dirent **namelist;
 
 	if (env)
-		snprintf(filename, sizeof(filename)-1, "%s", env);
+		snprintf(filename, sizeof(filename), "%s", env);
 	else
-		snprintf(filename, sizeof(filename)-1, "%s/ucm2",
+		snprintf(filename, sizeof(filename), "%s/ucm2",
 			 snd_config_topdir());
-	filename[sizeof(filename)-1] = '\0';
 
 #if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(ANDROID)
 #define SORTFUNC	versionsort
-- 
2.23.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  2019-11-19 10:48 [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Hans de Goede
                   ` (2 preceding siblings ...)
  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 ` Jaroslav Kysela
  2019-11-19 12:40   ` Hans de Goede
  3 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2019-11-19 12:23 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Takashi Iwai, alsa-devel, Pierre-Louis Bossart

Dne 19. 11. 19 v 11:48 Hans de Goede napsal(a):
> 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.

Hi Hans,

This new behaviour was intended for ucm2. I applied all four your patches, and 
added 10a63e093c4a98acfa9bcdfdd06938bcd874b008 on top which should keep the
new behaviour for v2 configs.

It's time to create the 1.2.1.1 bugfix alsa-lib release, I guess.

			Thank you,
				Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 12:40 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, Pierre-Louis Bossart

Hi,

On 19-11-2019 13:23, Jaroslav Kysela wrote:
> Dne 19. 11. 19 v 11:48 Hans de Goede napsal(a):
>> 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.
> 
> Hi Hans,
> 
> This new behaviour was intended for ucm2. I applied all four your patches, and added 10a63e093c4a98acfa9bcdfdd06938bcd874b008 on top which should keep the
> new behaviour for v2 configs.

Ah I see.

There is a bug in the commit you added on top though,
when load_master_config() gets called with longname == 1
and ALSA_CONFIG_UCM2_VAR is not set and ALSA_CONFIG_UCM_VAR
is set, then the if condition in the block is false, so it never executes:

+               if (getenv(ALSA_CONFIG_UCM2_VAR) || !getenv(ALSA_CONFIG_UCM_VAR)) {
+                       uc_mgr->conf_format = 2;
+                       configuration_filename(uc_mgr, filename, sizeof(filename),
+                                              uc_mgr->conf_file_name, card_name, ".conf");
+               }

Causing the next block to also not execute:

+               if (uc_mgr->conf_format >= 2 && access(filename, R_OK) != 0) {
+                       /* try the old ucm directory */
+                       uc_mgr->conf_format = 1;
+                       configuration_filename(uc_mgr, filename, sizeof(filename),
+                                              card_name, card_name, ".conf");
+                       if (access(filename, R_OK) != 0)
+                               return -ENOENT;
+               }

Causing load_master_config() to continue with an uninitialized filename.

I think you wanted the following condition for the second block:

                 if (uc_mgr->conf_format == 0 || access(filename, R_OK) != 0) {

Also don't you want the same behavor wrt forcing the conf_format based
on env. when trying the shortname ?

I think you can move the entire block under if (longname) to be unconditional,
since conf_file_name == card_name for the shortname case using the longname
path in the shortname case too is fine. Then you always call configuration_filename
with conf_format set and all the handling for conf_format not being set (and
for overriding it) can be dropped from configuration_filename() then.

> It's time to create the 1.2.1.1 bugfix alsa-lib release, I guess.

Yes that is a good idea (once the above is resolved).

Regards,

Hans

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  2019-11-19 12:40   ` Hans de Goede
@ 2019-11-19 13:21     ` Jaroslav Kysela
  2019-11-19 15:32       ` Hans de Goede
  0 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2019-11-19 13:21 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Takashi Iwai, alsa-devel, Pierre-Louis Bossart

Dne 19. 11. 19 v 13:40 Hans de Goede napsal(a):
> Hi,
> 
> On 19-11-2019 13:23, Jaroslav Kysela wrote:
>> Dne 19. 11. 19 v 11:48 Hans de Goede napsal(a):
>>> 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.
>>
>> Hi Hans,
>>
>> This new behaviour was intended for ucm2. I applied all four your patches, and added 10a63e093c4a98acfa9bcdfdd06938bcd874b008 on top which should keep the
>> new behaviour for v2 configs.
> 
> Ah I see.
> 
> There is a bug in the commit you added on top though,
> when load_master_config() gets called with longname == 1
> and ALSA_CONFIG_UCM2_VAR is not set and ALSA_CONFIG_UCM_VAR
> is set, then the if condition in the block is false, so it never executes:
> 
> +               if (getenv(ALSA_CONFIG_UCM2_VAR) || !getenv(ALSA_CONFIG_UCM_VAR)) {
> +                       uc_mgr->conf_format = 2;
> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
> +                                              uc_mgr->conf_file_name, card_name, ".conf");
> +               }
> 
> Causing the next block to also not execute:
> 
> +               if (uc_mgr->conf_format >= 2 && access(filename, R_OK) != 0) {
> +                       /* try the old ucm directory */
> +                       uc_mgr->conf_format = 1;
> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
> +                                              card_name, card_name, ".conf");
> +                       if (access(filename, R_OK) != 0)
> +                               return -ENOENT;
> +               }
> 
> Causing load_master_config() to continue with an uninitialized filename.
> 
> I think you wanted the following condition for the second block:
> 
>                   if (uc_mgr->conf_format == 0 || access(filename, R_OK) != 0) {
> 
> Also don't you want the same behavor wrt forcing the conf_format based
> on env. when trying the shortname ?
> 
> I think you can move the entire block under if (longname) to be unconditional,
> since conf_file_name == card_name for the shortname case using the longname
> path in the shortname case too is fine. Then you always call configuration_filename
> with conf_format set and all the handling for conf_format not being set (and
> for overriding it) can be dropped from configuration_filename() then.

Thanks again, fixed in 1d848ab739f0d207098627d2ba66421b3ec75eeb .

> 
>> It's time to create the 1.2.1.1 bugfix alsa-lib release, I guess.
> 
> Yes that is a good idea (once the above is resolved).

The tar ball is in ftp://ftp.alsa-project.org/pub/testing .

				Jaroslav

> 
> Regards,
> 
> Hans
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  2019-11-19 13:21     ` Jaroslav Kysela
@ 2019-11-19 15:32       ` Hans de Goede
  2019-11-25 10:12         ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2019-11-19 15:32 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, Pierre-Louis Bossart

Hi,

On 19-11-2019 14:21, Jaroslav Kysela wrote:
> Dne 19. 11. 19 v 13:40 Hans de Goede napsal(a):
>> Hi,
>>
>> On 19-11-2019 13:23, Jaroslav Kysela wrote:
>>> Dne 19. 11. 19 v 11:48 Hans de Goede napsal(a):
>>>> 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.
>>>
>>> Hi Hans,
>>>
>>> This new behaviour was intended for ucm2. I applied all four your patches, and added 10a63e093c4a98acfa9bcdfdd06938bcd874b008 on top which should keep the
>>> new behaviour for v2 configs.
>>
>> Ah I see.
>>
>> There is a bug in the commit you added on top though,
>> when load_master_config() gets called with longname == 1
>> and ALSA_CONFIG_UCM2_VAR is not set and ALSA_CONFIG_UCM_VAR
>> is set, then the if condition in the block is false, so it never executes:
>>
>> +               if (getenv(ALSA_CONFIG_UCM2_VAR) || !getenv(ALSA_CONFIG_UCM_VAR)) {
>> +                       uc_mgr->conf_format = 2;
>> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
>> +                                              uc_mgr->conf_file_name, card_name, ".conf");
>> +               }
>>
>> Causing the next block to also not execute:
>>
>> +               if (uc_mgr->conf_format >= 2 && access(filename, R_OK) != 0) {
>> +                       /* try the old ucm directory */
>> +                       uc_mgr->conf_format = 1;
>> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
>> +                                              card_name, card_name, ".conf");
>> +                       if (access(filename, R_OK) != 0)
>> +                               return -ENOENT;
>> +               }
>>
>> Causing load_master_config() to continue with an uninitialized filename.
>>
>> I think you wanted the following condition for the second block:
>>
>>                   if (uc_mgr->conf_format == 0 || access(filename, R_OK) != 0) {
>>
>> Also don't you want the same behavor wrt forcing the conf_format based
>> on env. when trying the shortname ?
>>
>> I think you can move the entire block under if (longname) to be unconditional,
>> since conf_file_name == card_name for the shortname case using the longname
>> path in the shortname case too is fine. Then you always call configuration_filename
>> with conf_format set and all the handling for conf_format not being set (and
>> for overriding it) can be dropped from configuration_filename() then.
> 
> Thanks again, fixed in 1d848ab739f0d207098627d2ba66421b3ec75eeb .
> 
>>
>>> It's time to create the 1.2.1.1 bugfix alsa-lib release, I guess.
>>
>> Yes that is a good idea (once the above is resolved).
> 
> The tar ball is in ftp://ftp.alsa-project.org/pub/testing .

Thanks, I've given this a quick test spin, the 1.2.1.1 tarbal looks good to me.

Regards,

Hans

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  2019-11-19 15:32       ` Hans de Goede
@ 2019-11-25 10:12         ` Takashi Iwai
  2019-11-25 10:51           ` Jaroslav Kysela
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2019-11-25 10:12 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart

On Tue, 19 Nov 2019 16:32:07 +0100,
Hans de Goede wrote:
> 
> Hi,
> 
> On 19-11-2019 14:21, Jaroslav Kysela wrote:
> > Dne 19. 11. 19 v 13:40 Hans de Goede napsal(a):
> >> Hi,
> >>
> >> On 19-11-2019 13:23, Jaroslav Kysela wrote:
> >>> Dne 19. 11. 19 v 11:48 Hans de Goede napsal(a):
> >>>> 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.
> >>>
> >>> Hi Hans,
> >>>
> >>> This new behaviour was intended for ucm2. I applied all four your patches, and added 10a63e093c4a98acfa9bcdfdd06938bcd874b008 on top which should keep the
> >>> new behaviour for v2 configs.
> >>
> >> Ah I see.
> >>
> >> There is a bug in the commit you added on top though,
> >> when load_master_config() gets called with longname == 1
> >> and ALSA_CONFIG_UCM2_VAR is not set and ALSA_CONFIG_UCM_VAR
> >> is set, then the if condition in the block is false, so it never executes:
> >>
> >> +               if (getenv(ALSA_CONFIG_UCM2_VAR) || !getenv(ALSA_CONFIG_UCM_VAR)) {
> >> +                       uc_mgr->conf_format = 2;
> >> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
> >> +                                              uc_mgr->conf_file_name, card_name, ".conf");
> >> +               }
> >>
> >> Causing the next block to also not execute:
> >>
> >> +               if (uc_mgr->conf_format >= 2 && access(filename, R_OK) != 0) {
> >> +                       /* try the old ucm directory */
> >> +                       uc_mgr->conf_format = 1;
> >> +                       configuration_filename(uc_mgr, filename, sizeof(filename),
> >> +                                              card_name, card_name, ".conf");
> >> +                       if (access(filename, R_OK) != 0)
> >> +                               return -ENOENT;
> >> +               }
> >>
> >> Causing load_master_config() to continue with an uninitialized filename.
> >>
> >> I think you wanted the following condition for the second block:
> >>
> >>                   if (uc_mgr->conf_format == 0 || access(filename, R_OK) != 0) {
> >>
> >> Also don't you want the same behavor wrt forcing the conf_format based
> >> on env. when trying the shortname ?
> >>
> >> I think you can move the entire block under if (longname) to be unconditional,
> >> since conf_file_name == card_name for the shortname case using the longname
> >> path in the shortname case too is fine. Then you always call configuration_filename
> >> with conf_format set and all the handling for conf_format not being set (and
> >> for overriding it) can be dropped from configuration_filename() then.
> >
> > Thanks again, fixed in 1d848ab739f0d207098627d2ba66421b3ec75eeb .
> >
> >>
> >>> It's time to create the 1.2.1.1 bugfix alsa-lib release, I guess.
> >>
> >> Yes that is a good idea (once the above is resolved).
> >
> > The tar ball is in ftp://ftp.alsa-project.org/pub/testing .
> 
> Thanks, I've given this a quick test spin, the 1.2.1.1 tarbal looks good to me.

Jaroslav, when will this tarball released officially?


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname
  2019-11-25 10:12         ` Takashi Iwai
@ 2019-11-25 10:51           ` Jaroslav Kysela
  0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2019-11-25 10:51 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart

Dne 25. 11. 19 v 11:12 Takashi Iwai napsal(a):

>>> The tar ball is in ftp://ftp.alsa-project.org/pub/testing .
>>
>> Thanks, I've given this a quick test spin, the 1.2.1.1 tarbal looks good to me.
> 
> Jaroslav, when will this tarball released officially?

Oops, it's already in /pub/lib on ALSA's FTP. I just forget to write a release 
note. I will do it now.

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-11-25 10:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 10:48 [alsa-devel] [PATCH alsa-lib 1/4] ucm: Fix opening of master-configs by the card's longname Hans de Goede
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

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).