]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd: Add another fix for using XSI strerror_r
authorKhem Raj <raj.khem@gmail.com>
Wed, 25 Jan 2023 04:03:56 +0000 (20:03 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 26 Jan 2023 21:05:52 +0000 (21:05 +0000)
This makes systemd continue to work on musl

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd/0001-errno-util-Make-STRERROR-portable-for-musl.patch [new file with mode: 0644]
meta/recipes-core/systemd/systemd_252.4.bb

diff --git a/meta/recipes-core/systemd/systemd/0001-errno-util-Make-STRERROR-portable-for-musl.patch b/meta/recipes-core/systemd/systemd/0001-errno-util-Make-STRERROR-portable-for-musl.patch
new file mode 100644 (file)
index 0000000..2fb8985
--- /dev/null
@@ -0,0 +1,42 @@
+From f66b5c802ce0a3310f5580cfc1b02446f8087568 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 23 Jan 2023 23:39:46 -0800
+Subject: [PATCH] errno-util: Make STRERROR portable for musl
+
+Sadly, systemd has decided to use yet another GNU extention in a macro
+lets make this such that we can use XSI compliant strerror_r() for
+non-glibc hosts
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/basic/errno-util.h | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h
+index 091f99c590..eb5c1f9961 100644
+--- a/src/basic/errno-util.h
++++ b/src/basic/errno-util.h
+@@ -14,8 +14,16 @@
+  * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks
+  *
+  * Note that we use the GNU variant of strerror_r() here. */
+-#define STRERROR(errnum) strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
+-
++static inline const char * STRERROR(int errnum);
++
++static inline const char * STRERROR(int errnum) {
++#ifdef __GLIBC__
++        return strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN);
++#else
++        static __thread char buf[ERRNO_BUF_LEN];
++        return strerror_r(abs(errnum), buf, ERRNO_BUF_LEN) ? "unknown error" : buf;
++#endif
++}
+ /* A helper to print an error message or message for functions that return 0 on EOF.
+  * Note that we can't use ({ … }) to define a temporary variable, so errnum is
+  * evaluated twice. */
+-- 
+2.39.1
+
index d291a2a9a1faa19144869d8e6eb76101feb1529f..e6c873f53be22c930c3a21052d4ee6a4576a9673 100644 (file)
@@ -50,6 +50,7 @@ SRC_URI_MUSL = "\
                file://0002-Add-sys-stat.h-for-S_IFDIR.patch \
                file://0001-Adjust-for-musl-headers.patch \
                file://0001-test-bus-error-strerror-is-assumed-to-be-GNU-specifi.patch \
+               file://0001-errno-util-Make-STRERROR-portable-for-musl.patch \
                "
 
 PAM_PLUGINS = " \