All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iptables: extensions: Remove assignment in if condition.
@ 2017-03-29 23:34 Arushi Singhal
  2017-03-30  9:02 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Arushi Singhal @ 2017-03-29 23:34 UTC (permalink / raw)
  To: netfilter-devel; +Cc: outreachy-kernel

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



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

* Re: [PATCH] iptables: extensions: Remove assignment in if condition.
  2017-03-29 23:34 [PATCH] iptables: extensions: Remove assignment in if condition Arushi Singhal
@ 2017-03-30  9:02 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2017-03-30  9:02 UTC (permalink / raw)
  To: Arushi Singhal; +Cc: netfilter-devel, outreachy-kernel

Arushi Singhal <arushisinghal19971997@gmail.com> wrote:
> 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, ':');

This is broken.


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

end of thread, other threads:[~2017-03-30  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 23:34 [PATCH] iptables: extensions: Remove assignment in if condition Arushi Singhal
2017-03-30  9:02 ` Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.