netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iptables: Remove explicit static variables initalization.
       [not found] <cover.1490815157.git.rvarsha016@gmail.com>
@ 2017-03-29 19:27 ` Varsha Rao
  2017-04-06 16:22   ` Pablo Neira Ayuso
  2017-03-29 19:27 ` [PATCH 2/2] iptables: Remove unnecessary braces Varsha Rao
  1 sibling, 1 reply; 4+ messages in thread
From: Varsha Rao @ 2017-03-29 19:27 UTC (permalink / raw)
  To: netfilter-devel, pablo; +Cc: outreachy-kernel

Static variables are initialized to zero by default, so remove explicit
initalization. This patch fixes the checkpatch issue.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
 iptables/ip6tables-restore.c |  2 +-
 iptables/ip6tables-save.c    |  2 +-
 iptables/iptables-restore.c  |  2 +-
 iptables/iptables-save.c     |  2 +-
 iptables/iptables-xml.c      | 10 +++++-----
 iptables/xtables-arp.c       |  2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index 8a47f09..30a4ade 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -26,7 +26,7 @@
 #define DEBUGP(x, args...)
 #endif
 
-static int counters = 0, verbose = 0, noflush = 0, wait = 0;
+static int counters, verbose, noflush, wait;
 
 static struct timeval wait_interval = {
 	.tv_sec	= 1,
diff --git a/iptables/ip6tables-save.c b/iptables/ip6tables-save.c
index 053413a..c2495d2 100644
--- a/iptables/ip6tables-save.c
+++ b/iptables/ip6tables-save.c
@@ -18,7 +18,7 @@
 #include "ip6tables.h"
 #include "ip6tables-multi.h"
 
-static int show_counters = 0;
+static int show_counters;
 
 static const struct option options[] = {
 	{.name = "counters", .has_arg = false, .val = 'c'},
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index 7bb06d8..15db358 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -23,7 +23,7 @@
 #define DEBUGP(x, args...)
 #endif
 
-static int counters = 0, verbose = 0, noflush = 0, wait = 0;
+static int counters, verbose, noflush, wait;
 
 static struct timeval wait_interval = {
 	.tv_sec	= 1,
diff --git a/iptables/iptables-save.c b/iptables/iptables-save.c
index e8ae9c6..fbc6059 100644
--- a/iptables/iptables-save.c
+++ b/iptables/iptables-save.c
@@ -17,7 +17,7 @@
 #include "iptables.h"
 #include "iptables-multi.h"
 
-static int show_counters = 0;
+static int show_counters;
 
 static const struct option options[] = {
 	{.name = "counters", .has_arg = false, .val = 'c'},
diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c
index 740a563..2e093b5 100644
--- a/iptables/iptables-xml.c
+++ b/iptables/iptables-xml.c
@@ -34,9 +34,9 @@ struct xtables_globals iptables_xml_globals = {
 static void print_usage(const char *name, const char *version)
 	    __attribute__ ((noreturn));
 
-static int verbose = 0;
+static int verbose;
 /* Whether to combine actions of sequential rules with identical conditions */
-static int combine = 0;
+static int combine;
 /* Keeping track of external matches and targets.  */
 static struct option options[] = {
 	{"verbose", 0, NULL, 'v'},
@@ -73,10 +73,10 @@ parse_counters(char *string, struct xt_counters *ctr)
 
 /* global new argv and argc */
 static char *newargv[255];
-static unsigned int newargc = 0;
+static unsigned int newargc;
 
 static char *oldargv[255];
-static unsigned int oldargc = 0;
+static unsigned int oldargc;
 
 /* arg meta data, were they quoted, frinstance */
 static int newargvattr[255];
@@ -96,7 +96,7 @@ struct chain {
 
 #define maxChains 10240		/* max chains per table */
 static struct chain chains[maxChains];
-static int nextChain = 0;
+static int nextChain;
 
 /* funCtion adding one argument to newargv, updating newargc 
  * returns true if argument added, false otherwise */
diff --git a/iptables/xtables-arp.c b/iptables/xtables-arp.c
index 6aa000a..4a968f4 100644
--- a/iptables/xtables-arp.c
+++ b/iptables/xtables-arp.c
@@ -150,7 +150,7 @@ static struct option original_opts[] = {
 int RUNTIME_NF_ARP_NUMHOOKS = 3;
 
 static struct option *opts = original_opts;
-static unsigned int global_option_offset = 0;
+static unsigned int global_option_offset;
 
 extern void xtables_exit_error(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
 struct xtables_globals arptables_globals = {
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] iptables: Remove unnecessary braces.
       [not found] <cover.1490815157.git.rvarsha016@gmail.com>
  2017-03-29 19:27 ` [PATCH 1/2] iptables: Remove explicit static variables initalization Varsha Rao
@ 2017-03-29 19:27 ` Varsha Rao
  2017-04-06 16:22   ` Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Varsha Rao @ 2017-03-29 19:27 UTC (permalink / raw)
  To: netfilter-devel, pablo; +Cc: outreachy-kernel

Remove braces which are not required, to fix the check patch issue.
The following coccinelle script was used to fix this issue.

@@
expression e;
expression e1;
@@
if(e)
-{
 e1;
-}

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
 iptables/iptables-standalone.c | 3 +--
 iptables/iptables.c            | 3 +--
 iptables/xtables-standalone.c  | 3 +--
 iptables/xtables-translate.c   | 6 ++----
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/iptables/iptables-standalone.c b/iptables/iptables-standalone.c
index 4da1d7f..c211fb7 100644
--- a/iptables/iptables-standalone.c
+++ b/iptables/iptables-standalone.c
@@ -73,9 +73,8 @@ iptables_main(int argc, char *argv[])
 			fprintf(stderr, "iptables: %s.\n",
 				iptc_strerror(errno));
 		}
-		if (errno == EAGAIN) {
+		if (errno == EAGAIN)
 			exit(RESOURCE_PROBLEM);
-		}
 	}
 
 	exit(!ret);
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 62731c5..97cbda9 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -1114,9 +1114,8 @@ void print_rule4(const struct ipt_entry *e,
 		       e->ip.invflags & IPT_INV_FRAG ? " !" : "");
 
 	/* Print matchinfo part */
-	if (e->target_offset) {
+	if (e->target_offset)
 		IPT_MATCH_ITERATE(e, print_match_save, &e->ip);
-	}
 
 	/* print counters for iptables -R */
 	if (counters < 0)
diff --git a/iptables/xtables-standalone.c b/iptables/xtables-standalone.c
index 355a446..139c477 100644
--- a/iptables/xtables-standalone.c
+++ b/iptables/xtables-standalone.c
@@ -85,9 +85,8 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
 			fprintf(stderr, "iptables: %s.\n",
 				nft_strerror(errno));
 		}
-		if (errno == EAGAIN) {
+		if (errno == EAGAIN)
 			exit(RESOURCE_PROBLEM);
-		}
 	}
 
 	exit(!ret);
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
index 00de019..e049f24 100644
--- a/iptables/xtables-translate.c
+++ b/iptables/xtables-translate.c
@@ -236,9 +236,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[],
 	switch (p.command) {
 	case CMD_APPEND:
 		ret = 1;
-		if (!xlate(h, &p, &cs, &args, true, nft_rule_xlate_add)) {
+		if (!xlate(h, &p, &cs, &args, true, nft_rule_xlate_add))
 			print_ipt_cmd(argc, argv);
-		}
 		break;
 	case CMD_DELETE:
 		break;
@@ -250,9 +249,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[],
 		break;
 	case CMD_INSERT:
 		ret = 1;
-		if (!xlate(h, &p, &cs, &args, false, nft_rule_xlate_add)) {
+		if (!xlate(h, &p, &cs, &args, false, nft_rule_xlate_add))
 			print_ipt_cmd(argc, argv);
-		}
 		break;
 	case CMD_FLUSH:
 		if (p.chain) {
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] iptables: Remove explicit static variables initalization.
  2017-03-29 19:27 ` [PATCH 1/2] iptables: Remove explicit static variables initalization Varsha Rao
@ 2017-04-06 16:22   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-04-06 16:22 UTC (permalink / raw)
  To: Varsha Rao; +Cc: netfilter-devel, outreachy-kernel

On Thu, Mar 30, 2017 at 12:57:02AM +0530, Varsha Rao wrote:
> Static variables are initialized to zero by default, so remove explicit
> initalization. This patch fixes the checkpatch issue.

Applied.

But I had to add this chunk:

diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index a551c8c19f7f..6afa0d0ec5b1 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -24,7 +24,7 @@
 #define DEBUGP(x, args...)
 #endif
 
-static int counters = 0, verbose = 0, noflush = 0;
+static int counters, verbose, noflush;
 
 /* Keeping track of external matches and targets.  */
 static const struct option options[] = {

You have to be more careful. It's good if you just fix all spots in
one single go.

Thanks!

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] iptables: Remove unnecessary braces.
  2017-03-29 19:27 ` [PATCH 2/2] iptables: Remove unnecessary braces Varsha Rao
@ 2017-04-06 16:22   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-04-06 16:22 UTC (permalink / raw)
  To: Varsha Rao; +Cc: netfilter-devel, outreachy-kernel

On Thu, Mar 30, 2017 at 12:57:43AM +0530, Varsha Rao wrote:
> Remove braces which are not required, to fix the check patch issue.
> The following coccinelle script was used to fix this issue.
> 
> @@
> expression e;
> expression e1;
> @@
> if(e)
> -{
>  e1;
> -}

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-06 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1490815157.git.rvarsha016@gmail.com>
2017-03-29 19:27 ` [PATCH 1/2] iptables: Remove explicit static variables initalization Varsha Rao
2017-04-06 16:22   ` Pablo Neira Ayuso
2017-03-29 19:27 ` [PATCH 2/2] iptables: Remove unnecessary braces Varsha Rao
2017-04-06 16:22   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).