]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
utils: define xfree() as macro
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 20 Aug 2014 12:51:12 +0000 (14:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 20 Aug 2014 13:03:46 +0000 (15:03 +0200)
Original description from Thomas Petazzoni:

When ELF binaries and shared libraries are used, the internal
functions of libnftnl such as xfree() are not visible to the outside
world (their visibility is 'hidden'). Therefore, the fact that other
programs (especially nftables) may have symbols with the same name
does not cause any problem.

However, when doing static linking on a non-ELF platform (such as
Blackfin, which uses the FLAT binary format), there is no way of
encoding this visibility. Therefore, the xfree() symbols of libnftnl
becomes visible to the outside world, causing a conflict with the
xfree() symbol defined by nftables.

To solve this, this patch convers xfree as a macro instead of
a function.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/internal.h
src/utils.c

index e76a5cb2b0db8498e9d93bec34732324f963de7c..c8dea7e8999c618c2ebc820cf45919123c136dee 100644 (file)
@@ -16,6 +16,8 @@
 #include <libnftnl/common.h>
 #include <linux/netfilter/nf_tables.h>
 
+#define xfree(ptr)     free((void *)ptr);
+
 #define BASE_DEC 10
 #define BASE_HEX 16
 
@@ -144,8 +146,6 @@ int nft_event_footer_snprintf(char *buf, size_t bufsize,
                              uint32_t format, uint32_t flags);
 int nft_event_footer_fprintf(FILE *fp, uint32_t format, uint32_t flags);
 
-void xfree(const void *ptr);
-
 struct expr_ops;
 
 struct nft_rule_expr {
index 1878390c17ef3d564878344b3bbc75c4120663ad..96c8bf22fc7a1a1c0e0a157fcb882f6013bf54df 100644 (file)
@@ -180,11 +180,6 @@ int nft_str2verdict(const char *verdict, int *verdict_num)
        return -1;
 }
 
-void xfree(const void *ptr)
-{
-       free((void *)ptr);
-}
-
 int nft_fprintf(FILE *fp, void *obj, uint32_t type, uint32_t flags,
                int (*snprintf_cb)(char *buf, size_t bufsiz, void *obj,
                                   uint32_t type, uint32_t flags))