Put the assignment before the if condition Signed-off-by: Zhang Han <zhangha...@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