Blame SOURCES/alsa-git.patch

e7ccf0
From d6adde0e32376554e461098dcd7cfdb824fabd1e Mon Sep 17 00:00:00 2001
e7ccf0
From: Jaroslav Kysela <perex@perex.cz>
e7ccf0
Date: Mon, 13 Dec 2021 14:40:56 +0100
e7ccf0
Subject: [PATCH 1/4] ucm: top-level path - set directory from symlink
e7ccf0
e7ccf0
It is useful to read the top-level symlink and set the configuration
e7ccf0
directory according this symlink for the relative paths.
e7ccf0
e7ccf0
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
e7ccf0
---
e7ccf0
 src/ucm/parser.c | 55 +++++++++++++++++++++++++++++++++++++++---------
e7ccf0
 1 file changed, 45 insertions(+), 10 deletions(-)
e7ccf0
e7ccf0
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
e7ccf0
index 48790057..7bdaa8fe 100644
e7ccf0
--- a/src/ucm/parser.c
e7ccf0
+++ b/src/ucm/parser.c
e7ccf0
@@ -31,6 +31,7 @@
e7ccf0
  */
e7ccf0
 
e7ccf0
 #include "ucm_local.h"
e7ccf0
+#include <sys/stat.h>
e7ccf0
 #include <stdbool.h>
e7ccf0
 #include <dirent.h>
e7ccf0
 #include <limits.h>
e7ccf0
@@ -2186,6 +2187,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
e7ccf0
 	snd_config_t *n, *n2;
e7ccf0
 	const char *id;
e7ccf0
 	char *dir = NULL, *file = NULL, fn[PATH_MAX];
e7ccf0
+	struct stat st;
e7ccf0
 	long version;
e7ccf0
 	int err;
e7ccf0
 
e7ccf0
@@ -2260,23 +2262,51 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
e7ccf0
 		}
e7ccf0
 
e7ccf0
 		ucm_filename(fn, sizeof(fn), version, dir, file);
e7ccf0
-		if (access(fn, R_OK) == 0) {
e7ccf0
-			if (replace_string(&uc_mgr->conf_dir_name, dir) == NULL) {
e7ccf0
-				err = -ENOMEM;
e7ccf0
-				goto __error;
e7ccf0
-			}
e7ccf0
-			if (replace_string(&uc_mgr->conf_file_name, file) == NULL) {
e7ccf0
-				err = -ENOMEM;
e7ccf0
-				goto __error;
e7ccf0
+		if (access(fn, R_OK) == 0 && lstat(fn, &st) == 0) {
e7ccf0
+			if (st.st_mode & S_IFLNK) {
e7ccf0
+				ssize_t r;
e7ccf0
+				char *link, *dir2, *p;
e7ccf0
+
e7ccf0
+				link = malloc(PATH_MAX);
e7ccf0
+				if (link == NULL)
e7ccf0
+					goto __enomem;
e7ccf0
+				r = readlink(fn, link, PATH_MAX - 1);
e7ccf0
+				if (r <= 0) {
e7ccf0
+					free(link);
e7ccf0
+					goto __next;
e7ccf0
+				}
e7ccf0
+				link[r] = '\0';
e7ccf0
+				p = strrchr(link, '/');
e7ccf0
+				if (p) {
e7ccf0
+					*p = '\0';
e7ccf0
+					dir2 = malloc(PATH_MAX);
e7ccf0
+					if (dir2 == NULL) {
e7ccf0
+						free(link);
e7ccf0
+						goto __enomem;
e7ccf0
+					}
e7ccf0
+					strncpy(dir2, dir, PATH_MAX - 1);
e7ccf0
+					strncat(dir2, "/", PATH_MAX - 1);
e7ccf0
+					strncat(dir2, link, PATH_MAX - 1);
e7ccf0
+					fn[PATH_MAX - 1] = '\0';
e7ccf0
+					free(dir);
e7ccf0
+					dir = dir2;
e7ccf0
+				}
e7ccf0
+				free(link);
e7ccf0
 			}
e7ccf0
+			if (replace_string(&uc_mgr->conf_dir_name, dir) == NULL)
e7ccf0
+				goto __enomem;
e7ccf0
+			if (replace_string(&uc_mgr->conf_file_name, file) == NULL)
e7ccf0
+				goto __enomem;
e7ccf0
 			strncpy(filename, fn, PATH_MAX);
e7ccf0
+			filename[PATH_MAX - 1] = '\0';
e7ccf0
 			uc_mgr->conf_format = version;
e7ccf0
 			goto __ok;
e7ccf0
 		}
e7ccf0
 
e7ccf0
 __next:
e7ccf0
 		free(file);
e7ccf0
-		free(dir);
e7ccf0
+		if (dir != fn)
e7ccf0
+			free(dir);
e7ccf0
 		dir = NULL;
e7ccf0
 		file = NULL;
e7ccf0
 	}
e7ccf0
@@ -2284,11 +2314,16 @@ __next:
e7ccf0
 	err = -ENOENT;
e7ccf0
 	goto __error;
e7ccf0
 
e7ccf0
+__enomem:
e7ccf0
+	err = -ENOMEM;
e7ccf0
+	goto __error;
e7ccf0
+
e7ccf0
 __ok:
e7ccf0
 	err = 0;
e7ccf0
 __error:
e7ccf0
 	free(file);
e7ccf0
-	free(dir);
e7ccf0
+	if (dir != fn)
e7ccf0
+		free(dir);
e7ccf0
 	return err;
e7ccf0
 }
e7ccf0
 
e7ccf0
-- 
e7ccf0
2.34.1
e7ccf0
e7ccf0
e7ccf0
From 47252054b4a2d5c8382cb1342f5d4eb89dabf95f Mon Sep 17 00:00:00 2001
e7ccf0
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
e7ccf0
Date: Sat, 1 Jan 2022 17:20:47 +0100
e7ccf0
Subject: [PATCH 2/4] src/topology/parser.c: drop duplicate safe_strtol_base
e7ccf0
e7ccf0
The safe_strtol_base() function is defined twice since
e7ccf0
	f547b2e3 ("conf: introduce safe_strtol_base()") and
e7ccf0
	5fab157a ("topology: do not call strtol directly")
e7ccf0
resulting in the following build failure when alsa-utils is built
e7ccf0
statically because safe_strtol_base is defined twice.
e7ccf0
e7ccf0
Fixes: http://autobuild.buildroot.org/results/08d028004090b2a8292f03910cb9bf80a73ac804
e7ccf0
Fixes: https://github.com/alsa-project/alsa-lib/pull/207
e7ccf0
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
e7ccf0
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
e7ccf0
---
e7ccf0
 src/topology/parser.c | 19 -------------------
e7ccf0
 1 file changed, 19 deletions(-)
e7ccf0
e7ccf0
diff --git a/src/topology/parser.c b/src/topology/parser.c
e7ccf0
index 01c95afa..e70173f6 100644
e7ccf0
--- a/src/topology/parser.c
e7ccf0
+++ b/src/topology/parser.c
e7ccf0
@@ -21,25 +21,6 @@
e7ccf0
 #include "list.h"
e7ccf0
 #include "tplg_local.h"
e7ccf0
 
e7ccf0
-/*
e7ccf0
- * Safe strtol call
e7ccf0
- */
e7ccf0
-int safe_strtol_base(const char *str, long *val, int base)
e7ccf0
-{
e7ccf0
-	char *end;
e7ccf0
-	long v;
e7ccf0
-	if (!*str)
e7ccf0
-		return -EINVAL;
e7ccf0
-	errno = 0;
e7ccf0
-	v = strtol(str, &end, base);
e7ccf0
-	if (errno)
e7ccf0
-		return -errno;
e7ccf0
-	if (*end)
e7ccf0
-		return -EINVAL;
e7ccf0
-	*val = v;
e7ccf0
-	return 0;
e7ccf0
-}
e7ccf0
-
e7ccf0
 /*
e7ccf0
  * Get integer value
e7ccf0
  */
e7ccf0
-- 
e7ccf0
2.34.1
e7ccf0
e7ccf0
e7ccf0
From c687c482107f746332dd18f7407f6c6efbffccb2 Mon Sep 17 00:00:00 2001
e7ccf0
From: Jaroslav Kysela <perex@perex.cz>
e7ccf0
Date: Sat, 1 Jan 2022 19:18:25 +0100
e7ccf0
Subject: [PATCH 3/4] conf: fix the export of safe_strto* functions from
e7ccf0
 libasound
e7ccf0
e7ccf0
Only one library should define the safe_strto function. Export it
e7ccf0
correctly and add _snd_ prefix to avoid possible clashes with the other
e7ccf0
application code.
e7ccf0
e7ccf0
Fixes: 47252054 ("src/topology/parser.c: drop duplicate safe_strtol_base")
e7ccf0
Fixes: https://github.com/alsa-project/alsa-lib/pull/208
e7ccf0
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
e7ccf0
---
e7ccf0
 include/local.h | 8 ++++++--
e7ccf0
 src/Versions.in | 6 ++++++
e7ccf0
 src/conf.c      | 6 +++---
e7ccf0
 3 files changed, 15 insertions(+), 5 deletions(-)
e7ccf0
e7ccf0
diff --git a/include/local.h b/include/local.h
e7ccf0
index ebc9350c..f64fe9d8 100644
e7ccf0
--- a/include/local.h
e7ccf0
+++ b/include/local.h
e7ccf0
@@ -232,10 +232,14 @@ size_t page_align(size_t size);
e7ccf0
 size_t page_size(void);
e7ccf0
 size_t page_ptr(size_t object_offset, size_t object_size, size_t *offset, size_t *mmap_offset);
e7ccf0
 
e7ccf0
-int safe_strtoll_base(const char *str, long long *val, int base);
e7ccf0
+#define safe_strtoll_base _snd_safe_strtoll_base
e7ccf0
+int _snd_safe_strtoll_base(const char *str, long long *val, int base);
e7ccf0
 static inline int safe_strtoll(const char *str, long long *val) { return safe_strtoll_base(str, val, 0); }
e7ccf0
-int safe_strtol_base(const char *str, long *val, int base);
e7ccf0
+#define safe_strtol_base _snd_safe_strtol_base
e7ccf0
+int _snd_safe_strtol_base(const char *str, long *val, int base);
e7ccf0
 static inline int safe_strtol(const char *str, long *val) { return safe_strtol_base(str, val, 0); }
e7ccf0
+#define safe_strtod _snd_safe_strtod
e7ccf0
+int _snd_safe_strtod(const char *str, double *val);
e7ccf0
 
e7ccf0
 int snd_send_fd(int sock, void *data, size_t len, int fd);
e7ccf0
 int snd_receive_fd(int sock, void *data, size_t len, int *fd);
e7ccf0
diff --git a/src/Versions.in b/src/Versions.in
e7ccf0
index 5daccbd4..85031b38 100644
e7ccf0
--- a/src/Versions.in
e7ccf0
+++ b/src/Versions.in
e7ccf0
@@ -134,3 +134,9 @@ ALSA_1.1.6 {
e7ccf0
 
e7ccf0
     @SYMBOL_PREFIX@snd_dlopen;
e7ccf0
 } ALSA_0.9.7;
e7ccf0
+
e7ccf0
+ALSA_1.2.6 {
e7ccf0
+  global:
e7ccf0
+
e7ccf0
+    @SYMBOL_PREFIX@_snd_safe_strto*;
e7ccf0
+} ALSA_1.1.6;
e7ccf0
diff --git a/src/conf.c b/src/conf.c
e7ccf0
index d3597cbc..098ebd63 100644
e7ccf0
--- a/src/conf.c
e7ccf0
+++ b/src/conf.c
e7ccf0
@@ -663,7 +663,7 @@ static int input_stdio_open(snd_input_t **inputp, const char *file,
e7ccf0
 	return err;
e7ccf0
 }
e7ccf0
 
e7ccf0
-int safe_strtoll_base(const char *str, long long *val, int base)
e7ccf0
+int _snd_safe_strtoll_base(const char *str, long long *val, int base)
e7ccf0
 {
e7ccf0
 	char *end;
e7ccf0
 	long v;
e7ccf0
@@ -679,7 +679,7 @@ int safe_strtoll_base(const char *str, long long *val, int base)
e7ccf0
 	return 0;
e7ccf0
 }
e7ccf0
 
e7ccf0
-int safe_strtol_base(const char *str, long *val, int base)
e7ccf0
+int _snd_safe_strtol_base(const char *str, long *val, int base)
e7ccf0
 {
e7ccf0
 	char *end;
e7ccf0
 	long v;
e7ccf0
@@ -695,7 +695,7 @@ int safe_strtol_base(const char *str, long *val, int base)
e7ccf0
 	return 0;
e7ccf0
 }
e7ccf0
 
e7ccf0
-static int safe_strtod(const char *str, double *val)
e7ccf0
+int _snd_safe_strtod(const char *str, double *val)
e7ccf0
 {
e7ccf0
 	char *end;
e7ccf0
 	double v;
e7ccf0
-- 
e7ccf0
2.34.1
e7ccf0
e7ccf0
e7ccf0
From 3dbe072d8deba7c11f6e766ef80c0e50a69447d0 Mon Sep 17 00:00:00 2001
e7ccf0
From: Jaroslav Kysela <perex@perex.cz>
e7ccf0
Date: Thu, 27 Jan 2022 18:25:00 +0100
e7ccf0
Subject: [PATCH 4/4] conf: snd_config_merge - fix comment (overwrite /
e7ccf0
 override)
e7ccf0
e7ccf0
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
e7ccf0
---
e7ccf0
 src/conf.c | 2 +-
e7ccf0
 1 file changed, 1 insertion(+), 1 deletion(-)
e7ccf0
e7ccf0
diff --git a/src/conf.c b/src/conf.c
e7ccf0
index 098ebd63..70f0e773 100644
e7ccf0
--- a/src/conf.c
e7ccf0
+++ b/src/conf.c
e7ccf0
@@ -2276,7 +2276,7 @@ static int _snd_config_array_merge(snd_config_t *dst, snd_config_t *src, int ind
e7ccf0
  *
e7ccf0
  * \par Errors:
e7ccf0
  * 
e7ccf0
- * 
-EEXIST
identifier already exists (!overwrite)
e7ccf0
+ * 
-EEXIST
identifier already exists (!override)
e7ccf0
  * 
-ENOMEM
not enough memory
e7ccf0
  * 
e7ccf0
  */
e7ccf0
-- 
e7ccf0
2.34.1
e7ccf0