From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Hongyang Subject: [PATCH v5 06/14] tools/libxc: add a check in xc_hypercall_buffer_free_pages macro Date: Wed, 13 May 2015 09:53:56 +0800 Message-ID: <1431482044-21286-7-git-send-email-yanghy@cn.fujitsu.com> References: <1431482044-21286-1-git-send-email-yanghy@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431482044-21286-1-git-send-email-yanghy@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, wency@cn.fujitsu.com, andrew.cooper3@citrix.com, yunhong.jiang@intel.com, eddie.dong@intel.com, rshriram@cs.ubc.ca, ian.jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org When we use a DECLARE_HYPERCALL_BUFFER_SHADOW define a user pointer '_name' and a shadow xc_hypercall_buffer_t. then call xc_hypercall_buffer_free_pages(_xch, _name, _nr), the complier will report '_name' unused error, it's because xc_hypercall_buffer_free_pages() is a MACRO and '_name' transparently converted to the hypercall buffer. it confused the caller because xc_hypercall_buffer_free_pages() do look like a function and take '_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 --- tools/libxc/include/xenctrl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 0804257..202f612 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -353,7 +353,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. -- 1.9.1