]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
VHD: Improve misleading result code from failing vhd_parent_locator_get.
authorDaniel Stodden <daniel.stodden@citrix.com>
Wed, 13 Jul 2011 20:51:37 +0000 (13:51 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Wed, 13 Jul 2011 21:00:01 +0000 (14:00 -0700)
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>
vhd/lib/libvhd.c

index dc15f0faecf1a1579bd51251a4300f43fa181740..ba5db3ffca2e2ea61bb0446fab892c26b7f092ff 100644 (file)
@@ -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);