|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 12/14] libxl: Check xc_sharing_* for proper return values.
If there is a negative return value - check for that and
also use errno for the proper error value.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
tools/libxl/libxl.c | 4 ++--
tools/tests/mem-sharing/memshrtool.c | 12 ++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 94b4d59..99a99e9 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5024,7 +5024,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo
*physinfo)
physinfo->scrub_pages = xcphysinfo.scrub_pages;
physinfo->outstanding_pages = xcphysinfo.outstanding_pages;
l = xc_sharing_freed_pages(ctx->xch);
- if (l == -ENOSYS) {
+ if (l < 0 && errno == ENOSYS) {
l = 0;
} else if (l < 0) {
LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
@@ -5033,7 +5033,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo
*physinfo)
}
physinfo->sharing_freed_pages = l;
l = xc_sharing_used_frames(ctx->xch);
- if (l == -ENOSYS) {
+ if (l < 0 && errno == ENOSYS) {
l = 0;
} else if (l < 0) {
LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
diff --git a/tools/tests/mem-sharing/memshrtool.c
b/tools/tests/mem-sharing/memshrtool.c
index db44294..d1dd8a2 100644
--- a/tools/tests/mem-sharing/memshrtool.c
+++ b/tools/tests/mem-sharing/memshrtool.c
@@ -55,11 +55,19 @@ int main(int argc, const char** argv)
if( !strcasecmp(cmd, "info") )
{
+ long rc;
if( argc != 2 )
return usage(argv[0]);
- printf("used = %ld\n", xc_sharing_used_frames(xch));
- printf("freed = %ld\n", xc_sharing_freed_pages(xch));
+ rc = xc_sharing_freed_pages(xch);
+ if ( rc < 0 )
+ return errno;
+
+ printf("used = %ld\n", rc);
+ rc = xc_sharing_used_frames(xch);
+ if ( rc < 0 )
+ return errno;
+ printf("freed = %ld\n", rc);
}
else if( !strcasecmp(cmd, "enable") )
{
--
2.1.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |