Skip to contentSkip to conversation

src: Make the library compile under clang

PATCH Applied Kevin Cernekee 2 participants 2 messages Aug 14, 2016 – Aug 17, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 src: Make the library compile under clang

clang treats "char buffer[size]" inside a union as VLAIS unless |size| is const:

src/conntrack/api.c:992:8: error: fields must have a constant size: 'variable length array in structure' extension will never be supported

                char buffer[size];
                     ^
---
 src/conntrack/api.c | 4 ++--
 src/expect/api.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
src/conntrack/api.c +2 -2
index e4d4acc312bb..bed2e42c8f43 100644
@@ -955,7 +955,7 @@ int nfct_query(struct nfct_handle *h,
 	       const enum nf_conntrack_query qt,
 	       const void *data)
 {
-	size_t size = 4096;	/* enough for now */
+	const size_t size = 4096;	/* enough for now */
 	union {
 		char buffer[size];
 		struct nfnlhdr req;
@@ -987,7 +987,7 @@ int nfct_send(struct nfct_handle *h,
 	      const enum nf_conntrack_query qt,
 	      const void *data)
 {
-	size_t size = 4096;	/* enough for now */
+	const size_t size = 4096;	/* enough for now */
 	union {
 		char buffer[size];
 		struct nfnlhdr req;
src/expect/api.c +2 -2
index 8ff20e2821e3..3f1763038ede 100644
@@ -669,7 +669,7 @@ int nfexp_query(struct nfct_handle *h,
 	        const enum nf_conntrack_query qt,
 	        const void *data)
 {
-	size_t size = 4096;	/* enough for now */
+	const size_t size = 4096;	/* enough for now */
 	union {
 		char buffer[size];
 		struct nfnlhdr req;
@@ -701,7 +701,7 @@ int nfexp_send(struct nfct_handle *h,
 	       const enum nf_conntrack_query qt,
 	       const void *data)
 {
-	size_t size = 4096;	/* enough for now */
+	const size_t size = 4096;	/* enough for now */
 	union {
 		char buffer[size];
 		struct nfnlhdr req;
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer Applied
#1 lore raw
Quoted 6 lines · Kevin Cernekee

clang treats "char buffer[size]" inside a union as VLAIS unless |size| is const:

src/conntrack/api.c:992:8: error: fields must have a constant size: 'variable length array in structure' extension will never be supported

                char buffer[size];
                     ^

Applied, thanks.