[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v6 05/12] nbd/server: Simplify nbd_negotiate_options
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH v6 05/12] nbd/server: Simplify nbd_negotiate_options loop |
Date: |
Fri, 27 Oct 2017 12:40:30 +0200 |
Instead of making each caller check whether a transmission error
occurred, we can sink a common error check to the end of the loop.
Signed-off-by: Eric Blake <address@hidden>
---
v6: split from length validation [Vladimir]
---
nbd/server.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 05ff7470d5..6af708662d 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -698,9 +698,6 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
"Option 0x%" PRIx32
"not permitted before TLS",
option);
- if (ret < 0) {
- return ret;
- }
/* Let the client keep trying, unless they asked to
* quit. In this mode, we've already sent an error, so
* we can't ack the abort. */
@@ -713,9 +710,6 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
switch (option) {
case NBD_OPT_LIST:
ret = nbd_negotiate_handle_list(client, length, errp);
- if (ret < 0) {
- return ret;
- }
break;
case NBD_OPT_ABORT:
@@ -738,9 +732,6 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
assert(option == NBD_OPT_GO);
return 0;
}
- if (ret) {
- return ret;
- }
break;
case NBD_OPT_STARTTLS:
@@ -758,9 +749,6 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
option, errp,
"TLS not configured");
}
- if (ret < 0) {
- return ret;
- }
break;
default:
if (nbd_drop(client->ioc, length, errp) < 0) {
@@ -772,9 +760,6 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
"Unsupported option 0x%"
PRIx32 " (%s)", option,
nbd_opt_lookup(option));
- if (ret < 0) {
- return ret;
- }
break;
}
} else {
@@ -794,6 +779,9 @@ static int nbd_negotiate_options(NBDClient *client,
uint16_t myflags,
return -EINVAL;
}
}
+ if (ret < 0) {
+ return ret;
+ }
}
}
--
2.13.6
- [Qemu-block] [PATCH v6 00/12] nbd minimal structured read, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 01/12] nbd: Include error names in trace messages, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 02/12] nbd: Move nbd_errno_to_system_errno() to public header, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 03/12] nbd: Expose constants and structs for structured read, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 04/12] nbd/server: Report error for write to read-only export, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 05/12] nbd/server: Simplify nbd_negotiate_options loop,
Eric Blake <=
- [Qemu-block] [PATCH v6 06/12] nbd/server: Refactor zero-length option check, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 07/12] nbd: Minimal structured read for server, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 08/12] nbd/server: Include human-readable message in structured errors, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 10/12] nbd/client: prepare nbd_receive_reply for structured reply, Eric Blake, 2017/10/27
- [Qemu-block] [PATCH v6 09/12] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/10/27