[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/9] net: Remove assignment in if condition
From: |
Zhang Han |
Subject: |
[PATCH 7/9] net: Remove assignment in if condition |
Date: |
Tue, 22 Dec 2020 16:23:38 +0800 |
Put the assignment before the if condition
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
net/tap-bsd.c | 3 ++-
net/tap-solaris.c | 9 ++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index dc8f9c8658..d1dca793f9 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -176,7 +176,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
if (fd < 0) {
/* Tap device not specified or does not exist. */
- if ((fd = tap_open_clone(ifname, ifname_size, errp)) < 0) {
+ fd = tap_open_clone(ifname, ifname_size, errp);
+ if (fd < 0) {
return -1;
}
}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index a0a5456ab6..d5af4efd60 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -105,7 +105,8 @@ static int tap_alloc(char *dev, size_t dev_size, Error
**errp)
strioc_ppa.ic_timout = 0;
strioc_ppa.ic_len = sizeof(ppa);
strioc_ppa.ic_dp = (char *)&ppa;
- if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) {
+ ppa = ioctl(tap_fd, I_STR, &strioc_ppa));
+ if (ppa < 0) {
error_report("Can't assign new interface");
}
@@ -162,12 +163,14 @@ static int tap_alloc(char *dev, size_t dev_size, Error
**errp)
error_report("Can't set ifname to arp");
}
- if ((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0) {
+ ip_muxid = ioctl(ip_fd, I_LINK, if_fd);
+ if (ip_muxid < 0) {
error_setg(errp, "Can't link TAP device to IP");
return -1;
}
- if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) {
+ arp_muxid = ioctl(ip_fd, link_type, arp_fd);
+ if (arp_muxid < 0) {
error_report("Can't link TAP device to ARP");
}
--
2.29.1.59.gf9b6481aed
- [PATCH 0/9] Fix some style problems in net, Zhang Han, 2020/12/22
- [PATCH 9/9] net: Fix the indent problems, Zhang Han, 2020/12/22
- [PATCH 8/9] net: Remove initialization of static ints, Zhang Han, 2020/12/22
- [PATCH 5/9] net: Fix lines over 90 characters, Zhang Han, 2020/12/22
- [PATCH 1/9] net: Add spaces around operator/delete redundant spaces, Zhang Han, 2020/12/22
- [PATCH 4/9] net: Transfer "foo* " to "foo *", Zhang Han, 2020/12/22
- [PATCH 7/9] net: Remove assignment in if condition,
Zhang Han <=
- [PATCH 3/9] net: Transfer // comments to /**/, Zhang Han, 2020/12/22
- [PATCH 6/9] net: Transfer tabs to spcaes, Zhang Han, 2020/12/22
- [PATCH 2/9] net: Add braces for statements/fix braces' position, Zhang Han, 2020/12/22
- Re: [PATCH 0/9] Fix some style problems in net, no-reply, 2020/12/22