|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 2/3] libxl: check for underlying xenstore operation failure...
...in libxl__xs_writev_perms() and libxl__xs_printf()
ERROR_FAIL is returned when any underlying operation fails. This is a
semantic change in the case of a vasprintf() failure in libxl__xs_printf(),
but appears to be better than returning a hardcoded -1.
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
tools/libxl/libxl_xshelp.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/libxl/libxl_xshelp.c b/tools/libxl/libxl_xshelp.c
index 3cac4f2..a178039 100644
--- a/tools/libxl/libxl_xshelp.c
+++ b/tools/libxl/libxl_xshelp.c
@@ -57,9 +57,11 @@ int libxl__xs_writev_perms(libxl__gc *gc, xs_transaction_t t,
path = libxl__sprintf(gc, "%s/%s", dir, kvs[i]);
if (path && kvs[i + 1]) {
int length = strlen(kvs[i + 1]);
- xs_write(ctx->xsh, t, path, kvs[i + 1], length);
- if (perms)
- xs_set_permissions(ctx->xsh, t, path, perms, num_perms);
+ if (!xs_write(ctx->xsh, t, path, kvs[i + 1], length))
+ return ERROR_FAIL;
+ if (perms &&
+ !xs_set_permissions(ctx->xsh, t, path, perms, num_perms))
+ return ERROR_FAIL;
}
}
return 0;
@@ -108,11 +110,10 @@ int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
va_end(ap);
if (ret == -1) {
- return -1;
+ return ERROR_FAIL;
}
- xs_write(ctx->xsh, t, path, s, ret);
- free(s);
- return 0;
+ libxl__ptr_add(gc, s);
+ return xs_write(ctx->xsh, t, path, s, ret) ? 0 : ERROR_FAIL;
}
char * libxl__xs_read(libxl__gc *gc, xs_transaction_t t, const char *path)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |