All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dsahern@gmail.com
Cc: netdev@vger.kernel.org,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next 2/3] iproute: don't do assignment in condition
Date: Wed,  7 Feb 2018 16:25:05 -0800	[thread overview]
Message-ID: <20180208002506.14272-3-sthemmin@microsoft.com> (raw)
In-Reply-To: <20180208002506.14272-1-sthemmin@microsoft.com>

Fix checkpatch complaints about assignment in conditions.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/iproute.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index e9c4093fa3eb..22ed113e890a 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -653,7 +653,8 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		struct nlmsghdr *fn;
 
 		if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) {
-			if ((ret = flush_update()) < 0)
+			ret = flush_update();
+			if (ret < 0)
 				return ret;
 		}
 		fn = (struct nlmsghdr *)(filter.flushb + NLMSG_ALIGN(filter.flushp));
@@ -827,7 +828,8 @@ static int parse_one_nh(struct nlmsghdr *n, struct rtmsg *r,
 			}
 		} else if (strcmp(*argv, "dev") == 0) {
 			NEXT_ARG();
-			if ((rtnh->rtnh_ifindex = ll_name_to_index(*argv)) == 0) {
+			rtnh->rtnh_ifindex = ll_name_to_index(*argv);
+			if (rtnh->rtnh_ifindex == 0) {
 				fprintf(stderr, "Cannot find device \"%s\"\n", *argv);
 				return -1;
 			}
@@ -1326,9 +1328,9 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
 		usage();
 
 	if (d) {
-		int idx;
+		int idx = ll_name_to_index(d);
 
-		if ((idx = ll_name_to_index(d)) == 0) {
+		if (idx == 0) {
 			fprintf(stderr, "Cannot find device \"%s\"\n", d);
 			return -1;
 		}
@@ -1658,7 +1660,8 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
 		int idx;
 
 		if (id) {
-			if ((idx = ll_name_to_index(id)) == 0) {
+			idx = ll_name_to_index(id);
+			if (idx == 0) {
 				fprintf(stderr, "Cannot find device \"%s\"\n", id);
 				return -1;
 			}
@@ -1666,7 +1669,8 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
 			filter.iifmask = -1;
 		}
 		if (od) {
-			if ((idx = ll_name_to_index(od)) == 0) {
+			idx = ll_name_to_index(od);
+			if (idx == 0) {
 				fprintf(stderr, "Cannot find device \"%s\"\n", od);
 				return -1;
 			}
@@ -1716,7 +1720,8 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
 				return 0;
 			}
 			round++;
-			if ((ret = flush_update()) < 0)
+			ret = flush_update();
+			if (ret < 0)
 				return ret;
 
 			if (time(0) - start > 30) {
@@ -1867,14 +1872,16 @@ static int iproute_get(int argc, char **argv)
 		int idx;
 
 		if (idev) {
-			if ((idx = ll_name_to_index(idev)) == 0) {
+			idx = ll_name_to_index(idev);
+			if (idx == 0) {
 				fprintf(stderr, "Cannot find device \"%s\"\n", idev);
 				return -1;
 			}
 			addattr32(&req.n, sizeof(req), RTA_IIF, idx);
 		}
 		if (odev) {
-			if ((idx = ll_name_to_index(odev)) == 0) {
+			idx = ll_name_to_index(odev);
+			if (idx == 0) {
 				fprintf(stderr, "Cannot find device \"%s\"\n", odev);
 				return -1;
 			}
-- 
2.15.1

  parent reply	other threads:[~2018-02-08  0:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08  0:25 [PATCH iproute2-next 0/3] route code cleanups Stephen Hemminger
2018-02-08  0:25 ` [PATCH iproute2-next 1/3] iproute: whitespace fixes Stephen Hemminger
2018-02-08  0:25 ` Stephen Hemminger [this message]
2018-02-08  0:25 ` [PATCH iproute2-next 3/3] iproute: make flush a separate function Stephen Hemminger
2018-02-08  0:29 ` [PATCH iproute2-next 0/3] route code cleanups David Ahern

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=20180208002506.14272-3-sthemmin@microsoft.com \
    --to=stephen@networkplumber.org \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.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 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.