On 06/09/2018 10:17 AM, Vladimir Sementsov-Ogievskiy wrote:
Use NBDExport pointer instead of just export name: there no needs to
s/no needs/is no need/
store duplicated name in the struct, moreover, NBDExport will be used
further.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
nbd/server.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
@@ -399,10 +399,9 @@ static int nbd_negotiate_handle_list(NBDClient *client,
Error **errp)
return nbd_negotiate_send_rep(client, NBD_REP_ACK, errp);
}
-static void nbd_check_meta_export_name(NBDClient *client)
+static void nbd_check_meta_export(NBDClient *client)
{
- client->export_meta.valid &= !strcmp(client->exp->name,
- client->export_meta.export_name);
+ client->export_meta.valid &= client->exp == client->export_meta.exp;
Changes from string comparison to pointer comparison...
@@ -853,15 +852,15 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
memset(meta, 0, sizeof(*meta));
- ret = nbd_opt_read_name(client, meta->export_name, NULL, errp);
+ ret = nbd_opt_read_name(client, export_name, NULL, errp);
if (ret <= 0) {
return ret;
}
- exp = nbd_export_find(meta->export_name);
- if (exp == NULL) {
+ meta->exp = nbd_export_find(export_name);
+ if (meta->exp == NULL) {
...by remembering the results of the string comparison performed under
the hood. Looks good.
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org