From: Yang Hongyang Date: Thu, 14 May 2015 08:55:08 +0000 (+0800) Subject: tools/libxc: add a check in xc_hypercall_buffer_free_pages macro X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3246 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ebbbf9a1fed35105b16cb5dd70501ed3b5fde127;p=xen.git tools/libxc: add a check in xc_hypercall_buffer_free_pages macro When we use a DECLARE_HYPERCALL_BUFFER_SHADOW it defines a user pointer '_name' and a shadow xc_hypercall_buffer_t. When calling xc_hypercall_buffer_free_pages(_xch, _name, _nr), the complier will report '_name' unused error, because xc_hypercall_buffer_free_pages() is a MACRO and '_name' is transparently converted to the hypercall buffer. it confuses the caller because xc_hypercall_buffer_free_pages() looks like a function and takes '_name' as an arg. Add an if check to let the compiler think we are actually using the argument '_name'. Signed-off-by: Yang Hongyang CC: Ian Campbell CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper Acked-by: Ian Campbell [ ijc -- some rewording of the commit message ] --- diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 5a9f76a9ab..09a7450519 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -358,7 +358,12 @@ void xc__hypercall_buffer_free(xc_interface *xch, xc_hypercall_buffer_t *b); void *xc__hypercall_buffer_alloc_pages(xc_interface *xch, xc_hypercall_buffer_t *b, int nr_pages); #define xc_hypercall_buffer_alloc_pages(_xch, _name, _nr) xc__hypercall_buffer_alloc_pages(_xch, HYPERCALL_BUFFER(_name), _nr) void xc__hypercall_buffer_free_pages(xc_interface *xch, xc_hypercall_buffer_t *b, int nr_pages); -#define xc_hypercall_buffer_free_pages(_xch, _name, _nr) xc__hypercall_buffer_free_pages(_xch, HYPERCALL_BUFFER(_name), _nr) +#define xc_hypercall_buffer_free_pages(_xch, _name, _nr) \ + do { \ + if ( _name ) \ + xc__hypercall_buffer_free_pages(_xch, HYPERCALL_BUFFER(_name), \ + _nr); \ + } while (0) /* * Array of hypercall buffers.