Skip to contentSkip to conversation

iptables: extensions: Remove assignment in if condition.

PATCH Superseded Arushi Singhal 2 participants 2 messages Mar 29, 2017 – Mar 30, 2017 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables: extensions: Remove assignment in if condition.

Remove assignments in if condition as reported by checkpatch.pl.

---
 extensions/libebt_ip.c          | 11 ++++++-----
 extensions/libip6t_ipv6header.c |  5 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)
extensions/libebt_ip.c +6 -5
index 4ca63e9..deae6f4 100644
@@ -68,9 +68,9 @@ parse_port_range(const char *protocol, const char *portstring, uint16_t *ports)
 {
 	char *buffer;
 	char *cp;
-
+	cp = strchr(buffer, ':');
 	buffer = strdup(portstring);
-	if ((cp = strchr(buffer, ':')) == NULL)
+	if (!cp)
 		ports[0] = ports[1] = xtables_parse_port(buffer, NULL);
 	else {
 		*cp = '\0';
@@ -97,8 +97,9 @@ static int undot_ip(char *ip, unsigned char *ip2)
 	strncpy(buf, ip, sizeof(buf) - 1);
 
 	p = buf;
+	q = strchr(p, '.')OA;
 	for (i = 0; i < 3; i++) {
-		if ((q = strchr(p, '.')) == NULL)
+		if (!q)
 			return -1;
 		*q = '\0';
 		onebyte = strtol(p, &end, 10);
@@ -141,9 +142,9 @@ static int ip_mask(char *mask, unsigned char *mask2)
 static void ebt_parse_ip_address(char *address, uint32_t *addr, uint32_t *msk)
 {
 	char *p;
-
+	p = strrchr(address, '/');
 	/* first the mask */
-	if ((p = strrchr(address, '/')) != NULL) {
+	if (p) {
 		*p = '\0';
 		if (ip_mask(p + 1, (unsigned char *)msk)) {
 			xtables_error(PARAMETER_PROBLEM,
extensions/libip6t_ipv6header.c +3 -2
index 6f03087..887d225 100644
@@ -85,8 +85,9 @@ name_to_proto(const char *s)
         unsigned int proto=0;
 	const struct protoent *pent;
 
-        if ((pent = getprotobyname(s)))
-        	proto = pent->p_proto;
+	pent = getprotobyname(s);
+        if (pent)
+		proto = pent->p_proto;
         else {
         	unsigned int i;
         	for (i = 0; i < ARRAY_SIZE(chain_protos); ++i)
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 13 lines · Arushi Singhal

Remove assignments in if condition as reported by checkpatch.pl.

---
 extensions/libebt_ip.c          | 11 ++++++-----
 extensions/libip6t_ipv6header.c |  5 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)
extensions/libebt_ip.c +0 -0
index 4ca63e9..deae6f4 100644

extensions/libebt_ip.c parse_port_range(const char *protocol, const char *portstring, uint16_t *ports) · line 71

Quoted 5 lines
extensions/libebt_ip.c +1 -1
@@ -68,9 +68,9 @@ parse_port_range(const char *protocol, const char *portstring, uint16_t *ports)
 {
 	char *buffer;
 	char *cp;
-
+	cp = strchr(buffer, ':');

This is broken.