mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
nbd: Use g_autofree in a few places
Thanks to our recent move to use glib's g_autofree, I can join the bandwagon. Getting rid of gotos is fun ;) There are probably more places where we could register cleanup functions and get rid of more gotos; this patch just focuses on the labels that existed merely to call g_free. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20190824172813.29720-2-eblake@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
parent
61cc872456
commit
df18c04edf
3 changed files with 15 additions and 30 deletions
12
nbd/server.c
12
nbd/server.c
|
@ -206,7 +206,7 @@ static int GCC_FMT_ATTR(4, 0)
|
|||
nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
|
||||
Error **errp, const char *fmt, va_list va)
|
||||
{
|
||||
char *msg;
|
||||
g_autofree char *msg = NULL;
|
||||
int ret;
|
||||
size_t len;
|
||||
|
||||
|
@ -216,18 +216,14 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
|
|||
trace_nbd_negotiate_send_rep_err(msg);
|
||||
ret = nbd_negotiate_send_rep_len(client, type, len, errp);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
if (nbd_write(client->ioc, msg, len, errp) < 0) {
|
||||
error_prepend(errp, "write failed (error message): ");
|
||||
ret = -EIO;
|
||||
} else {
|
||||
ret = 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
out:
|
||||
g_free(msg);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Send an error reply.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue