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