diff options
author | Eric Blake <eblake@redhat.com> | 2019-08-24 12:28:12 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2019-09-05 15:52:45 -0500 |
commit | df18c04edf57b55737ed5125bffe71a8196938a0 (patch) | |
tree | 8736b0cfd329925185320014721c549f087af0c4 /block/nbd.c | |
parent | 61cc872456492da24e36cfbd668abfbe127c739f (diff) | |
download | qemu-df18c04edf57b55737ed5125bffe71a8196938a0.zip qemu-df18c04edf57b55737ed5125bffe71a8196938a0.tar.gz qemu-df18c04edf57b55737ed5125bffe71a8196938a0.tar.bz2 |
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>
Diffstat (limited to 'block/nbd.c')
-rw-r--r-- | block/nbd.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/block/nbd.c b/block/nbd.c index beed46f..c4c91a1 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1374,7 +1374,7 @@ static bool nbd_has_filename_options_conflict(QDict *options, Error **errp) static void nbd_parse_filename(const char *filename, QDict *options, Error **errp) { - char *file; + g_autofree char *file = NULL; char *export_name; const char *host_spec; const char *unixpath; @@ -1396,7 +1396,7 @@ static void nbd_parse_filename(const char *filename, QDict *options, export_name = strstr(file, EN_OPTSTR); if (export_name) { if (export_name[strlen(EN_OPTSTR)] == 0) { - goto out; + return; } export_name[0] = 0; /* truncate 'file' */ export_name += strlen(EN_OPTSTR); @@ -1407,11 +1407,11 @@ static void nbd_parse_filename(const char *filename, QDict *options, /* extract the host_spec - fail if it's not nbd:... */ if (!strstart(file, "nbd:", &host_spec)) { error_setg(errp, "File name string for NBD must start with 'nbd:'"); - goto out; + return; } if (!*host_spec) { - goto out; + return; } /* are we a UNIX or TCP socket? */ @@ -1431,9 +1431,6 @@ static void nbd_parse_filename(const char *filename, QDict *options, out_inet: qapi_free_InetSocketAddress(addr); } - -out: - g_free(file); } static bool nbd_process_legacy_socket_options(QDict *output_options, |