From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [RFC iproute2-next 11/16] iproute: don't do assignment in condition Date: Thu, 1 Feb 2018 17:19:41 -0800 Message-ID: <20180202011946.21929-12-sthemmin@microsoft.com> References: <20180202011946.21929-1-sthemmin@microsoft.com> Cc: netdev@vger.kernel.org, Stephen Hemminger , Stephen Hemminger To: dsahern@gmail.com Return-path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:33462 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907AbeBBBUS (ORCPT ); Thu, 1 Feb 2018 20:20:18 -0500 Received: by mail-pl0-f67.google.com with SMTP id t4so4922664plo.0 for ; Thu, 01 Feb 2018 17:20:17 -0800 (PST) In-Reply-To: <20180202011946.21929-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org List-ID: Fix checkpatch complaints about assignment in conditions. Signed-off-by: Stephen Hemminger --- ip/iproute.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ip/iproute.c b/ip/iproute.c index b466f9eb8cad..55b2f51e3987 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -652,7 +652,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)); @@ -826,7 +827,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; } @@ -1325,9 +1327,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; } @@ -1657,7 +1659,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; } @@ -1665,7 +1668,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; } @@ -1715,7 +1719,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) { @@ -1866,14 +1871,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