kmod: bump to version 24
[buildroot-gz.git] / package / quagga / 0003-lib-memory-fix-indirect-static-link-with-zlib.patch
blob6990f47cda1ce67d8fa2348cff47b9bf4eb8456b
1 From 008dd9771057dbbd7ce971c43bce2a0b05e2cf97 Mon Sep 17 00:00:00 2001
2 From: Baruch Siach <baruch@tkos.co.il>
3 Date: Sun, 21 Aug 2016 08:56:57 +0300
4 Subject: [PATCH] lib/memory: fix indirect static link with zlib
6 quagga SNMP support depends on netsnmp, that optionally depends on OpenSSL,
7 which in turn requires zlib. zlib exports the 'zcalloc' symbol, which collides
8 with a function of the same name in memory.c. This is not a problem when
9 linking dynamically, since quagga does not use zlib directly. But static
10 linking fails with the error:
12 CCLD ospfd
13 .../output/host/usr/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/libz.a(zutil.o): In function `zcalloc':
14 zutil.c:(.text+0x48): multiple definition of `zcalloc'
15 .../output/build/quagga-1.0.20160315/lib/.libs/libzebra.a(memory.o):memory.c:(.text+0x1a0): first defined here
17 Rename 'zcalloc' to 'zzcalloc' to avoid symbol collision.
19 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
20 ---
21 Patch status: posted upstream
22 https://lists.quagga.net/pipermail/quagga-dev/2016-August/016109.html
24 lib/memory.c | 14 ++++++++------
25 lib/memory.h | 4 ++--
26 2 files changed, 10 insertions(+), 8 deletions(-)
28 diff --git a/lib/memory.c b/lib/memory.c
29 index 269520d5a435..b1680a5e6f07 100644
30 --- a/lib/memory.c
31 +++ b/lib/memory.c
32 @@ -80,9 +80,11 @@ zmalloc (int type, size_t size)
35 * Allocate memory as in zmalloc, and also clear the memory.
36 + * Add an extra 'z' prefix to function name to avoid collision when linking
37 + * statically with zlib that exports the 'zcalloc' symbol.
39 void *
40 -zcalloc (int type, size_t size)
41 +zzcalloc (int type, size_t size)
43 void *memory;
45 @@ -97,9 +99,9 @@ zcalloc (int type, size_t size)
48 /*
49 - * Given a pointer returned by zmalloc or zcalloc, free it and
50 + * Given a pointer returned by zmalloc or zzcalloc, free it and
51 * return a pointer to a new size, basically acting like realloc().
52 - * Requires: ptr was returned by zmalloc, zcalloc, or zrealloc with the
53 + * Requires: ptr was returned by zmalloc, zzcalloc, or zrealloc with the
54 * same type.
55 * Effects: Returns a pointer to the new memory, or aborts.
57 @@ -109,7 +111,7 @@ zrealloc (int type, void *ptr, size_t size)
58 void *memory;
60 if (ptr == NULL) /* is really alloc */
61 - return zcalloc(type, size);
62 + return zzcalloc(type, size);
64 memory = realloc (ptr, size);
65 if (memory == NULL)
66 @@ -122,7 +124,7 @@ zrealloc (int type, void *ptr, size_t size)
69 * Free memory allocated by z*alloc or zstrdup.
70 - * Requires: ptr was returned by zmalloc, zcalloc, or zrealloc with the
71 + * Requires: ptr was returned by zmalloc, zzcalloc, or zrealloc with the
72 * same type.
73 * Effects: The memory is freed and may no longer be referenced.
75 @@ -196,7 +198,7 @@ mtype_zcalloc (const char *file, int line, int type, size_t size)
76 mstat[type].c_calloc++;
77 mstat[type].t_calloc++;
79 - memory = zcalloc (type, size);
80 + memory = zzcalloc (type, size);
81 mtype_log ("xcalloc", memory, file, line, type);
83 return memory;
84 diff --git a/lib/memory.h b/lib/memory.h
85 index 23962235dbfe..501352993d21 100644
86 --- a/lib/memory.h
87 +++ b/lib/memory.h
88 @@ -56,7 +56,7 @@ extern struct mlist mlists[];
89 mtype_zstrdup (__FILE__, __LINE__, (mtype), (str))
90 #else
91 #define XMALLOC(mtype, size) zmalloc ((mtype), (size))
92 -#define XCALLOC(mtype, size) zcalloc ((mtype), (size))
93 +#define XCALLOC(mtype, size) zzcalloc ((mtype), (size))
94 #define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
95 #define XFREE(mtype, ptr) do { \
96 zfree ((mtype), (ptr)); \
97 @@ -67,7 +67,7 @@ extern struct mlist mlists[];
99 /* Prototypes of memory function. */
100 extern void *zmalloc (int type, size_t size);
101 -extern void *zcalloc (int type, size_t size);
102 +extern void *zzcalloc (int type, size_t size);
103 extern void *zrealloc (int type, void *ptr, size_t size);
104 extern void zfree (int type, void *ptr);
105 extern char *zstrdup (int type, const char *str);
107 2.8.1