On 4/23/19 2:06 PM, Eric Blake wrote:
Now that cleanup.h is in common code, we can use it in our
filters. The first round focuses just on places that called
nbdkit_extents_free(), as all three callers had multiple exit paths
that definitely benefit from the macro.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
filters/offset/offset.c | 13 +++++--------
filters/partition/partition.c | 12 ++++--------
filters/truncate/truncate.c | 12 ++++--------
filters/offset/Makefile.am | 5 ++++-
filters/partition/Makefile.am | 5 ++++-
filters/truncate/Makefile.am | 5 ++++-
6 files changed, 25 insertions(+), 27 deletions(-)
@@ -322,20 +323,15 @@ truncate_extents (struct nbdkit_next_ops
*next_ops, void *nxdata,
n = count;
else
n = real_size_copy - offset;
- if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1) {
- nbdkit_extents_free (extents2);
+ if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1)
return -1;
- }
for (i = 0; i < nbdkit_extents_count (extents2); ++i) {
struct nbdkit_extent e = nbdkit_get_extent (extents2, i);
- if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) {
- nbdkit_extents_free (extents2);
+ if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1)
return -1;
- }
Of course, we have to re-add the {} if we fix nbdkit_add_extent() to set
reasonable errno so that we can '*err = errno' on failure...
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org