src/sae.c: fix build without reallocarray
Fabrice Fontaine
PATCH v2 1/1 src/sae.c: fix build without reallocarray
reallocarray has been added to glibc relatively recently (version 2.26, from 2017) and apparently not all users run new enough glibc. Moreover, reallocarray is not available with uclibc-ng. So use realloc if reallocarray is not available to avoid the following build failure raised since commit 891b78e9e892a3bcd800eb3a298e6380e9a15dd1:
/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':
sae.c:(.text+0xd74): undefined reference to `reallocarray'
Fixes:
- http://autobuild.buildroot.org/results/c6d3f86282c44645b4f1c61882dc63ccfc8eb35a
---
Changes v1 -> v2 (after review of Denis Kenzior):
- Remove SoB
- Add reallocarray to missing.h
configure.ac | 1 + src/missing.h | 7 +++++++ 2 files changed, 8 insertions(+)
configure.ac +1 -0
@@ -129,6 +129,7 @@ AC_DEFINE_UNQUOTED(WIRED_STORAGEDIR, "${wired_storagedir}", AC_CHECK_FUNCS(explicit_bzero) AC_CHECK_FUNCS(rawmemchr) +AC_CHECK_FUNCS(reallocarray) AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
src/missing.h +7 -0
@@ -37,3 +37,10 @@ _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"") _Pragma("GCC diagnostic pop") }#endif + +#ifndef HAVE_REALLOCARRAY +static inline void *reallocarray (void *ptr,size_t nmemb,size_t size) +{ +return realloc (ptr, nmemb * size); +} +#endif
Signature · 1 line
2.33.0
Denis Kenzior
Hi Fabrice,
Quoted 16 lines · Fabrice Fontaine
reallocarray has been added to glibc relatively recently (version 2.26, from 2017) and apparently not all users run new enough glibc. Moreover, reallocarray is not available with uclibc-ng. So use realloc if reallocarray is not available to avoid the following build failure raised since commit
891b78e9e892a3bcd800eb3a298e6380e9a15dd1:
/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':
sae.c:(.text+0xd74): undefined reference to `reallocarray'Fixes:
- http://autobuild.buildroot.org/results/c6d3f86282c44645b4f1c61882dc63ccfc8eb35a
---
Changes v1 -> v2 (after review of Denis Kenzior):
- Remove SoB
- Add reallocarray tomissing.h
Quoted 4 lines
configure.ac | 1 + src/missing.h | 7 +++++++ 2 files changed, 8 insertions(+)
Applied after re-wording the commit header slightly. Thanks!
Regards,
-Denis