[iptables PATCH 2/2] xshared: Make some functions static

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

 



With all ip(6)tables variants using the same do_parse() function, quite
a bunch of functions are not used outside of xshared.c anymore. Make them
static.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 iptables/xshared.c | 30 +++++++++++++++++-------------
 iptables/xshared.h | 21 ---------------------
 2 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/iptables/xshared.c b/iptables/xshared.c
index 9b5e5b5bddc27..bd4e10225de95 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -39,8 +39,8 @@ char *arp_opcodes[] =
  * to the commandline, and see expected results. So we call help for all
  * specified matches and targets.
  */
-void print_extension_helps(const struct xtables_target *t,
-    const struct xtables_rule_match *m)
+static void print_extension_helps(const struct xtables_target *t,
+				  const struct xtables_rule_match *m)
 {
 	for (; t != NULL; t = t->next) {
 		if (t->used) {
@@ -129,8 +129,8 @@ static struct xtables_match *load_proto(struct iptables_command_state *cs)
 			  cs->options & OPT_NUMERIC, &cs->matches);
 }
 
-int command_default(struct iptables_command_state *cs,
-		    struct xtables_globals *gl, bool invert)
+static int command_default(struct iptables_command_state *cs,
+			   struct xtables_globals *gl, bool invert)
 {
 	struct xtables_rule_match *matchp;
 	struct xtables_match *m;
@@ -789,7 +789,7 @@ void save_iface(char letter, const char *iface,
 	}
 }
 
-void command_match(struct iptables_command_state *cs, bool invert)
+static void command_match(struct iptables_command_state *cs, bool invert)
 {
 	struct option *opts = xt_params->opts;
 	struct xtables_match *m;
@@ -827,7 +827,7 @@ void command_match(struct iptables_command_state *cs, bool invert)
 	xt_params->opts = opts;
 }
 
-const char *xt_parse_target(const char *targetname)
+static const char *xt_parse_target(const char *targetname)
 {
 	const char *ptr;
 
@@ -889,7 +889,7 @@ void command_jump(struct iptables_command_state *cs, const char *jumpto)
 	xt_params->opts = opts;
 }
 
-char cmd2char(int option)
+static char cmd2char(int option)
 {
 	/* cmdflags index corresponds with position of bit in CMD_* values */
 	static const char cmdflags[] = { 'I', 'D', 'D', 'R', 'A', 'L', 'F', 'Z',
@@ -905,8 +905,8 @@ char cmd2char(int option)
 	return cmdflags[i];
 }
 
-void add_command(unsigned int *cmd, const int newcmd,
-		 const int othercmds, int invert)
+static void add_command(unsigned int *cmd, const int newcmd,
+			const int othercmds, int invert)
 {
 	if (invert)
 		xtables_error(PARAMETER_PROBLEM, "unexpected '!' flag");
@@ -917,7 +917,7 @@ void add_command(unsigned int *cmd, const int newcmd,
 }
 
 /* Can't be zero. */
-int parse_rulenumber(const char *rule)
+static int parse_rulenumber(const char *rule)
 {
 	unsigned int rulenum;
 
@@ -928,6 +928,10 @@ int parse_rulenumber(const char *rule)
 	return rulenum;
 }
 
+#define NUMBER_OF_OPT	ARRAY_SIZE(optflags)
+static const char optflags[]
+= { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c', 'f', 2, 3, 'l', 4, 5, 6 };
+
 /* Table of legal combinations of commands and options.  If any of the
  * given commands make an option legal, that option is legal (applies to
  * CMD_LIST and CMD_ZERO only).
@@ -957,7 +961,7 @@ static const char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
 /*CHECK*/     {'x',' ',' ',' ',' ',' ','x',' ',' ','x','x',' ',' ',' ',' ',' ',' ',' '},
 };
 
-void generic_opt_check(int command, int options)
+static void generic_opt_check(int command, int options)
 {
 	int i, j, legal = 0;
 
@@ -992,7 +996,7 @@ void generic_opt_check(int command, int options)
 	}
 }
 
-char opt2char(int option)
+static char opt2char(int option)
 {
 	const char *ptr;
 
@@ -1024,7 +1028,7 @@ static const int inverse_for_options[NUMBER_OF_OPT] =
 /* 6 */ IPT_INV_PROTO,
 };
 
-void
+static void
 set_option(unsigned int *options, unsigned int option, uint16_t *invflg,
 	   bool invert)
 {
diff --git a/iptables/xshared.h b/iptables/xshared.h
index 2498e32d39e03..1d6b9bf4ee9b7 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -39,10 +39,6 @@ enum {
 	OPT_P_TYPE	= 1 << 17,
 };
 
-#define NUMBER_OF_OPT	ARRAY_SIZE(optflags)
-static const char optflags[]
-= { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c', 'f', 2, 3, 'l', 4, 5, 6 };
-
 enum {
 	CMD_NONE		= 0,
 	CMD_INSERT		= 1 << 0,
@@ -79,10 +75,6 @@ struct xtables_target;
 #define IPT_INV_ARPOP		0x0400
 #define IPT_INV_ARPHRD		0x0800
 
-void
-set_option(unsigned int *options, unsigned int option, uint16_t *invflg,
-	   bool invert);
-
 /**
  * xtables_afinfo - protocol family dependent information
  * @kmod:		kernel module basename (e.g. "ip_tables")
@@ -164,10 +156,6 @@ enum {
 	XT_OPTION_OFFSET_SCALE = 256,
 };
 
-extern void print_extension_helps(const struct xtables_target *,
-	const struct xtables_rule_match *);
-extern int command_default(struct iptables_command_state *,
-	struct xtables_globals *, bool invert);
 extern int subcmd_main(int, char **, const struct subcommand *);
 extern void xs_init_target(struct xtables_target *);
 extern void xs_init_match(struct xtables_match *);
@@ -239,19 +227,10 @@ void save_iface(char letter, const char *iface,
 void print_fragment(unsigned int flags, unsigned int invflags,
 		    unsigned int format, bool fake);
 
-void command_match(struct iptables_command_state *cs, bool invert);
-const char *xt_parse_target(const char *targetname);
 void command_jump(struct iptables_command_state *cs, const char *jumpto);
 
-char cmd2char(int option);
-void add_command(unsigned int *cmd, const int newcmd,
-		 const int othercmds, int invert);
-int parse_rulenumber(const char *rule);
 void assert_valid_chain_name(const char *chainname);
 
-void generic_opt_check(int command, int options);
-char opt2char(int option);
-
 void print_rule_details(unsigned int linenum, const struct xt_counters *ctrs,
 			const char *targname, uint8_t proto, uint8_t flags,
 			uint8_t invflags, unsigned int format);
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux