From 30de25eb3efdf65b1870da1f91ddc62108c17a98 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Thu, 3 Feb 2022 13:30:05 +0100 Subject: [PATCH] Provide replacement function for strerror_l() strerror_l() is not implemented in some C libraries, such as uClibc, so let's provide a simple replacement function that falls back on strerror(). Signed-off-by: Thomas Petazzoni [Retrieved from: https://git.buildroot.net/buildroot/tree/package/libblockdev/0001-Provide-replacement-function-for-strerror_l.patch] Signed-off-by: Fabrice Fontaine --- configure.ac | 2 ++ src/plugins/crypto.c | 7 +++++++ src/utils/module.c | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 8b783a877..5c83e2a46 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,8 @@ AC_CHECK_HEADERS([dlfcn.h string.h unistd.h sys/fcntl.h sys/ioctl.h linux/random [LIBBLOCKDEV_SOFT_FAILURE([Header file $ac_header not found.])], []) +AC_CHECK_FUNCS([strerror_l]) + AC_ARG_WITH([bcache], AS_HELP_STRING([--with-bcache], [support bcache @<:@default=yes@:>@]), [], diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c index 8beae0985..f7646ec94 100644 --- a/src/plugins/crypto.c +++ b/src/plugins/crypto.c @@ -71,6 +71,13 @@ #define UNUSED __attribute__((unused)) +#if !defined(HAVE_STRERROR_L) +static char *strerror_l(int errnum, locale_t locale UNUSED) +{ + return strerror(errnum); +} +#endif + /** * SECTION: crypto * @short_description: plugin for operations with encrypted devices diff --git a/src/utils/module.c b/src/utils/module.c index 254ee251c..0870485ed 100644 --- a/src/utils/module.c +++ b/src/utils/module.c @@ -259,6 +259,14 @@ gboolean bd_utils_unload_kernel_module (const gchar *module_name, GError **error return TRUE; } +#define UNUSED __attribute__((unused)) + +#if !defined(HAVE_STRERROR_L) +static char *strerror_l(int errnum, locale_t locale UNUSED) +{ + return strerror(errnum); +} +#endif static BDUtilsLinuxVersion detected_linux_ver; static gboolean have_linux_ver = FALSE;