From: "Jan Beulich" Subject: Re: [PATCH 4/5] xen: Enforce casting for guest_handle_cast Date: Thu, 31 May 2012 16:47:41 +0100 Message-ID: <4FC7AEBD020000780008774C@nat28.tlf.novell.com> References: <1338476832-26653-1-git-send-email-jean.guyader@citrix.com> <1338476832-26653-5-git-send-email-jean.guyader@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1338476832-26653-5-git-send-email-jean.guyader@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jean Guyader Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 31.05.12 at 17:07, Jean Guyader wrote: >--- a/xen/include/asm-x86/guest_access.h >+++ b/xen/include/asm-x86/guest_access.h >@@ -47,7 +47,7 @@ > > /* Cast a guest handle to the specified type of handle. */ > #define guest_handle_cast(hnd, type) ({ \ >- type *_x = (hnd).p; \ >+ type *_x = (type *)(hnd).p; \ You would have to explain how this is safe: Without the cast, we get compiler warnings (and hence build failures due to -Werror) if "type *" and typeof((hnd).p) are incompatible. Adding an explicit cast removes that intentional check. Jan > (XEN_GUEST_HANDLE(type)) { _x }; \ > }) >