0001-build-Add-reallocarray-to-missing-h.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From ec1c348b4fd67619fa0c2f55ae644f6a8014d971 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sun, 19 Sep 2021 21:17:44 +0200
  4. Subject: build: Add reallocarray to missing.h
  5. reallocarray has been added to glibc relatively recently (version 2.26,
  6. from 2017) and apparently not all users run new enough glibc. Moreover,
  7. reallocarray is not available with uclibc-ng. So use realloc if
  8. reallocarray is not available to avoid the following build failure
  9. raised since commit 891b78e9e892a3bcd800eb3a298e6380e9a15dd1:
  10. /home/giuliobenetti/autobuild/run/instance-3/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/10.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: src/sae.o: in function `sae_rx_authenticate':
  11. sae.c:(.text+0xd74): undefined reference to `reallocarray'
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/c6d3f86282c44645b4f1c61882dc63ccfc8eb35a
  14. [Retrieved from:
  15. https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=ec1c348b4fd67619fa0c2f55ae644f6a8014d971]
  16. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  17. ---
  18. configure.ac | 1 +
  19. src/missing.h | 7 +++++++
  20. 2 files changed, 8 insertions(+)
  21. diff --git a/configure.ac b/configure.ac
  22. index c6250401..51d9da93 100644
  23. --- a/configure.ac
  24. +++ b/configure.ac
  25. @@ -129,6 +129,7 @@ AC_DEFINE_UNQUOTED(WIRED_STORAGEDIR, "${wired_storagedir}",
  26. AC_CHECK_FUNCS(explicit_bzero)
  27. AC_CHECK_FUNCS(rawmemchr)
  28. +AC_CHECK_FUNCS(reallocarray)
  29. AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
  30. diff --git a/src/missing.h b/src/missing.h
  31. index 2cc80aee..a5b92952 100644
  32. --- a/src/missing.h
  33. +++ b/src/missing.h
  34. @@ -37,3 +37,10 @@ _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"")
  35. _Pragma("GCC diagnostic pop")
  36. }
  37. #endif
  38. +
  39. +#ifndef HAVE_REALLOCARRAY
  40. +static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
  41. +{
  42. + return realloc(ptr, nmemb * size);
  43. +}
  44. +#endif
  45. --
  46. cgit 1.2.3-1.el7