This makes more obvious, where the variables make sense.

Note that ifname, script and downscript variables are not used in
net_init_tap_one() for fd/fds/helper cases.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@yandex-team.ru>
---
 net/tap.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index ade58826c8..80ec54f914 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -803,19 +803,11 @@ static int get_fds(char *str, char *fds[], int max)
 int net_init_tap(const Netdev *netdev, const char *name,
                  NetClientState *peer, Error **errp)
 {
-    const NetdevTapOptions *tap;
-    int fd, vnet_hdr = 0, i = 0, queues;
-    /* for the no-fd, no-helper case */
-    const char *script;
-    const char *downscript;
-    char ifname[128];
+    const NetdevTapOptions *tap = &netdev->u.tap;
+    int fd, vnet_hdr = 0, i = 0;
     int ret = 0;
 
     assert(netdev->type == NET_CLIENT_DRIVER_TAP);
-    tap = &netdev->u.tap;
-    queues = tap->has_queues ? tap->queues : 1;
-    script = tap->script;
-    downscript = tap->downscript;
 
     /* QEMU hubs do not support multiqueue tap, in this case peer is set.
      * For -netdev, peer is always NULL. */
@@ -861,7 +853,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
         }
 
         ret = net_init_tap_one(tap, peer, "tap", name, NULL,
-                               script, downscript,
+                               NULL, NULL,
                                tap->vhostfd, vnet_hdr, fd, errp);
         if (ret < 0) {
             return -1;
@@ -915,8 +907,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
                 goto free_fail;
             }
 
-            ret = net_init_tap_one(tap, peer, "tap", name, ifname,
-                                   script, downscript,
+            ret = net_init_tap_one(tap, peer, "tap", name, NULL,
+                                   NULL, NULL,
                                    tap->vhostfds ? vhost_fds[i] : NULL,
                                    vnet_hdr, fd, errp);
             if (ret < 0) {
@@ -957,16 +949,21 @@ free_fail:
             return -1;
         }
 
-        ret = net_init_tap_one(tap, peer, "bridge", name, ifname,
-                               script, downscript, tap->vhostfd,
+        ret = net_init_tap_one(tap, peer, "bridge", name, NULL,
+                               NULL, NULL, tap->vhostfd,
                                vnet_hdr, fd, errp);
         if (ret < 0) {
             close(fd);
             return -1;
         }
     } else {
+        const char *script = tap->script;
+        const char *downscript = tap->downscript;
+        int queues = tap->has_queues ? tap->queues : 1;
         g_autofree char *default_script = NULL;
         g_autofree char *default_downscript = NULL;
+        char ifname[128];
+
         if (tap->vhostfds) {
             error_setg(errp, "vhostfds= is invalid if fds= wasn't specified");
             return -1;
-- 
2.48.1


Reply via email to