net/tap: drop unnecessary nested block
authorPascal Mazon <pascal.mazon@6wind.com>
Fri, 12 May 2017 13:01:38 +0000 (15:01 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:25 +0000 (10:41 +0100)
This is cosmetic; the code is functionally equivalent.

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
drivers/net/tap/rte_eth_tap.c

index 5b99a81..91a957e 100644 (file)
@@ -825,30 +825,26 @@ tap_setup_queue(struct rte_eth_dev *dev,
        struct pmd_internals *pmd = dev->data->dev_private;
        struct rx_queue *rx = &internals->rxq[qid];
        struct tx_queue *tx = &internals->txq[qid];
-       int fd;
+       int fd = rx->fd == -1 ? tx->fd : rx->fd;
 
-       fd = rx->fd;
-       if (fd < 0) {
-               fd = tx->fd;
+       if (fd == -1) {
+               RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid %d\n",
+                       pmd->name, qid);
+               fd = tun_alloc(pmd, qid);
                if (fd < 0) {
-                       RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid %d\n",
+                       RTE_LOG(ERR, PMD, "tun_alloc(%s, %d) failed\n",
                                pmd->name, qid);
-                       fd = tun_alloc(pmd, qid);
-                       if (fd < 0) {
-                               RTE_LOG(ERR, PMD, "tun_alloc(%s, %d) failed\n",
-                                       pmd->name, qid);
+                       return -1;
+               }
+               if (qid == 0) {
+                       struct ifreq ifr;
+
+                       ifr.ifr_mtu = dev->data->mtu;
+                       if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1,
+                                     LOCAL_AND_REMOTE) < 0) {
+                               close(fd);
                                return -1;
                        }
-                       if (qid == 0) {
-                               struct ifreq ifr;
-
-                               ifr.ifr_mtu = dev->data->mtu;
-                               if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1,
-                                             LOCAL_AND_REMOTE) < 0) {
-                                       close(fd);
-                                       return -1;
-                               }
-                       }
                }
        }