Follow common recommendations in include/qapi/error.h of having a return value together with errp. This allows to avoid error propagation.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> --- net/tap.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/net/tap.c b/net/tap.c index 3bd81883fd..72464a416d 100644 --- a/net/tap.c +++ b/net/tap.c @@ -703,7 +703,7 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr, #define MAX_TAP_QUEUES 1024 -static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, +static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdname, @@ -784,10 +784,11 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } } - return; + return true; failed: qemu_del_net_client(&s->nc); + return false; } static int get_fds(char *str, char *fds[], int max) @@ -822,7 +823,6 @@ int net_init_tap(const Netdev *netdev, const char *name, const NetdevTapOptions *tap; int fd, vnet_hdr = 0, i = 0, queues; /* for the no-fd, no-helper case */ - Error *err = NULL; const char *vhostfdname; char ifname[128]; int ret = 0; @@ -870,11 +870,9 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } - net_init_tap_one(tap, peer, "tap", name, NULL, - NULL, NULL, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, NULL, + NULL, NULL, + vhostfdname, vnet_hdr, fd, errp)) { close(fd); return -1; } @@ -931,12 +929,10 @@ int net_init_tap(const Netdev *netdev, const char *name, goto free_fail; } - net_init_tap_one(tap, peer, "tap", name, ifname, - NULL, NULL, - tap->vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, ifname, + NULL, NULL, + tap->vhostfds ? vhost_fds[i] : NULL, + vnet_hdr, fd, errp)) { ret = -1; goto free_fail; } @@ -976,11 +972,9 @@ free_fail: return -1; } - net_init_tap_one(tap, peer, "bridge", name, ifname, - NULL, NULL, vhostfdname, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "bridge", name, ifname, + NULL, NULL, vhostfdname, + vnet_hdr, fd, errp)) { close(fd); return -1; } @@ -1016,12 +1010,10 @@ free_fail: } } - net_init_tap_one(tap, peer, "tap", name, ifname, - i >= 1 ? NULL : script, - i >= 1 ? NULL : downscript, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, ifname, + i >= 1 ? NULL : script, + i >= 1 ? NULL : downscript, + vhostfdname, vnet_hdr, fd, errp)) { close(fd); return -1; } -- 2.52.0
