nbd/server: refactor nbd_negotiate
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 <vsementsov@virtuozzo.com> Message-Id: <20170707152918.23086-3-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
1e120ffead
commit
76ff081d91
12
nbd/server.c
12
nbd/server.c
|
@ -584,21 +584,15 @@ static coroutine_fn int nbd_negotiate(NBDClient *client)
|
||||||
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
|
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
|
||||||
stq_be_p(buf + 16, client->exp->size);
|
stq_be_p(buf + 16, client->exp->size);
|
||||||
stw_be_p(buf + 26, client->exp->nbdflags | myflags);
|
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) {
|
if (nbd_write(client->ioc, buf, sizeof(buf), NULL) < 0) {
|
||||||
LOG("write failed");
|
LOG("write failed");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if (nbd_write(client->ioc, buf, 18, NULL) < 0) {
|
||||||
LOG("write failed");
|
LOG("write failed");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue