Skip to contentSkip to conversation

net-snmp: Fix build with gcc5

PATCH In review Khem Raj 2 participants 4 messages Oct 3, 2015

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 net-snmp: Fix build with gcc5

Fix errors seen with gcc5

Change-Id I9c4361f3a9c25342f5c740263f551c162dce8faf
---
 ...tools.c-Don-t-check-for-return-from-EVP_M.patch | 33 ++++++++++++++++++++++
 .../recipes-protocols/net-snmp/net-snmp_5.7.3.bb   |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch new file +33 -0
new file mode 100644
index 0000000..af242fa
@@ -0,0 +1,33 @@
+From d3027a227bc0f603a5b650d01f97ee1dec515be5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 18 Sep 2015 00:28:45 -0400
+Subject: [PATCH] snmplib/keytools.c: Don't check for return from
+ EVP_MD_CTX_init()
+
+EVP_MD_CTX_init() API returns void, it fixes errors with new compilers
+
+snmplib/keytools.c: In function 'generate_Ku': error: invalid use of void expression
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+Upstream-Status: Submitted [https://sourceforge.net/p/net-snmp/patches/1317/]
+ snmplib/keytools.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/snmplib/keytools.c b/snmplib/keytools.c
+index 0ccb3a6..880fc14 100644
+--- a/snmplib/keytools.c
++++ b/snmplib/keytools.c
+@@ -153,8 +153,7 @@ generate_Ku(const oid * hashtype, u_int hashtype_len,
+     ctx = EVP_MD_CTX_create();
+ #else
+     ctx = malloc(sizeof(*ctx));
+-    if (!EVP_MD_CTX_init(ctx))
+-        return SNMPERR_GENERR;
++    EVP_MD_CTX_init(ctx);
+ #endif
+ #ifndef NETSNMP_DISABLE_MD5
+     if (ISTRANSFORM(hashtype, HMACMD5Auth)) {
+-- 
+2.5.2
+
meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.3.bb +1 -0
index 431a633..b32d842 100644
@@ -20,6 +20,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.zip \
         file://run-ptest \
         file://dont-return-incompletely-parsed-varbinds.patch \
         file://0001-config_os_headers-Error-Fix.patch \
+        file://0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch \
 "
 SRC_URI[md5sum] = "9f682bd70c717efdd9f15b686d07baee"
 SRC_URI[sha256sum] = "e8dfc79b6539b71a6ff335746ce63d2da2239062ad41872fff4354cafed07a3e"
Signature · 1 line
2.6.0
author
#1 lore raw

PATCH 2/2 libnetfilter: Avoid using VLAs

VLAs in non POD data types like structures and unions
are not a standard feature of C language and gcc has specific implementation which other compilers dont have specifically clang, and they refuse to implement it since its non standard.

Change-Id I6ae24adb455bf262fe9406a1c8e3b3a4a0cf77d4
---
 .../libnetfilter/files/replace-VLAs-in-union.patch | 89 ++++++++++++++++++++++
 .../libnetfilter/libnetfilter-conntrack_1.0.4.bb   |  4 +-
 2 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 meta-networking/recipes-filter/libnetfilter/files/replace-VLAs-in-union.patch
meta-networking/recipes-filter/libnetfilter/files/replace-VLAs-in-union.patch new file +89 -0
new file mode 100644
index 0000000..16e4af4
@@ -0,0 +1,89 @@
+VLAs in structs and unions (non-PODs) is unsupported in non-gcc compilers
+therefore convert it to not use VLAs instead use fixed arrays
+
+Signed-off-by: Khem Raj <[email protected]>
+Upstream-Status: Pending
+Index: libnetfilter_conntrack-1.0.4/src/conntrack/api.c
+===================================================================
+--- libnetfilter_conntrack-1.0.4.orig/src/conntrack/api.c
++++ libnetfilter_conntrack-1.0.4/src/conntrack/api.c
+@@ -954,16 +954,15 @@ int nfct_query(struct nfct_handle *h,
+ 	       const enum nf_conntrack_query qt,
+ 	       const void *data)
+ {
+-	size_t size = 4096;	/* enough for now */
+ 	union {
+-		char buffer[size];
++		char buffer[4096];
+ 		struct nfnlhdr req;
+ 	} u;
+ 
+ 	assert(h != NULL);
+ 	assert(data != NULL);
+ 
+-	if (__build_query_ct(h->nfnlssh_ct, qt, data, &u.req, size) == -1)
++	if (__build_query_ct(h->nfnlssh_ct, qt, data, &u.req, 4096) == -1)
+ 		return -1;
+ 
+ 	return nfnl_query(h->nfnlh, &u.req.nlh);
+@@ -986,16 +985,15 @@ int nfct_send(struct nfct_handle *h,
+ 	      const enum nf_conntrack_query qt,
+ 	      const void *data)
+ {
+-	size_t size = 4096;	/* enough for now */
+ 	union {
+-		char buffer[size];
++		char buffer[4096];
+ 		struct nfnlhdr req;
+ 	} u;
+ 
+ 	assert(h != NULL);
+ 	assert(data != NULL);
+ 
+-	if (__build_query_ct(h->nfnlssh_ct, qt, data, &u.req, size) == -1)
++	if (__build_query_ct(h->nfnlssh_ct, qt, data, &u.req, 4096) == -1)
+ 		return -1;
+ 
+ 	return nfnl_send(h->nfnlh, &u.req.nlh);
+Index: libnetfilter_conntrack-1.0.4/src/expect/api.c
+===================================================================
+--- libnetfilter_conntrack-1.0.4.orig/src/expect/api.c
++++ libnetfilter_conntrack-1.0.4/src/expect/api.c
+@@ -669,16 +669,15 @@ int nfexp_query(struct nfct_handle *h,
+ 	        const enum nf_conntrack_query qt,
+ 	        const void *data)
+ {
+-	size_t size = 4096;	/* enough for now */
+ 	union {
+-		char buffer[size];
++		char buffer[4096];
+ 		struct nfnlhdr req;
+ 	} u;
+ 
+ 	assert(h != NULL);
+ 	assert(data != NULL);
+ 
+-	if (__build_query_exp(h->nfnlssh_exp, qt, data, &u.req, size) == -1)
++	if (__build_query_exp(h->nfnlssh_exp, qt, data, &u.req, 4096) == -1)
+ 		return -1;
+ 
+ 	return nfnl_query(h->nfnlh, &u.req.nlh);
+@@ -701,16 +700,15 @@ int nfexp_send(struct nfct_handle *h,
+ 	       const enum nf_conntrack_query qt,
+ 	       const void *data)
+ {
+-	size_t size = 4096;	/* enough for now */
+ 	union {
+-		char buffer[size];
++		char buffer[4096];
+ 		struct nfnlhdr req;
+ 	} u;
+ 
+ 	assert(h != NULL);
+ 	assert(data != NULL);
+ 
+-	if (__build_query_exp(h->nfnlssh_exp, qt, data, &u.req, size) == -1)
++	if (__build_query_exp(h->nfnlssh_exp, qt, data, &u.req, 4096) == -1)
+ 		return -1;
+ 
+ 	return nfnl_send(h->nfnlh, &u.req.nlh);
meta-networking/recipes-filter/libnetfilter/libnetfilter-conntrack_1.0.4.bb +3 -1
index c1df1cb..ecbc86b 100644
@@ -6,7 +6,9 @@ LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b"
 DEPENDS = "libnfnetlink libmnl"
 
-SRC_URI = "http://www.netfilter.org/projects/libnetfilter_conntrack/files/libnetfilter_conntrack-${PV}.tar.bz2;name=tar"
+SRC_URI = "http://www.netfilter.org/projects/libnetfilter_conntrack/files/libnetfilter_conntrack-${PV}.tar.bz2;name=tar \
+           file://replace-VLAs-in-union.patch \
+"
 SRC_URI[tar.md5sum] = "18cf80c4b339a3285e78822dbd4f08d7"
 SRC_URI[tar.sha256sum] = "d9ec4a3caf49417f2b0a2d8d44249133e8c3ec78c757b7eb8c273f1cb6929c7d"
 
Signature · 1 line
2.6.0
#2 lore raw

Re: [meta-networking][PATCH 2/2] libnetfilter: Avoid using VLAs

Quoted 4 lines · Khem Raj

VLAs in non POD data types like structures and unions
are not a standard feature of C language and gcc has specific implementation which other compilers dont have specifically clang, and they refuse to implement it since its non standard.

The reference to "POD" here is a bit confusing. By the generally accepted meaning of the term, structs and unions would in fact be POD just like any other C type. But you seem to be using the term here to mean something along the lines of "non-aggregate type", which isn't a usage I've previously encountered.

This is particularly confusing in this context because there is a different clang limitation which applies to VLAs where the variable-length element is not POD, irrespective of whether it is inside an aggregate or not, and someone reading your comment might be misled into thinking that this was the issue here.

p.

author
#3 lore raw

Re: [meta-networking][PATCH 2/2] libnetfilter: Avoid using VLAs

Quoted 12 lines · Phil Blundell
Quoted 4 lines · Khem Raj

VLAs in non POD data types like structures and unions
are not a standard feature of C language and gcc has specific implementation which other compilers dont have specifically clang, and they refuse to implement it since its non standard.

The reference to "POD" here is a bit confusing. By the generally accepted meaning of the term, structs and unions would in fact be POD just like any other C type. But you seem to be using the term here to mean something along the lines of "non-aggregate type", which isn't a usage I've previously encountered.

Quoted 5 lines

This is particularly confusing in this context because there is a different clang limitation which applies to VLAs where the variable-length element is not POD, irrespective of whether it is inside an aggregate or not, and someone reading your comment might be misled into thinking that this was the issue here.

Yes, infact I should have said composite data types instead of non-POD data types. I will send a v2 which should
clear this confusion.

Quoted 9 lines

p.

--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel