xref: /OK3568_Linux_fs/buildroot/package/iwd/0001-build-Add-reallocarray-to-missing-h.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunFrom ec1c348b4fd67619fa0c2f55ae644f6a8014d971 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3*4882a593SmuzhiyunDate: Sun, 19 Sep 2021 21:17:44 +0200
4*4882a593SmuzhiyunSubject: build: Add reallocarray to missing.h
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunreallocarray has been added to glibc relatively recently (version 2.26,
7*4882a593Smuzhiyunfrom 2017) and apparently not all users run new enough glibc. Moreover,
8*4882a593Smuzhiyunreallocarray is not available with uclibc-ng. So use realloc if
9*4882a593Smuzhiyunreallocarray is not available to avoid the following build failure
10*4882a593Smuzhiyunraised since commit 891b78e9e892a3bcd800eb3a298e6380e9a15dd1:
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun/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':
13*4882a593Smuzhiyunsae.c:(.text+0xd74): undefined reference to `reallocarray'
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunFixes:
16*4882a593Smuzhiyun - http://autobuild.buildroot.org/results/c6d3f86282c44645b4f1c61882dc63ccfc8eb35a
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun[Retrieved from:
19*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=ec1c348b4fd67619fa0c2f55ae644f6a8014d971]
20*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
21*4882a593Smuzhiyun---
22*4882a593Smuzhiyun configure.ac  | 1 +
23*4882a593Smuzhiyun src/missing.h | 7 +++++++
24*4882a593Smuzhiyun 2 files changed, 8 insertions(+)
25*4882a593Smuzhiyun
26*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac
27*4882a593Smuzhiyunindex c6250401..51d9da93 100644
28*4882a593Smuzhiyun--- a/configure.ac
29*4882a593Smuzhiyun+++ b/configure.ac
30*4882a593Smuzhiyun@@ -129,6 +129,7 @@ AC_DEFINE_UNQUOTED(WIRED_STORAGEDIR, "${wired_storagedir}",
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun AC_CHECK_FUNCS(explicit_bzero)
33*4882a593Smuzhiyun AC_CHECK_FUNCS(rawmemchr)
34*4882a593Smuzhiyun+AC_CHECK_FUNCS(reallocarray)
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
37*4882a593Smuzhiyun
38*4882a593Smuzhiyundiff --git a/src/missing.h b/src/missing.h
39*4882a593Smuzhiyunindex 2cc80aee..a5b92952 100644
40*4882a593Smuzhiyun--- a/src/missing.h
41*4882a593Smuzhiyun+++ b/src/missing.h
42*4882a593Smuzhiyun@@ -37,3 +37,10 @@ _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"")
43*4882a593Smuzhiyun _Pragma("GCC diagnostic pop")
44*4882a593Smuzhiyun }
45*4882a593Smuzhiyun #endif
46*4882a593Smuzhiyun+
47*4882a593Smuzhiyun+#ifndef HAVE_REALLOCARRAY
48*4882a593Smuzhiyun+static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
49*4882a593Smuzhiyun+{
50*4882a593Smuzhiyun+	return realloc(ptr, nmemb * size);
51*4882a593Smuzhiyun+}
52*4882a593Smuzhiyun+#endif
53*4882a593Smuzhiyun--
54*4882a593Smuzhiyuncgit 1.2.3-1.el7
55*4882a593Smuzhiyun
56