Skip to contentSkip to conversation

Multiple checkpatch issues.

PATCH In review Arushi Singhal 2 participants 6 messages Mar 31, 2017 – Apr 7, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

cover Multiple checkpatch issues.

Solved the multiple checkpatch issues.

Arushi Singhal (4):
iptables: iptables: Add blank line after declaration
iptables: iptables: Remove assignment in if condition
iptables: iptables: Indent the code.
iptables: iptables: switch and case should be at the same indent

 iptables/getethertype.c      |  4 ++-
 iptables/ip6tables-restore.c | 62 ++++++++++++++++++++++----------------------
 iptables/nft-arp.c           |  3 ++-
 iptables/xtables-arp.c       |  4 +--
 iptables/xtables-eb.c        |  4 +--
 5 files changed, 40 insertions(+), 37 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/4 iptables: iptables: Add blank line after declaration

Add blank line after the declaration of variable to follow kernel coding style.

---
 iptables/getethertype.c | 1 +
 1 file changed, 1 insertion(+)
iptables/getethertype.c +1 -0
index 027ef4a..bf3e408 100644
@@ -75,6 +75,7 @@ struct ethertypeent *getethertypeent(void)
 {
 	char *e;
 	char *endptr;
+
 	register char *cp, **q;
 
 	if (etherf == NULL
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 1/4] iptables: iptables: Add blank line after declaration

Quoted 13 lines · Arushi Singhal

Add blank line after the declaration of variable to follow kernel coding style.

---
 iptables/getethertype.c | 1 +
 1 file changed, 1 insertion(+)
iptables/getethertype.c +0 -0
index 027ef4a..bf3e408 100644

iptables/getethertype.c struct ethertypeent *getethertypeent(void) · line 79

Quoted 5 lines
iptables/getethertype.c +1 -0
@@ -75,6 +75,7 @@ struct ethertypeent *getethertypeent(void)
 {
 	char *e;
 	char *endptr;
+
 	register char *cp, **q;

I don't see any need for this new empty line.

#3 lore raw

PATCH 2/4 iptables: iptables: Remove assignment in if condition

In reply to Arushi Singhal

Remove the assignment from if condition to follow kernel coding style and make the code more clear and readable.

---
 iptables/getethertype.c | 3 ++-
 iptables/nft-arp.c      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
iptables/getethertype.c +2 -1
index bf3e408..11c121a 100644
@@ -84,7 +84,8 @@ struct ethertypeent *getethertypeent(void)
 	}
 
 again:
-	if ((e = fgets(line, BUFSIZ, etherf)) == NULL) {
+	e = fgets(line, BUFSIZ, etherf);
+	if (!e) {
 		return (NULL);
 	}
 	if (*e == '#')
iptables/nft-arp.c +2 -1
index 0e13b8c..37ed956 100644
@@ -70,7 +70,8 @@ addr_to_network(const struct in_addr *addr)
 {
 	struct netent *net;
 
-	if ((net = getnetbyaddr((long) ntohl(addr->s_addr), AF_INET)) != NULL)
+	net = getnetbyaddr((long) ntohl(addr->s_addr), AF_INET);
+	if (net)
 		return (char *) net->n_name;
 
 	return (char *) NULL;
Signature · 1 line
2.11.0
#4 lore raw

PATCH 3/4 iptables: iptables: Indent the code.

In reply to Arushi Singhal

Ident the code.

---
 iptables/xtables-arp.c | 4 ++--
 iptables/xtables-eb.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
iptables/xtables-arp.c +2 -2
index 6aa000a..38b0206 100644
@@ -481,8 +481,8 @@ exit_printhelp(void)
 "  --set-counters PKTS BYTES	set the counter during insert/append\n"
 "[!] --version	-V		print package version.\n");
 	printf(" opcode strings: \n");
-        for (i = 0; i < NUMOPCODES; i++)
-                printf(" %d = %s\n", i + 1, opcodes[i]);
+	for (i = 0; i < NUMOPCODES; i++)
+		printf(" %d = %s\n", i + 1, opcodes[i]);
         printf(
 " hardware type string: 1 = Ethernet\n"
 " protocol type string: 0x800 = IPv4\n");
iptables/xtables-eb.c +2 -2
index c8b5d4f..2cb3ae6 100644
@@ -327,9 +327,9 @@ static void ebt_list_extensions(const struct xtables_target *t,
 	printf("%s v%s\n", prog_name, prog_vers);
 	printf("Loaded userspace extensions:\n");
 	/*printf("\nLoaded tables:\n");
-        while (tbl) {
+	while (tbl) {
 		printf("%s\n", tbl->name);
-                tbl = tbl->next;
+		tbl = tbl->next;
 	}*/
 	printf("\nLoaded targets:\n");
         for (t = xtables_targets; t; t = t->next) {
Signature · 1 line
2.11.0
#5 lore raw

PATCH 4/4 iptables: iptables: switch and case should be at the same indent

In reply to Arushi Singhal

As per kernel coding style switch and case should be at the same identation.

---
 iptables/ip6tables-restore.c | 62 ++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
iptables/ip6tables-restore.c +31 -31
index 8a47f09..24ea5ec 100644
@@ -215,37 +215,37 @@ int ip6tables_restore_main(int argc, char *argv[])
 
 	while ((c = getopt_long(argc, argv, "bcvthnwWM:T:", options, NULL)) != -1) {
 		switch (c) {
-			case 'b':
-				fprintf(stderr, "-b/--binary option is not implemented\n");
-				break;
-			case 'c':
-				counters = 1;
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case 't':
-				testing = 1;
-				break;
-			case 'h':
-				print_usage("ip6tables-restore",
-					    IPTABLES_VERSION);
-				break;
-			case 'n':
-				noflush = 1;
-				break;
-			case 'w':
-				wait = parse_wait_time(argc, argv);
-				break;
-			case 'W':
-				parse_wait_interval(argc, argv, &wait_interval);
-				break;
-			case 'M':
-				xtables_modprobe_program = optarg;
-				break;
-			case 'T':
-				tablename = optarg;
-				break;
+		case 'b':
+			fprintf(stderr, "-b/--binary option is not implemented\n");
+			break;
+		case 'c':
+			counters = 1;
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		case 't':
+			testing = 1;
+			break;
+		case 'h':
+			print_usage("ip6tables-restore",
+				    IPTABLES_VERSION);
+			break;
+		case 'n':
+			noflush = 1;
+			break;
+		case 'w':
+			wait = parse_wait_time(argc, argv);
+			break;
+		case 'W':
+			parse_wait_interval(argc, argv, &wait_interval);
+			break;
+		case 'M':
+			xtables_modprobe_program = optarg;
+			break;
+		case 'T':
+			tablename = optarg;
+			break;
 		}
 	}
 
Signature · 1 line
2.11.0