qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/6] nbd/server: use errp instead of LOG


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-devel] [PATCH v2 2/6] nbd/server: use errp instead of LOG
Date: Fri, 7 Jul 2017 18:10:37 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

07.07.2017 17:40, Eric Blake wrote:
On 06/21/2017 10:34 AM, Vladimir Sementsov-Ogievskiy wrote:
Move to modern errp scheme from just LOGging errors.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
  nbd/server.c | 268 +++++++++++++++++++++++++++++++++++------------------------
  1 file changed, 161 insertions(+), 107 deletions(-)
-static coroutine_fn int nbd_negotiate(NBDClient *client)
+static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
  {
      char buf[8 + 8 + 8 + 128];
      int ret;
Now that you have this,

     qio_channel_set_blocking(client->ioc, false, NULL);

you should probably pass errp through to qio_channel_set_blocking and
return early if that fails (either here or in one of the followup
patches) [hmm, I note that most callers of qio_channel_set_blocking()
ignore errors - outside of NBD, so that's a separate cleanup series]

I've looked through realizations of ioc_klass->io_set_blocking - looks like they all are returning zero always.



@@ -591,21 +617,23 @@ static coroutine_fn int nbd_negotiate(NBDClient *client)
if (oldStyle) {
          if (client->tlscreds) {
-            TRACE("TLS cannot be enabled with oldstyle protocol");
+            error_setg(errp, "TLS cannot be enabled with oldstyle protocol");
              return -EINVAL;
This code is unreachable, since earlier we have:

     oldStyle = client->exp != NULL && !client->tlscreds;
You could just as easily delete the conditional.  In fact, our code has:

if (oldStyle) {
     do stuff
} else {
     do stuff
}

if (oldStyle) {
     do stuff
} else {
     do stuff
}

and it would be simple to merge that into a single if statement.


--
Best regards,
Vladimir




reply via email to

[Prev in Thread] Current Thread [Next in Thread]