PATCH: dlls/x11drv strict aliasing
Marcus Meissner
marcus at jet.franken.de
Sat May 1 11:46:27 CDT 2004
Hi,
More strict aliasing fixes. This time with lots of unions.
Also lvalue fixes.
Ciao, Marcus
Changelog:
Fixed strict aliasing problems by using unions.
Removed lvalue casts.
Index: dlls/x11drv/clipboard.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/clipboard.c,v
retrieving revision 1.24
diff -u -r1.24 clipboard.c
--- dlls/x11drv/clipboard.c 5 Apr 2004 20:17:13 -0000 1.24
+++ dlls/x11drv/clipboard.c 1 May 2004 16:43:11 -0000
@@ -1156,7 +1156,12 @@
*/
HANDLE X11DRV_CLIPBOARD_ImportMetaFilePict(LPBYTE lpdata, UINT cBytes)
{
- return X11DRV_CLIPBOARD_SerializeMetafile(CF_METAFILEPICT, (HANDLE)lpdata, (LPDWORD)&cBytes, FALSE);
+ union {
+ UINT i;
+ DWORD d;
+ } tmp;
+ tmp.i = cBytes;
+ return X11DRV_CLIPBOARD_SerializeMetafile(CF_METAFILEPICT, (HANDLE)lpdata, &tmp.d, FALSE);
}
@@ -1167,7 +1172,12 @@
*/
HANDLE X11DRV_CLIPBOARD_ImportEnhMetaFile(LPBYTE lpdata, UINT cBytes)
{
- return X11DRV_CLIPBOARD_SerializeMetafile(CF_ENHMETAFILE, (HANDLE)lpdata, (LPDWORD)&cBytes, FALSE);
+ union {
+ UINT i;
+ DWORD d;
+ } tmp;
+ tmp.i = cBytes;
+ return X11DRV_CLIPBOARD_SerializeMetafile(CF_ENHMETAFILE, (HANDLE)lpdata, &tmp.d, FALSE);
}
@@ -1472,10 +1482,13 @@
Atom atype=AnyPropertyType;
int aformat;
unsigned long remain;
- Atom* targetList=NULL;
Window w;
HWND hWndClipWindow;
unsigned long cSelectionTargets = 0;
+ union {
+ Atom *atoms;
+ unsigned char *cptr;
+ } targetList;
if (selectionAcquired & (S_PRIMARY | S_CLIPBOARD))
{
@@ -1543,7 +1556,7 @@
wine_tsx11_lock();
if(XGetWindowProperty(display, xe.xselection.requestor, xe.xselection.property,
0, 0x3FFF, True, AnyPropertyType/*XA_ATOM*/, &atype, &aformat, &cSelectionTargets,
- &remain, (unsigned char**)&targetList) != Success)
+ &remain, &targetList.cptr) != Success)
{
wine_tsx11_unlock();
WARN("Failed to read TARGETS property\n");
@@ -1565,17 +1578,17 @@
/* Cache these formats in the clipboard cache */
for (i = 0; i < cSelectionTargets; i++)
{
- LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupProperty(targetList[i]);
+ LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupProperty(targetList.atoms[i]);
if (!lpFormat)
- lpFormat = X11DRV_CLIPBOARD_LookupAliasProperty(targetList[i]);
+ lpFormat = X11DRV_CLIPBOARD_LookupAliasProperty(targetList.atoms[i]);
if (!lpFormat)
{
/* add it to the list of atoms that we don't know about yet */
if (!atoms) atoms = HeapAlloc( GetProcessHeap(), 0,
(cSelectionTargets - i) * sizeof(*atoms) );
- if (atoms) atoms[nb_atoms++] = targetList[i];
+ if (atoms) atoms[nb_atoms++] = targetList.atoms[i];
}
else
{
@@ -1616,7 +1629,7 @@
/* Free the list of targets */
wine_tsx11_lock();
- XFree(targetList);
+ XFree(targetList.atoms);
wine_tsx11_unlock();
}
Index: dlls/x11drv/dib_convert.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/dib_convert.c,v
retrieving revision 1.1
diff -u -r1.1 dib_convert.c
--- dlls/x11drv/dib_convert.c 25 Nov 2003 03:27:38 -0000 1.1
+++ dlls/x11drv/dib_convert.c 1 May 2004 16:43:12 -0000
@@ -1187,9 +1187,11 @@
dstbyte=(BYTE*)dstpixel;
for (x=0; x<oddwidth; x++) {
DWORD srcval;
+ WORD *wdstbyte = (WORD*)dstbyte;
srcval=*srcpixel++;
- *((WORD*)dstbyte)++=srcval; /* h, g */
- *dstbyte++=srcval >> 16; /* l */
+ *wdstbyte = srcval; /* h, g */
+ dstbyte += 2;
+ *dstbyte++=srcval >> 16; /* l */
}
srcbits = (char*)srcbits + srclinebytes;
dstbits = (char*)dstbits + dstlinebytes;
@@ -1238,9 +1240,11 @@
dstbyte=(BYTE*)dstpixel;
for (x=0; x<oddwidth; x++) {
DWORD srcval;
+ WORD *wdstbyte = (WORD*)dstbyte;;
srcval=*srcpixel++;
- *((WORD*)dstbyte)++=((srcval >> 16) & 0x00ff) | /* h */
- (srcval & 0xff00); /* g */
+ *wdstbyte=((srcval >> 16) & 0x00ff) | /* h */
+ (srcval & 0xff00); /* g */
+ dstbyte += sizeof(WORD);
*dstbyte++=srcval; /* l */
}
srcbits = (char*)srcbits + srclinebytes;
Index: dlls/x11drv/dib_src_swap.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/dib_src_swap.c,v
retrieving revision 1.1
diff -u -r1.1 dib_src_swap.c
--- dlls/x11drv/dib_src_swap.c 25 Nov 2003 03:27:38 -0000 1.1
+++ dlls/x11drv/dib_src_swap.c 1 May 2004 16:43:12 -0000
@@ -1358,9 +1358,11 @@
dstbyte=(BYTE*)dstpixel;
for (x=0; x<oddwidth; x++) {
DWORD srcval;
+ WORD *dstword = (WORD*)dstbyte;
srcval=*srcpixel++;
FLIP_DWORD(&srcval);
- *((WORD*)dstbyte)++=srcval; /* h, g */
+ *dstword = srcval; /* h, g */
+ dstbyte+=sizeof(WORD);
*dstbyte++=srcval >> 16; /* l */
}
srcbits = (char*)srcbits + srclinebytes;
@@ -1404,8 +1406,10 @@
dstbyte=(BYTE*)dstpixel;
for (x=0; x<oddwidth; x++) {
DWORD srcval;
+ WORD *dstword = (WORD*)dstbyte;
srcval=*srcpixel++;
- *((WORD*)dstbyte)++=((srcval >> 8) & 0xffff); /* g, h */
+ *dstword = ((srcval >> 8) & 0xffff); /* g, h */
+ dstbyte += sizeof(WORD);
*dstbyte++= srcval >> 24; /* l */
}
srcbits = (char*)srcbits + srclinebytes;
Index: dlls/x11drv/event.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/event.c,v
retrieving revision 1.34
diff -u -r1.34 event.c
--- dlls/x11drv/event.c 19 Mar 2004 01:17:32 -0000 1.34
+++ dlls/x11drv/event.c 1 May 2004 16:43:13 -0000
@@ -268,8 +268,16 @@
#endif
wine_tsx11_lock();
- if (XFindContext( display, event->xany.window, winContext, (char **)&hWnd ) != 0)
+ {
+ union {
+ HWND hwnd;
+ char *ptr;
+ } xhwnd;
+ if (XFindContext( display, event->xany.window, winContext, &xhwnd.ptr ) != 0)
hWnd = 0; /* Not for a registered window */
+ else
+ hWnd = xhwnd.hwnd;
+ }
wine_tsx11_unlock();
if (!hWnd && event->xany.window == root_window) hWnd = GetDesktopWindow();
@@ -527,7 +535,6 @@
*/
static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
{
- HWND hwnd_tmp;
Window focus_win;
int revert;
XIC xic;
@@ -554,7 +561,8 @@
XGetInputFocus( thread_display(), &focus_win, &revert );
if (focus_win)
{
- if (XFindContext( thread_display(), focus_win, winContext, (char **)&hwnd_tmp ) != 0)
+ char *hwnd_tmp;
+ if (XFindContext( thread_display(), focus_win, winContext, &hwnd_tmp ) != 0)
focus_win = 0;
}
wine_tsx11_unlock();
@@ -700,7 +708,10 @@
Atom atype=AnyPropertyType;
int aformat;
unsigned long remain;
- Atom* targetPropList=NULL;
+ union {
+ Atom *atoms;
+ unsigned char *ptr;
+ } targetPropList = { NULL };
unsigned long cTargetPropList = 0;
/* If the specified property is None the requestor is an obsolete client.
@@ -719,7 +730,7 @@
if(XGetWindowProperty(display, pevent->requestor, rprop,
0, 0x3FFF, False, AnyPropertyType, &atype,&aformat,
&cTargetPropList, &remain,
- (unsigned char**)&targetPropList) != Success)
+ &targetPropList.ptr) != Success)
{
wine_tsx11_unlock();
TRACE("\tCouldn't read MULTIPLE property\n");
@@ -753,8 +764,8 @@
{
char *targetName, *propName;
wine_tsx11_lock();
- targetName = XGetAtomName(display, targetPropList[i]);
- propName = XGetAtomName(display, targetPropList[i+1]);
+ targetName = XGetAtomName(display, targetPropList.atoms[i]);
+ propName = XGetAtomName(display, targetPropList.atoms[i+1]);
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
i/2, targetName, propName);
XFree(targetName);
@@ -763,7 +774,7 @@
}
/* We must have a non "None" property to service a MULTIPLE target atom */
- if ( !targetPropList[i+1] )
+ if ( !targetPropList.atoms[i+1] )
{
TRACE("\tMULTIPLE(%d): Skipping target with empty property!\n", i);
continue;
@@ -771,8 +782,8 @@
/* Set up an XSelectionRequestEvent for this (target,property) pair */
memcpy( &event, pevent, sizeof(XSelectionRequestEvent) );
- event.target = targetPropList[i];
- event.property = targetPropList[i+1];
+ event.target = targetPropList.atoms[i];
+ event.property = targetPropList.atoms[i+1];
/* Fire a SelectionRequest, informing the handler that we are processing
* a MULTIPLE selection request event.
@@ -783,7 +794,7 @@
/* Free the list of targets/properties */
wine_tsx11_lock();
- XFree(targetPropList);
+ XFree(targetPropList.atoms);
wine_tsx11_unlock();
}
@@ -935,20 +946,23 @@
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
{
- RECT tempRect;
+ union {
+ RECT rect;
+ POINT pt[2];
+ } tmp;
if (!IsWindowEnabled(hQueryWnd)) return 0;
- GetWindowRect(hQueryWnd, &tempRect);
+ GetWindowRect(hQueryWnd, &tmp.rect);
- if(!PtInRect(&tempRect, *lpPt)) return 0;
+ if(!PtInRect(&tmp.rect, *lpPt)) return 0;
if (!IsIconic( hQueryWnd ))
{
- GetClientRect( hQueryWnd, &tempRect );
- MapWindowPoints( hQueryWnd, 0, (LPPOINT)&tempRect, 2 );
+ GetClientRect( hQueryWnd, &tmp.rect );
+ MapWindowPoints( hQueryWnd, 0, tmp.pt, 2 );
- if (PtInRect( &tempRect, *lpPt))
+ if (PtInRect( &tmp.rect, *lpPt))
{
HWND *list = WIN_ListChildren( hQueryWnd );
HWND bResult = 0;
@@ -961,8 +975,8 @@
{
if (GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)
{
- GetWindowRect( list[i], &tempRect );
- if (PtInRect( &tempRect, *lpPt )) break;
+ GetWindowRect( list[i], &tmp.rect );
+ if (PtInRect( &tmp.rect, *lpPt )) break;
}
}
if (list[i])
@@ -992,6 +1006,7 @@
{
unsigned long data_length;
unsigned long aux_long;
+ unsigned int aux_uint;
unsigned char* p_data = NULL;
union {
Atom atom_aux;
@@ -1011,8 +1026,7 @@
wine_tsx11_lock();
XQueryPointer( event->display, get_whole_window(pWnd), &w_aux_root, &w_aux_child,
- &x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
- (unsigned int*)&aux_long);
+ &x, &y, &u.pt_aux.x, &u.pt_aux.y, &aux_uint);
wine_tsx11_unlock();
/* find out drop point and drop window */
@@ -1246,7 +1260,16 @@
wine_tsx11_lock();
XQueryPointer( event->display, root_window, &root, &child,
&root_x, &root_y, &child_x, &child_y, &u);
- if (XFindContext( event->display, child, winContext, (char **)&hWnd ) != 0) hWnd = 0;
+ {
+ union {
+ char *ptr;
+ HWND hwnd;
+ } xhwnd;
+ if (XFindContext( event->display, child, winContext, &xhwnd.ptr ) != 1)
+ hWnd = 0;
+ else
+ hWnd = xhwnd.hwnd;
+ }
wine_tsx11_unlock();
if (!hWnd) return;
if (event->data.l[0] == DndFile || event->data.l[0] == DndFiles)
--
More information about the wine-patches
mailing list