]> Git Repo - qemu.git/commitdiff
nbd/server: refactor nbd_negotiate
authorVladimir Sementsov-Ogievskiy <[email protected]>
Fri, 7 Jul 2017 15:29:10 +0000 (18:29 +0300)
committerEric Blake <[email protected]>
Mon, 10 Jul 2017 14:57:24 +0000 (09:57 -0500)
Combine two successive "if (oldStyle) {...} else {...}" into one.

Block "if (client->tlscreds)" under "if (oldStyle)" is unreachable,
as we have "oldStyle = client->exp != NULL && !client->tlscreds;".
So, delete this block.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20170707152918[email protected]>
Signed-off-by: Eric Blake <[email protected]>
nbd/server.c

index 39639723378eb02bf29e364f1cf45956c87bdd30..a6a57ce7c102c59df9bd2363db15407505581d11 100644 (file)
@@ -584,21 +584,15 @@ static coroutine_fn int nbd_negotiate(NBDClient *client)
         stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
         stq_be_p(buf + 16, client->exp->size);
         stw_be_p(buf + 26, client->exp->nbdflags | myflags);
-    } else {
-        stq_be_p(buf + 8, NBD_OPTS_MAGIC);
-        stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
-    }
 
-    if (oldStyle) {
-        if (client->tlscreds) {
-            TRACE("TLS cannot be enabled with oldstyle protocol");
-            return -EINVAL;
-        }
         if (nbd_write(client->ioc, buf, sizeof(buf), NULL) < 0) {
             LOG("write failed");
             return -EINVAL;
         }
     } else {
+        stq_be_p(buf + 8, NBD_OPTS_MAGIC);
+        stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
+
         if (nbd_write(client->ioc, buf, 18, NULL) < 0) {
             LOG("write failed");
             return -EINVAL;
This page took 0.025072 seconds and 4 git commands to generate.