Blame SOURCES/alsa-git.patch

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