[iptables PATCH 08/27] Consolidate DEBUGP macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This debug printing macro was defined in various places, always
identical. Move it into xshared.h and drop it from sources including
that header. There are a few exceptions:

* iptables-xml.c did not include xshared.h, which this patch changes.

* Sources in extensions and libiptc mostly left alone since they don't
  include xshared.h (and maybe shouldn't). Only libxt_set.h does, so
  it's converted, too.

This also converts DEBUG define use in libip6t_hbh.c to avoid a compiler
warning.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 extensions/libip6t_hbh.c     | 6 ++----
 extensions/libxt_set.h       | 6 ------
 iptables/ip6tables-restore.c | 6 ------
 iptables/iptables-restore.c  | 6 ------
 iptables/iptables-xml.c      | 7 +------
 iptables/nft-shared.h        | 5 +----
 iptables/xshared.h           | 6 ++++++
 iptables/xtables-restore.c   | 6 ------
 8 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/extensions/libip6t_hbh.c b/extensions/libip6t_hbh.c
index 76b4ff00d4c05..4cebecfd3d2f5 100644
--- a/extensions/libip6t_hbh.c
+++ b/extensions/libip6t_hbh.c
@@ -5,8 +5,6 @@
 #include <xtables.h>
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
-#define DEBUG		0
-
 enum {
 	O_HBH_LEN = 0,
 	O_HBH_OPTS,
@@ -83,7 +81,7 @@ parse_options(const char *optsstr, uint16_t *opts)
                         opts[i] |= (0x00FF);
 		}
 
-#if DEBUG
+#ifdef DEBUG
 		printf("opts str: %s %s\n", cp, range);
 		printf("opts opt: %04X\n", opts[i]);
 #endif
@@ -92,7 +90,7 @@ parse_options(const char *optsstr, uint16_t *opts)
 
 	free(buffer);
 
-#if DEBUG
+#ifdef DEBUG
 	printf("addr nr: %d\n", i);
 #endif
 
diff --git a/extensions/libxt_set.h b/extensions/libxt_set.h
index 5a1bdcf730cf2..41dfbd30fc7c1 100644
--- a/extensions/libxt_set.h
+++ b/extensions/libxt_set.h
@@ -8,12 +8,6 @@
 #include <errno.h>
 #include "../iptables/xshared.h"
 
-#ifdef DEBUG
-#define DEBUGP(x, args...) fprintf(stderr, x , ## args)
-#else
-#define DEBUGP(x, args...) 
-#endif
-
 static int
 get_version(unsigned *version)
 {
diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index d36f92da45e18..3065768ed8e6b 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -20,12 +20,6 @@
 #include "libiptc/libip6tc.h"
 #include "ip6tables-multi.h"
 
-#ifdef DEBUG
-#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
-#else
-#define DEBUGP(x, args...)
-#endif
-
 static int counters, verbose, noflush, wait;
 
 static struct timeval wait_interval = {
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index 142ddb825ce6d..e52e8e47dda74 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -17,12 +17,6 @@
 #include "libiptc/libiptc.h"
 #include "iptables-multi.h"
 
-#ifdef DEBUG
-#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
-#else
-#define DEBUGP(x, args...)
-#endif
-
 static int counters, verbose, noflush, wait;
 
 static struct timeval wait_interval = {
diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c
index 69c19a60180f2..a1b09f3ad745c 100644
--- a/iptables/iptables-xml.c
+++ b/iptables/iptables-xml.c
@@ -16,12 +16,7 @@
 #include "libiptc/libiptc.h"
 #include "xtables-multi.h"
 #include <xtables.h>
-
-#ifdef DEBUG
-#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
-#else
-#define DEBUGP(x, args...)
-#endif
+#include "xshared.h"
 
 struct xtables_globals iptables_xml_globals = {
 	.option_offset = 0,
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 882f60e868c09..5ef17a088a208 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -11,12 +11,9 @@
 
 #include "xshared.h"
 
-#if 0
-#define DEBUGP(x, args...) fprintf(stdout, x, ## args)
+#ifdef DEBUG
 #define NLDEBUG
 #define DEBUG_DEL
-#else
-#define DEBUGP(x, args...)
 #endif
 
 /*
diff --git a/iptables/xshared.h b/iptables/xshared.h
index 533c52686bc29..363549db78894 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -10,6 +10,12 @@
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 
+#ifdef DEBUG
+#define DEBUGP(x, args...) fprintf(stdout, x, ## args)
+#else
+#define DEBUGP(x, args...)
+#endif
+
 enum {
 	OPT_NONE        = 0,
 	OPT_NUMERIC     = 1 << 0,
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 5c0ae98e8821a..0a3d1a3116782 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -19,12 +19,6 @@
 #include "nft-bridge.h"
 #include <libnftnl/chain.h>
 
-#ifdef DEBUG
-#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
-#else
-#define DEBUGP(x, args...)
-#endif
-
 static int counters, verbose, noflush;
 
 /* Keeping track of external matches and targets.  */
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux