Skip to contentSkip to conversation

uapi: Fix userspace compilation of ip_tables.h/ip6_tables.h in C++ mode

PATCH New Jason Gunthorpe 1 participant 1 message Oct 25, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uapi: Fix userspace compilation of ip_tables.h/ip6_tables.h in C++ mode

The implicit cast from void * is not allowed for C++ compilers, and the arithmetic on void * generates warnings if a C++ application tries to include these UAPI headers.

$ g++ -c t.cc
ip_tables.h:221:24: warning: pointer of type 'void *' used in arithmetic
ip_tables.h:221:24: error: invalid conversion from 'void*' to 'xt_entry_target*'
---
 include/uapi/linux/netfilter_ipv4/ip_tables.h  | 2 +-
 include/uapi/linux/netfilter_ipv6/ip6_tables.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/netfilter_ipv4/ip_tables.h +1 -1
index d0da53d96d93..4682b18f3f44 100644
@@ -221,7 +221,7 @@ struct ipt_get_entries {
 static __inline__ struct xt_entry_target *
 ipt_get_target(struct ipt_entry *e)
 {
-	return (void *)e + e->target_offset;
+	return (struct xt_entry_target *)((__u8 *)e + e->target_offset);
 }
 
 /*
include/uapi/linux/netfilter_ipv6/ip6_tables.h +1 -1
index d1b22653daf2..05e0631a6d12 100644
@@ -261,7 +261,7 @@ struct ip6t_get_entries {
 static __inline__ struct xt_entry_target *
 ip6t_get_target(struct ip6t_entry *e)
 {
-	return (void *)e + e->target_offset;
+	return (struct xt_entry_target *)((__u8 *)e + e->target_offset);
 }
 
 /*
Signature · 1 line
2.1.4