]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
libcgroup: Use GNU strerror_r only when its available
authorKhem Raj <raj.khem@gmail.com>
Wed, 24 Aug 2022 06:34:39 +0000 (23:34 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 25 Aug 2022 10:07:33 +0000 (11:07 +0100)
This patch ensures that a fallback to use XSI compliant strerror_r when
GNU extention is not implemented, which fixes the case when building
with musl

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/libcgroup/libcgroup/0001-api-Use-GNU-strerror_r-when-available.patch [new file with mode: 0644]
meta/recipes-core/libcgroup/libcgroup_3.0.0.bb

diff --git a/meta/recipes-core/libcgroup/libcgroup/0001-api-Use-GNU-strerror_r-when-available.patch b/meta/recipes-core/libcgroup/libcgroup/0001-api-Use-GNU-strerror_r-when-available.patch
new file mode 100644 (file)
index 0000000..96321d2
--- /dev/null
@@ -0,0 +1,55 @@
+From d190c0c548b3219b75e4c399aa89186e77bbe270 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 23 Aug 2022 20:03:09 -0700
+Subject: [PATCH] api: Use GNU strerror_r when available
+
+GNU strerror_r is only available in glibc, musl impelents the XSI
+version which is slightly different, therefore check if GNU version is
+available before using it, otherwise use the XSI compliant version.
+
+Upstream-Status: Submitted [https://github.com/libcgroup/libcgroup/pull/236]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ configure.ac | 5 +++++
+ src/api.c    | 8 ++++++--
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b68c655..831866d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -183,6 +183,11 @@ AC_FUNC_REALLOC
+ AC_FUNC_STAT
+ AC_CHECK_FUNCS([getmntent hasmntopt memset mkdir rmdir strdup])
++orig_CFLAGS="$CFLAGS"
++CFLAGS="$CFLAGS -D_GNU_SOURCE"
++AC_FUNC_STRERROR_R
++CFLAGS="$orig_CFLAGS"
++
+ AC_SEARCH_LIBS(
+       [fts_open],
+       [fts],
+diff --git a/src/api.c b/src/api.c
+index 5c6de11..06aa1d6 100644
+--- a/src/api.c
++++ b/src/api.c
+@@ -4571,9 +4571,13 @@ const char *cgroup_strerror(int code)
+ {
+       int idx = code % ECGROUPNOTCOMPILED;
+-      if (code == ECGOTHER)
++      if (code == ECGOTHER) {
++#ifdef STRERROR_R_CHAR_P
+               return strerror_r(cgroup_get_last_errno(), errtext, MAXLEN);
+-
++#else
++              return strerror_r(cgroup_get_last_errno(), errtext, sizeof (errtext)) ? "unknown error" : errtext;
++#endif
++      }
+       if (idx >= sizeof(cgroup_strerror_codes)/sizeof(cgroup_strerror_codes[0]))
+               return "Invalid error code";
+-- 
+2.37.2
+
index efd887844ded9a68ce299e38541ca00d12b88780..f3e841246f951abbfaca9b1ccda403f215de2cd9 100644 (file)
@@ -11,7 +11,9 @@ inherit autotools pkgconfig
 
 DEPENDS = "bison-native flex-native"
 
-SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/v3.0/${BP}.tar.gz"
+SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/v3.0/${BP}.tar.gz \
+           file://0001-api-Use-GNU-strerror_r-when-available.patch \
+"
 
 SRC_URI[sha256sum] = "8d284d896fca1c981b55850e92acd3ad9648a69227c028dda7ae3402af878edd"
 UPSTREAM_CHECK_URI = "https://github.com/libcgroup/libcgroup/releases/"