From: Konrad Rzeszutek Wilk Date: Thu, 19 Mar 2015 00:24:17 +0000 (-0400) Subject: libxc: Check xc_sharing_* for proper return values. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3549 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=650c9e5469e98f4b8b73f5aab5d4830e00603320;p=xen.git libxc: 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 Acked-by: Ian Campbell --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index b058166291..ff7515ac52 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5071,7 +5071,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, @@ -5080,7 +5080,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 db44294230..6454bc3e9c 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 1; + + printf("used = %ld\n", rc); + rc = xc_sharing_used_frames(xch); + if ( rc < 0 ) + return 1; + printf("freed = %ld\n", rc); } else if( !strcasecmp(cmd, "enable") ) {