netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arushi Singhal <arushisinghal19971997@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: outreachy-kernel@googlegroups.com
Subject: [PATCH] iptables: extensions: Remove assignment in if condition.
Date: Thu, 30 Mar 2017 05:04:59 +0530	[thread overview]
Message-ID: <20170329233459.GA22682@arushi-HP-Pavilion-Notebook> (raw)

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

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 extensions/libebt_ip.c          | 11 ++++++-----
 extensions/libip6t_ipv6header.c |  5 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/extensions/libebt_ip.c b/extensions/libebt_ip.c
index 4ca63e9..deae6f4 100644
--- a/extensions/libebt_ip.c
+++ b/extensions/libebt_ip.c
@@ -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,
diff --git a/extensions/libip6t_ipv6header.c b/extensions/libip6t_ipv6header.c
index 6f03087..887d225 100644
--- a/extensions/libip6t_ipv6header.c
+++ b/extensions/libip6t_ipv6header.c
@@ -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)
-- 
2.11.0


             reply	other threads:[~2017-03-29 23:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 23:34 Arushi Singhal [this message]
2017-03-30  9:02 ` [PATCH] iptables: extensions: Remove assignment in if condition Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329233459.GA22682@arushi-HP-Pavilion-Notebook \
    --to=arushisinghal19971997@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).