Blame SOURCES/alsa-git.patch

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