[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools/libxc: add a check in xc_hypercall_buffer_free_pages macro



commit ebbbf9a1fed35105b16cb5dd70501ed3b5fde127
Author:     Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
AuthorDate: Thu May 14 16:55:08 2015 +0800
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Thu May 14 13:02:05 2015 +0100

    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 <yanghy@xxxxxxxxxxxxxx>
    CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    CC: Wei Liu <wei.liu2@xxxxxxxxxx>
    CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    [ ijc -- some rewording of the commit message ]
---
 tools/libxc/include/xenctrl.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 5a9f76a..09a7450 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.
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.