1From 01883cc14904e55d90955ad7cd9fc55bc18364ac Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
3Date: Sat, 20 Jan 2024 13:29:28 +0100
4Subject: [PATCH] Provide replacement function for strerror_l()
5
6strerror_l() is not implemented in some C libraries, such as uClibc,
7so let's provide a simple replacement define that falls back on
8strerror() in utils.h header and include it where missing.
9
10Upstream: N/A since it's due uclibc only
11
12Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
13Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
14[Giulio: ported to version 3.0 and 3.1]
15---
16 configure.ac       | 2 ++
17 src/utils/module.c | 1 +
18 src/utils/utils.h  | 4 ++++
19 3 files changed, 7 insertions(+)
20
21diff --git a/configure.ac b/configure.ac
22index 02b26e3e..67341134 100644
23--- a/configure.ac
24+++ b/configure.ac
25@@ -120,6 +120,8 @@ AC_CHECK_HEADERS([dlfcn.h string.h unistd.h sys/fcntl.h sys/ioctl.h linux/random
26                  [LIBBLOCKDEV_SOFT_FAILURE([Header file $ac_header not found.])],
27                  [])
28
29+AC_CHECK_FUNCS([strerror_l])
30+
31 AC_ARG_WITH([escrow],
32     AS_HELP_STRING([--with-escrow], [support escrow @<:@default=yes@:>@]),
33     [],
34diff --git a/src/utils/module.c b/src/utils/module.c
35index 6557c3ab..5893f0ac 100644
36--- a/src/utils/module.c
37+++ b/src/utils/module.c
38@@ -28,6 +28,7 @@
39 #include "module.h"
40 #include "exec.h"
41 #include "logging.h"
42+#include "utils.h"
43
44 #define UNUSED __attribute__((unused))
45
46diff --git a/src/utils/utils.h b/src/utils/utils.h
47index 801a8b6e..b2bdf0d0 100644
48--- a/src/utils/utils.h
49+++ b/src/utils/utils.h
50@@ -9,6 +9,10 @@
51 #include "dbus.h"
52 #include "logging.h"
53
54+#if !defined(HAVE_STRERROR_L)
55+#define strerror_l(errnum, locale)      strerror(errnum)
56+#endif
57+
58 /**
59  * SECTION: utils
60  * @short_description: library providing utility functions used by the blockdev library and its plugins
61--
622.34.1
63
64