dlls/kernel32/thunk.c: use FIELD_OFFSET

Gerald Pfeifer gerald at pfeifer.com
Sun Oct 14 06:25:04 CDT 2007


The current cast is wrong (because the pointer should be DWORD*, not 
WORD*), but anyway we want to use FIELD_OFFSET. ;-)

Gerald

ChangeLog:
Use FIELD_OFFSET instead of pointer cast.

Index: thunk.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel32/thunk.c,v
retrieving revision 1.6
diff -u -3 -p -r1.6 thunk.c
--- thunk.c	9 Apr 2007 12:37:34 -0000	1.6
+++ thunk.c	14 Oct 2007 11:23:15 -0000
@@ -462,7 +462,8 @@ void WINAPI __regs_QT_Thunk( CONTEXT86 *
     context16.Eip   = LOWORD(context->Edx);
     /* point EBP to the STACK16FRAME on the stack
      * for the call_to_16 to set up the register content on calling */
-    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved) + (WORD)&((STACK16FRAME*)0)->bp;
+    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved)
+                      + FIELD_OFFSET(STACK16FRAME,bp);
 
     /*
      * used to be (problematic):
@@ -594,7 +595,8 @@ void WINAPI __regs_FT_Thunk( CONTEXT86 *
     context16.SegGs = wine_get_gs();
     context16.SegCs = HIWORD(callTarget);
     context16.Eip   = LOWORD(callTarget);
-    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved) + (WORD)&((STACK16FRAME*)0)->bp;
+    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved)
+                      + FIELD_OFFSET(STACK16FRAME,bp);
 
     argsize  = context->Ebp-context->Esp-0x40;
     if (argsize > sizeof(newstack)) argsize = sizeof(newstack);
@@ -760,7 +762,8 @@ void WINAPI __regs_Common32ThkLS( CONTEX
     context16.Edi   = LOWORD(context->Ecx);
     context16.SegCs = HIWORD(context->Eax);
     context16.Eip   = LOWORD(context->Eax);
-    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved) + (WORD)&((STACK16FRAME*)0)->bp;
+    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved)
+                      + FIELD_OFFSET(STACK16FRAME,bp);
 
     argsize = HIWORD(context->Edx) * 4;
 
@@ -820,7 +823,8 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT8
     context16.SegGs = wine_get_gs();
     context16.SegCs = HIWORD(context->Edx);
     context16.Eip   = LOWORD(context->Edx);
-    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved) + (WORD)&((STACK16FRAME*)0)->bp;
+    context16.Ebp   = OFFSETOF(NtCurrentTeb()->WOW32Reserved)
+                      + FIELD_OFFSET(STACK16FRAME,bp);
 
     argsize = 2 * *(WORD *)context->Esp + 2;
 



More information about the wine-patches mailing list