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

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