ip_tables.h does not compile when using g++
Hi,
I noticed a discussion on this list in May regarding this problem but nobody seemed to care.
The file linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.h is included by user space programs as well as the kernel, hence I think that it should compile using g++.
This patch makes it compile. Patch is also attached.
diff -ur linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.h linux-2.4.19-new/include/linux/netfilter_ipv4/ip_tables.h
--- linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.h Mon Feb 25
19:38:13 2002
+++ linux-2.4.19-new/include/linux/netfilter_ipv4/ip_tables.h Sat Sep 14
11:11:01 2002
@@ -292,7 +292,7 @@
static __inline__ struct ipt_entry_target * ipt_get_target(struct ipt_entry *e)
{
- return (void *)e + e->target_offset;
+ return ((struct ipt_entry_target *)((char *)e + e->target_offset));
}
/* fn returns 0 to continue iteration */
Regards,
Scott.
include/linux/netfilter_ipv4/ip_tables.h +1 -1
@@ -292,7 +292,7 @@static __inline__struct ipt_entry_target *ipt_get_target (struct ipt_entry *e) { -return (void *)e + e->target_offset; +return ((struct ipt_entry_target *)((char *)e + e->target_offset)); }/* fn returns 0 to continue iteration */
Quoted 3 lines · Scott Andrew Baillie
The file
linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.his included by user space programs as well as the kernel, hence I think that it should compile using g++.
You are right.
Quoted 10 lines
This patch makes it compile. Patch is also attached.
diff -ur
linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.hlinux-2.4.19-new/include/linux/netfilter_ipv4/ip_tables.h
---linux-2.4.19/include/linux/netfilter_ipv4/ip_tables.hMon Feb 25
19:38:13 2002
+++linux-2.4.19-new/include/linux/netfilter_ipv4/ip_tables.hSat Sep 14
11:11:01 2002
include/linux/netfilter_ipv4/ip_tables.h line 295
Quoted 5 lines
include/linux/netfilter_ipv4/ip_tables.h +1
-1@@ -292,7 +292,7 @@static __inline__struct ipt_entry_target *ipt_get_target (struct ipt_entry *e) { -return (void *)e + e->target_offset; +return ((struct ipt_entry_target *)((char *)e + e->target_offset));
why does it have to be (char *) ? There are no characters involved, hence it (in the spirit of this gcc extension) should be (void *).
The typecast to struct ipt_entry_target is correct, however.
Does it compile with
return ((struct ipt_entry_target *)((void *)e + e->target_offset));
If yes, I will submit this modified version of your patch.
Quoted 2 lines
(quoted diff) +0
-0Regards,Scott.
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+ V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)