From: "Jan Beulich" Subject: [PATCH 2/3] linux/x86: avoid casting hypercall return value Date: Tue, 29 Jan 2008 10:46:39 +0000 Message-ID: <479F121F.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org .., being a little more type correct and producing better code on 64-bits. As usual, written and tested on 2.6.24 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich Index: head-2008-01-28/include/asm-i386/mach-xen/asm/hypercall.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2008-01-28.orig/include/asm-i386/mach-xen/asm/hypercall.h = 2008-01-29 09:53:01.000000000 +0100 +++ head-2008-01-28/include/asm-i386/mach-xen/asm/hypercall.h 2008-01-29 = 10:09:17.000000000 +0100 @@ -52,40 +52,43 @@ =20 #define _hypercall0(type, name) \ ({ \ - long __res; \ + type __res; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res) \ : \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall1(type, name, a1) \ ({ \ - long __res, __ign1; \ + type __res; \ + long __ign1; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3Db" (__ign1) \ : "1" ((long)(a1)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall2(type, name, a1, a2) \ ({ \ - long __res, __ign1, __ign2; \ + type __res; \ + long __ign1, __ign2; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3Db" (__ign1), "=3Dc" (__ign2) \ : "1" ((long)(a1)), "2" ((long)(a2)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall3(type, name, a1, a2, a3) \ ({ \ - long __res, __ign1, __ign2, __ign3; \ + type __res; \ + long __ign1, __ign2, __ign3; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3Db" (__ign1), "=3Dc" (__ign2), \ @@ -93,12 +96,13 @@ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall4(type, name, a1, a2, a3, a4) \ ({ \ - long __res, __ign1, __ign2, __ign3, __ign4; \ + type __res; \ + long __ign1, __ign2, __ign3, __ign4; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3Db" (__ign1), "=3Dc" (__ign2), \ @@ -106,12 +110,13 @@ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)), "4" ((long)(a4)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \ ({ \ - long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \ + type __res; \ + long __ign1, __ign2, __ign3, __ign4, __ign5; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3Db" (__ign1), "=3Dc" (__ign2), \ @@ -120,7 +125,7 @@ "3" ((long)(a3)), "4" ((long)(a4)), \ "5" ((long)(a5)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 static inline int __must_check Index: head-2008-01-28/include/asm-x86_64/mach-xen/asm/hypercall.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2008-01-28.orig/include/asm-x86_64/mach-xen/asm/hypercall.h = 2008-01-29 10:03:28.000000000 +0100 +++ head-2008-01-28/include/asm-x86_64/mach-xen/asm/hypercall.h 2008-01-29 = 10:15:17.000000000 +0100 @@ -56,40 +56,43 @@ =20 #define _hypercall0(type, name) \ ({ \ - long __res; \ + type __res; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res) \ : \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall1(type, name, a1) \ ({ \ - long __res, __ign1; \ + type __res; \ + long __ign1; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3DD" (__ign1) \ : "1" ((long)(a1)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall2(type, name, a1, a2) \ ({ \ - long __res, __ign1, __ign2; \ + type __res; \ + long __ign1, __ign2; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3DD" (__ign1), "=3DS" (__ign2) \ : "1" ((long)(a1)), "2" ((long)(a2)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall3(type, name, a1, a2, a3) \ ({ \ - long __res, __ign1, __ign2, __ign3; \ + type __res; \ + long __ign1, __ign2, __ign3; \ asm volatile ( \ HYPERCALL_STR(name) \ : "=3Da" (__res), "=3DD" (__ign1), "=3DS" (__ign2), \ @@ -97,12 +100,13 @@ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall4(type, name, a1, a2, a3, a4) \ ({ \ - long __res, __ign1, __ign2, __ign3; \ + type __res; \ + long __ign1, __ign2, __ign3; \ register long __arg4 asm("r10") =3D (long)(a4); \ asm volatile ( \ HYPERCALL_STR(name) \ @@ -111,12 +115,13 @@ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \ ({ \ - long __res, __ign1, __ign2, __ign3; \ + type __res; \ + long __ign1, __ign2, __ign3; \ register long __arg4 asm("r10") =3D (long)(a4); \ register long __arg5 asm("r8") =3D (long)(a5); \ asm volatile ( \ @@ -126,7 +131,7 @@ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)) \ : "memory" ); \ - (type)__res; \ + __res; \ }) =20 static inline int __must_check