0001-Provide-replacement-function-for-strerror_l.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From ccf93148aa3587dd98a02e253cdc42a7af14df1e Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sat, 29 Aug 2020 16:04:15 +0200
  4. Subject: [PATCH] Provide replacement function for strerror_l()
  5. strerror_l() is not implemented in some C libraries, such as uClibc,
  6. so let's provide a simple replacement function that falls back on
  7. strerror().
  8. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  9. ---
  10. configure.ac | 2 ++
  11. src/plugins/crypto.c | 7 +++++++
  12. src/utils/module.c | 8 ++++++++
  13. 3 files changed, 17 insertions(+)
  14. diff --git a/configure.ac b/configure.ac
  15. index c2d22c2..36aeb51 100644
  16. --- a/configure.ac
  17. +++ b/configure.ac
  18. @@ -137,6 +137,8 @@ AC_CHECK_HEADERS([dlfcn.h string.h unistd.h sys/fcntl.h sys/ioctl.h linux/random
  19. [LIBBLOCKDEV_SOFT_FAILURE([Header file $ac_header not found.])],
  20. [])
  21. +AC_CHECK_FUNCS([strerror_l])
  22. +
  23. AC_ARG_WITH([bcache],
  24. AS_HELP_STRING([--with-bcache], [support bcache @<:@default=yes@:>@]),
  25. [],
  26. diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
  27. index f4a2e8f..c1bd7b5 100644
  28. --- a/src/plugins/crypto.c
  29. +++ b/src/plugins/crypto.c
  30. @@ -52,6 +52,13 @@
  31. #define UNUSED __attribute__((unused))
  32. +#if !defined(HAVE_STRERROR_L)
  33. +static char *strerror_l(int errnum, locale_t locale UNUSED)
  34. +{
  35. + return strerror(errnum);
  36. +}
  37. +#endif
  38. +
  39. /**
  40. * SECTION: crypto
  41. * @short_description: plugin for operations with encrypted devices
  42. diff --git a/src/utils/module.c b/src/utils/module.c
  43. index 9750e24..086bec0 100644
  44. --- a/src/utils/module.c
  45. +++ b/src/utils/module.c
  46. @@ -27,6 +27,14 @@
  47. #include "module.h"
  48. +#define UNUSED __attribute__((unused))
  49. +
  50. +#if !defined(HAVE_STRERROR_L)
  51. +static char *strerror_l(int errnum, locale_t locale UNUSED)
  52. +{
  53. + return strerror(errnum);
  54. +}
  55. +#endif
  56. /**
  57. * bd_utils_module_error_quark: (skip)
  58. --
  59. 2.26.2