Eric Blake
2019-Mar-29 02:39 UTC
Re: [Libguestfs] [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
On 3/28/19 11:18 AM, Richard W.M. Jones wrote:> --- > filters/truncate/truncate.c | 55 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) >> + extents2 = nbdkit_extents_new (0, real_size_copy); > + if (offset + count <= real_size_copy) > + n = count; > + else > + n = real_size_copy - offset; > + if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1) { > + nbdkit_extents_free (extents2); > + 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); > + return -1; > + } > + } > + nbdkit_extents_free (extents2); > +Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Richard W.M. Jones
2019-Mar-29 08:40 UTC
Re: [Libguestfs] [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
On Thu, Mar 28, 2019 at 09:39:23PM -0500, Eric Blake wrote:> On 3/28/19 11:18 AM, Richard W.M. Jones wrote: > > --- > > filters/truncate/truncate.c | 55 +++++++++++++++++++++++++++++++++++++ > > 1 file changed, 55 insertions(+) > > > > > + extents2 = nbdkit_extents_new (0, real_size_copy); > > + if (offset + count <= real_size_copy) > > + n = count; > > + else > > + n = real_size_copy - offset; > > + if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1) { > > + nbdkit_extents_free (extents2); > > + 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); > > + return -1; > > + } > > + } > > + nbdkit_extents_free (extents2); > > + > > Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters?At the moment the CLEANUP_* macros are only available to server code, not to plugins or filters. They would certainly make plugins and filters easier to write. I would really like attribute((cleanup)) to turn up in ISO C one day :-) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Eric Blake
2019-Mar-29 12:12 UTC
Re: [Libguestfs] [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
On 3/29/19 3:40 AM, Richard W.M. Jones wrote:>>> + nbdkit_extents_free (extents2); >>> + >> >> Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? > > At the moment the CLEANUP_* macros are only available to server code, > not to plugins or filters. They would certainly make plugins and > filters easier to write. I would really like attribute((cleanup)) to > turn up in ISO C one day :-)Justifying it in plugins may or may not be doable (we'd have to have proper inclusion guards so that the cleanup functions are only declared for capable compilers. For filters it may be easier: we already document that all filters might as well live in-tree because we don't guarantee a stable API (case in point - we broke API between 1.11.9 and 1.11.10, and didn't think twice about it). So we know our filters are being compiled with a capable compiler. I don't know if we are installing nbdkit-filters.h in a public location, but it really isn't all that useful outside of nbdkit sources. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Apparently Analagous Threads
- Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
- Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
- [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
- Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
- [nbdkit PATCH] offset, partition: Fix .extents with non-zero offset