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