All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, jasowang@redhat.com, vsementsov@virtuozzo.com
Subject: [PATCH 3/5] net/tap: tap_set_sndbuf(): return status
Date: Mon, 21 Dec 2020 22:06:07 +0300	[thread overview]
Message-ID: <20201221190609.93768-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20201221190609.93768-1-vsementsov@virtuozzo.com>

It's recommended to return a value indicating success / failure for
functions with errp parameter (see include/qapi/error.h). Let's update
tap_set_sndbuf().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 net/tap_int.h   | 2 +-
 net/tap-linux.c | 5 ++++-
 net/tap-stub.c  | 2 +-
 net/tap.c       | 6 +++---
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/net/tap_int.h b/net/tap_int.h
index 225a49ea48..57567b9f24 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -33,7 +33,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
 
 ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen);
 
-void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp);
+int tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp);
 int tap_probe_vnet_hdr(int fd, Error **errp);
 int tap_probe_vnet_hdr_len(int fd, int len);
 int tap_probe_has_ufo(int fd);
diff --git a/net/tap-linux.c b/net/tap-linux.c
index b0635e9e32..c51bcdc2a3 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -130,7 +130,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
  */
 #define TAP_DEFAULT_SNDBUF 0
 
-void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
+int tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
 {
     int sndbuf;
 
@@ -144,7 +144,10 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
 
     if (ioctl(fd, TUNSETSNDBUF, &sndbuf) == -1 && tap->has_sndbuf) {
         error_setg_errno(errp, errno, "TUNSETSNDBUF ioctl failed");
+        return -1;
     }
+
+    return 0;
 }
 
 int tap_probe_vnet_hdr(int fd, Error **errp)
diff --git a/net/tap-stub.c b/net/tap-stub.c
index 6fa130758b..473d5e4afe 100644
--- a/net/tap-stub.c
+++ b/net/tap-stub.c
@@ -26,7 +26,7 @@
 #include "qapi/error.h"
 #include "tap_int.h"
 
-void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
+int tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
 {
 }
 
diff --git a/net/tap.c b/net/tap.c
index 75b01d54ee..33d749c7b6 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -661,10 +661,10 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
     Error *err = NULL;
     TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr);
     int vhostfd;
+    int ret;
 
-    tap_set_sndbuf(s->fd, tap, &err);
-    if (err) {
-        error_propagate(errp, err);
+    ret = tap_set_sndbuf(s->fd, tap, errp);
+    if (ret < 0) {
         return;
     }
 
-- 
2.28.0



  parent reply	other threads:[~2020-12-21 19:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 19:06 [PATCH 0/5] net/tap: some fixes and refactorings Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 1/5] net/tap: fix net_init_tap(): set ret on failure path Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 2/5] net/tap: drop duplicated tap stubs Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` Vladimir Sementsov-Ogievskiy [this message]
2020-12-21 20:12   ` [PATCH 3/5] net/tap: tap_set_sndbuf(): return status Philippe Mathieu-Daudé
2020-12-22  9:50     ` Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 4/5] net/tap: refactor and improve net_init_tap_one() Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 5/5] net/tap: net_init_tap_one(): fix net-client leak on failure path Vladimir Sementsov-Ogievskiy
2021-01-12  4:53   ` Jason Wang
2021-12-23 16:45     ` Vladimir Sementsov-Ogievskiy
2021-01-09  9:58 ` [PATCH 0/5] net/tap: some fixes and refactorings Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221190609.93768-4-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.