diff mbox series

[iptables] include: Use char* for arithmetic over void*

Message ID 20181220050833.GA28675@janus
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [iptables] include: Use char* for arithmetic over void* | expand

Commit Message

William Woodruff Dec. 20, 2018, 5:08 a.m. UTC
Per my earlier proposal, replaces use of (void *) for pointer
arithmetic in three inline functions and two macros within
the iptables includes. This makes it easier for C++ projects
built with clang to include these files.

I haven't submitted a patch via email in a long time,
so please let me know if I've broken any etiquette and/or
borked the patch in any way.

William Woodruff


---
 include/linux/netfilter/x_tables.h        | 4 ++--
 include/linux/netfilter_arp/arp_tables.h  | 2 +-
 include/linux/netfilter_ipv4/ip_tables.h  | 2 +-
 include/linux/netfilter_ipv6/ip6_tables.h | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

--
2.20.1

Comments

William Woodruff Dec. 20, 2018, 5:49 a.m. UTC | #1
On Thu, Dec 20, 2018 at 12:08:33AM -0500, William Woodruff wrote:
> Per my earlier proposal, replaces use of (void *) for pointer
> arithmetic in three inline functions and two macros within
> the iptables includes. This makes it easier for C++ projects
> built with clang to include these files.
>

Sorry, please ignore this patch. I missed some compiler warnings
while building.

I'll have a warning-free patch prepared tomorrow.
diff mbox series

Patch

diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 41209700..e63aeb96 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -133,7 +133,7 @@  struct xt_counters_info {
 	for (__i = sizeof(type);				\
 	     __i < (e)->target_offset;				\
 	     __i += __m->u.match_size) {			\
-		__m = (void *)e + __i;				\
+		__m = (char *)e + __i;				\
 								\
 		__ret = fn(__m , ## args);			\
 		if (__ret != 0)					\
@@ -151,7 +151,7 @@  struct xt_counters_info {
 								\
 	for (__i = 0, __n = 0; __i < (size);			\
 	     __i += __entry->next_offset, __n++) { 		\
-		__entry = (void *)(entries) + __i;		\
+		__entry = (char *)(entries) + __i;		\
 		if (__n < n)					\
 			continue;				\
 								\
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index bb1ec648..2b57da14 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -195,7 +195,7 @@  struct arpt_get_entries {
 /* Helper functions */
 static __inline__ struct xt_entry_target *arpt_get_target(struct arpt_entry *e)
 {
-	return (void *)e + e->target_offset;
+	return (char *)e + e->target_offset;
 }

 /*
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 38542b4f..d90f2526 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -218,7 +218,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 (char *)e + e->target_offset;
 }

 /*
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 640a1d09..4b6abe64 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -258,7 +258,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 (char *)e + e->target_offset;
 }

 /*