On 3/20/19 5:11 PM, Richard W.M. Jones wrote:
Allows you to safely use nbdkit-offset-filter on top of a plugin supporting extents. --- filters/offset/offset.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
If we don't change our minds on the interface in patch 1, then this looks correct.
+/* Extents. */ +static int +offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, + void *handle, uint32_t count, uint64_t offs, uint32_t flags, + struct nbdkit_extents *extents, int *err) +{ + size_t i; + struct nbdkit_extents *extents2; + struct nbdkit_extent e; + + extents2 = nbdkit_extents_new (offs + offset); + if (extents2 == NULL) { + *err = errno; + return -1; + }
Ouch - nbdkit_extents_new() returns NULL for 'start >= INT64_MAX' without setting errno. Of course, that failure path should be unreachable here, but if you are going to assign *err based on errno, then we have to make sure patch 1 guarantees sane errno settings on all failure paths. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org