From: Boris Ostrovsky Subject: [PATCH] compat: Allow CHECK_FIELD_COMMON_ macro deal with fields that are handles Date: Fri, 10 Jan 2014 18:20:03 -0500 Message-ID: <1389396003-32647-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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: boris.ostrovsky@oracle.com List-Id: xen-devel@lists.xenproject.org CHECK_FIELD_COMMON_ and CHECK_FIELD_COMMON macros verify whether the field in 64- and 32-bit versions of a structure is at the same offset by comparing address of the field in both structures. However, if the field itself is a handle, it is either typedef struct { *p; } __guest_handle_ or typedef struct { compat_ptr_t c; *_[0] __attribute__((__packed__)); } __compat_handle_ and compiler will warn that we are trying to compare addresses of different structures. By casting the addresses to (void *) we will avoid this warning. Signed-off-by: Boris Ostrovsky --- xen/include/xen/compat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/xen/compat.h b/xen/include/xen/compat.h index ca60699..6de2d14 100644 --- a/xen/include/xen/compat.h +++ b/xen/include/xen/compat.h @@ -158,14 +158,14 @@ static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ { \ BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \ offsetof(compat_ ## t ## _t, f)); \ - return &x->f == &c->f; \ + return (void *)&x->f == (void *)&c->f; \ } #define CHECK_FIELD_COMMON_(k, name, n, f) \ static inline int name(k xen_ ## n *x, k compat_ ## n *c) \ { \ BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \ offsetof(k compat_ ## n, f)); \ - return &x->f == &c->f; \ + return (void *)&x->f == (void *)&c->f; \ } #define CHECK_FIELD(t, f) \ -- 1.8.1.4