Presently always comes back with -EINVAL, due to a final
vhd_parent_locator_read failing. Fix returns -EINVAL when without
candidates altogether, and the last vhd_find_parent results
otherwise. Such as -ENOENT.
Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
char *name, *location;
vhd_parent_locator_t *loc;
- err = 0;
+ err = -EINVAL;
*parent = NULL;
if (ctx->footer.type != HD_TYPE_DIFF)
n = vhd_parent_locator_count(ctx);
for (i = 0; i < n; i++) {
+ int _err;
+
loc = ctx->header.loc + i;
- err = vhd_parent_locator_read(ctx, loc, &name);
- if (err)
+ _err = vhd_parent_locator_read(ctx, loc, &name);
+ if (_err)
continue;
err = vhd_find_parent(ctx, name, &location);