From: Daniel Stodden Date: Wed, 13 Jul 2011 20:51:37 +0000 (-0700) Subject: VHD: Improve misleading result code from failing vhd_parent_locator_get. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=721768b9b55bbc8432dca203edc5a6c91dda788d;p=people%2Fdstodden%2Fblktap.git VHD: Improve misleading result code from failing vhd_parent_locator_get. 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 --- diff --git a/vhd/lib/libvhd.c b/vhd/lib/libvhd.c index dc15f0f..ba5db3f 100644 --- a/vhd/lib/libvhd.c +++ b/vhd/lib/libvhd.c @@ -1633,7 +1633,7 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent) char *name, *location; vhd_parent_locator_t *loc; - err = 0; + err = -EINVAL; *parent = NULL; if (ctx->footer.type != HD_TYPE_DIFF) @@ -1641,9 +1641,11 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent) 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);