From f8aa3b506cf92b33dcac5452e9a8e5fc8b0b544f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 23 Jan 2003 21:32:35 +0000 Subject: [PATCH] Added -Wpointer-arith gcc flag, and fixed the resulting warnings. --- configure | 2 +- configure.ac | 2 +- dlls/d3d8/device.c | 26 ++++++++++++++------------ dlls/d3d8/indexbuffer.c | 2 +- dlls/d3d8/shader.c | 6 +++--- dlls/ddraw/d3dexecutebuffer.c | 10 +++++----- dlls/gdi/freetype.c | 8 ++++---- dlls/ntdll/cdrom.c | 2 +- dlls/oleaut32/safearray.c | 4 ++-- dlls/winedos/vga.c | 2 +- dlls/winmm/lolvldrv.c | 12 ++++++------ dlls/winmm/wineoss/audio.c | 2 +- dlls/x11drv/clipboard.c | 6 +++--- programs/winedbg/gdbproxy.c | 10 ++++++---- 14 files changed, 49 insertions(+), 45 deletions(-) diff --git a/configure b/configure index 36798bc171e..c2b9fd4aba2 100755 --- a/configure +++ b/configure @@ -10668,7 +10668,7 @@ fi if test "x${GCC}" = "xyes" then - CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wall -Wpointer-arith" echo "$as_me:$LINENO: checking for gcc strength-reduce bug" >&5 echo $ECHO_N "checking for gcc strength-reduce bug... $ECHO_C" >&6 if test "${ac_cv_c_gcc_strength_bug+set}" = set; then diff --git a/configure.ac b/configure.ac index 30b170002fe..f2d1b836502 100644 --- a/configure.ac +++ b/configure.ac @@ -638,7 +638,7 @@ dnl **** Check for gcc strength-reduce bug **** if test "x${GCC}" = "xyes" then - CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wall -Wpointer-arith" AC_CACHE_CHECK( [for gcc strength-reduce bug], ac_cv_c_gcc_strength_bug, AC_TRY_RUN([ int L[[4]] = {0,1,2,3}; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e7c70d019b7..14f8d490958 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -143,10 +143,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface, BOOL isLastUByte4; int numTextures; int textureNo; - const void *curVtx = NULL; + const char *curVtx = NULL; const short *pIdxBufS = NULL; const long *pIdxBufL = NULL; - const void *curPos; + const char *curPos; BOOL isLightingOn = FALSE; BOOL enableTexture = FALSE; int vx_index; @@ -286,7 +286,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface, glBegin(primType); /* Draw the primitives */ - curVtx = vertexBufData + (StartVertexIndex * skip); + curVtx = (const char *)vertexBufData + (StartVertexIndex * skip); for (vx_index = 0; vx_index < NumVertexes; vx_index++) { @@ -580,7 +580,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface, /* Faster version, harder to debug */ /* Shuffle to the beginning of the vertexes to render and index from there */ - curVtx = vertexBufData + (StartVertexIndex * skip); + curVtx = (const char *)vertexBufData + (StartVertexIndex * skip); curPos = curVtx; /* Set up the vertex pointers */ @@ -727,17 +727,19 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface, TRACE("glElements(%x, %d, %d, ...)\n", primType, NumVertexes, minIndex); if (idxBytes==2) { #if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */ - glDrawElements(primType, NumVertexes, GL_UNSIGNED_SHORT, idxData+(2 * StartIdx)); + glDrawElements(primType, NumVertexes, GL_UNSIGNED_SHORT, + (char *)idxData+(2 * StartIdx)); #else glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes, - GL_UNSIGNED_SHORT, idxData+(2 * StartIdx)); + GL_UNSIGNED_SHORT, (char *)idxData+(2 * StartIdx)); #endif } else { #if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */ - glDrawElements(primType, NumVertexes, GL_UNSIGNED_INT, idxData+(4 * StartIdx)); + glDrawElements(primType, NumVertexes, GL_UNSIGNED_INT, + (char *)idxData+(4 * StartIdx)); #else glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes, - GL_UNSIGNED_INT, idxData+(2 * StartIdx)); + GL_UNSIGNED_INT, (char *)idxData+(2 * StartIdx)); #endif } checkGLcall("glDrawRangeElements"); @@ -1436,15 +1438,15 @@ HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect int pitchFrom = ((IDirect3DSurface8Impl *)pSourceSurface)->myDesc.Width * bytesPerPixel; int pitchTo = ((IDirect3DSurface8Impl *)pDestinationSurface)->myDesc.Width * bytesPerPixel; - void *copyfrom = ((IDirect3DSurface8Impl *)pSourceSurface)->allocatedMemory; - void *copyto = ((IDirect3DSurface8Impl *)pDestinationSurface)->allocatedMemory; + char *copyfrom = ((IDirect3DSurface8Impl *)pSourceSurface)->allocatedMemory; + char *copyto = ((IDirect3DSurface8Impl *)pDestinationSurface)->allocatedMemory; /* Copy rect by rect */ for (i=0; iright - r->left) * bytesPerPixel; int j; diff --git a/dlls/d3d8/indexbuffer.c b/dlls/d3d8/indexbuffer.c index 7a0244b79fc..cba7ae7f9e5 100644 --- a/dlls/d3d8/indexbuffer.c +++ b/dlls/d3d8/indexbuffer.c @@ -107,7 +107,7 @@ HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 ifa } else { FIXME("(%p) : stub, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags); } - *ppbData = This->allocatedMemory + OffsetToLock; + *ppbData = (BYTE *)This->allocatedMemory + OffsetToLock; return D3D_OK; } diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c index f62b4c7e1df..36fe0839c29 100644 --- a/dlls/d3d8/shader.c +++ b/dlls/d3d8/shader.c @@ -957,7 +957,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader, /*DWORD tokenlen;*/ DWORD tokentype; /** for input readers */ - const void* curPos = NULL; + const char* curPos = NULL; FLOAT x, y, z, w; SHORT u, v, r, t; DWORD dw; @@ -970,7 +970,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader, /** FVF generation block */ if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { IDirect3DVertexBuffer8* pVB; - const void* startVtx = NULL; + const char* startVtx = NULL; int skip = 0; ++pToken; @@ -982,7 +982,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader, if (0 == stream) { skip = device->StateBlock.stream_stride[0]; - startVtx = vertexFirstStream + (StartVertexIndex * skip); + startVtx = (const char *)vertexFirstStream + (StartVertexIndex * skip); curPos = startVtx + idxDecal; /*TRACE(" using stream[%lu] with %lu decal => curPos %p\n", stream, idxDecal, curPos);*/ } else { diff --git a/dlls/ddraw/d3dexecutebuffer.c b/dlls/ddraw/d3dexecutebuffer.c index 656857a39f2..53ff2f27fac 100644 --- a/dlls/ddraw/d3dexecutebuffer.c +++ b/dlls/ddraw/d3dexecutebuffer.c @@ -192,8 +192,8 @@ static void execute(IDirect3DExecuteBufferImpl *This, /* DWORD vc = This->data.dwVertexCount; */ DWORD is = This->data.dwInstructionOffset; /* DWORD il = This->data.dwInstructionLength; */ - - void *instr = This->desc.lpData + is; + + char *instr = (char *)This->desc.lpData + is; /* Should check if the viewport was added or not to the device */ @@ -504,7 +504,7 @@ static void execute(IDirect3DExecuteBufferImpl *This, /* Enough for the moment */ if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) { int nb; - D3DVERTEX *src = ((LPD3DVERTEX) (This->desc.lpData + vs)) + ci->wStart; + D3DVERTEX *src = ((LPD3DVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart; OGL_Vertex *dst = ((OGL_Vertex *) (This->vertex_data)) + ci->wDest; D3DMATRIX *mat = lpDevice->world_mat; @@ -533,7 +533,7 @@ static void execute(IDirect3DExecuteBufferImpl *This, } } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) { int nb; - D3DLVERTEX *src = ((LPD3DLVERTEX) (This->desc.lpData + vs)) + ci->wStart; + D3DLVERTEX *src = ((LPD3DLVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart; OGL_LVertex *dst = ((OGL_LVertex *) (This->vertex_data)) + ci->wDest; D3DMATRIX *mat = lpDevice->world_mat; @@ -558,7 +558,7 @@ static void execute(IDirect3DExecuteBufferImpl *This, dst++; } } else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) { - D3DTLVERTEX *src = ((LPD3DTLVERTEX) (This->desc.lpData + vs)) + ci->wStart; + D3DTLVERTEX *src = ((LPD3DTLVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart; D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest; This->vertex_type = D3DVT_TLVERTEX; diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index 65e7cc9952f..6865b1d0cc2 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -1597,7 +1597,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format, for(contour = 0; contour < outline->n_contours; contour++) { pph_start = needed; - pph = buf + needed; + pph = (TTPOLYGONHEADER *)((char *)buf + needed); first_pt = point; if(buf) { pph->dwType = TT_POLYGON_TYPE; @@ -1606,7 +1606,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format, needed += sizeof(*pph); point++; while(point <= outline->contours[contour]) { - ppc = buf + needed; + ppc = (TTPOLYCURVE *)((char *)buf + needed); type = (outline->tags[point] & FT_Curve_Tag_On) ? TT_PRIM_LINE : TT_PRIM_QSPLINE; cpfx = 0; @@ -1673,7 +1673,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format, for(contour = 0; contour < outline->n_contours; contour++) { pph_start = needed; - pph = buf + needed; + pph = (TTPOLYGONHEADER *)((char *)buf + needed); first_pt = point; if(buf) { pph->dwType = TT_POLYGON_TYPE; @@ -1682,7 +1682,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format, needed += sizeof(*pph); point++; while(point <= outline->contours[contour]) { - ppc = buf + needed; + ppc = (TTPOLYCURVE *)((char *)buf + needed); type = (outline->tags[point] & FT_Curve_Tag_On) ? TT_PRIM_LINE : TT_PRIM_CSPLINE; cpfx = 0; diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c index 3b73a6d5027..aad20d6dc7f 100644 --- a/dlls/ntdll/cdrom.c +++ b/dlls/ntdll/cdrom.c @@ -1172,7 +1172,7 @@ static DWORD CDROM_ScsiPassThrough(int dev, PSCSI_PASS_THROUGH pPacket) } else { - cmd.buffer = ((void*)pPacket) + pPacket->DataBufferOffset; + cmd.buffer = (char*)pPacket + pPacket->DataBufferOffset; } cmd.buflen = pPacket->DataTransferLength; cmd.sense = &sense; diff --git a/dlls/oleaut32/safearray.c b/dlls/oleaut32/safearray.c index 5805de9da80..ef4e035ed08 100644 --- a/dlls/oleaut32/safearray.c +++ b/dlls/oleaut32/safearray.c @@ -165,7 +165,7 @@ HRESULT WINAPI SafeArrayAllocDescriptor( { SAFEARRAYBOUND *sab; LONG allocSize = 0; - LPVOID ptr; + char *ptr; if (!cDims || cDims >= 0x10000) /* 65536 appears to be the limit */ return E_INVALIDARG; @@ -181,7 +181,7 @@ HRESULT WINAPI SafeArrayAllocDescriptor( ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize); if (!ptr) return E_OUTOFMEMORY; - *ppsaOut = ptr+sizeof(GUID); + *ppsaOut = (SAFEARRAY *)(ptr + sizeof(GUID)); (*ppsaOut)->cDims = cDims; TRACE("(%d): %lu bytes allocated for descriptor.\n", cDims, allocSize); diff --git a/dlls/winedos/vga.c b/dlls/winedos/vga.c index 42fe308ee9d..c655bfed26c 100644 --- a/dlls/winedos/vga.c +++ b/dlls/winedos/vga.c @@ -76,7 +76,7 @@ static int vga_fb_depth; static int vga_fb_pitch; static int vga_fb_offset; static int vga_fb_size = 0; -static void *vga_fb_data = 0; +static char *vga_fb_data = 0; static int vga_fb_window = 0; /* diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c index 333e9d1c925..05e7f0164c6 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -290,21 +290,21 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) { LPWINE_MLD mld; + UINT i; mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (!mld) return NULL; /* find an empty slot in MM_MLDrvs table */ - for (*hndl = 0; (DWORD)*hndl < MAX_MM_MLDRVS; (*hndl)++) { - if (!MM_MLDrvs[(UINT)*hndl]) break; - } - if ((DWORD)*hndl == MAX_MM_MLDRVS) { + for (i = 0; i < MAX_MM_MLDRVS; i++) if (!MM_MLDrvs[i]) break; + + if (i == MAX_MM_MLDRVS) { /* the MM_MLDrvs table could be made growable in the future if needed */ ERR("Too many open drivers\n"); return NULL; } - MM_MLDrvs[(UINT)*hndl] = mld; - *hndl = (HANDLE)((UINT)*hndl | 0x8000); + MM_MLDrvs[i] = mld; + *hndl = (HANDLE)(i | 0x8000); mld->type = type; if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { diff --git a/dlls/winmm/wineoss/audio.c b/dlls/winmm/wineoss/audio.c index 675101d5e20..ab24acfdd1d 100644 --- a/dlls/winmm/wineoss/audio.c +++ b/dlls/winmm/wineoss/audio.c @@ -2257,7 +2257,7 @@ static DWORD CALLBACK widRecorder(LPVOID pmt) DWORD dwSleepTime; DWORD bytesRead; LPVOID buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, wwi->dwFragmentSize); - LPVOID pOffset = buffer; + char *pOffset = buffer; audio_buf_info info; int xs; enum win_wm_message msg; diff --git a/dlls/x11drv/clipboard.c b/dlls/x11drv/clipboard.c index f92397c5159..eea0cde4d1e 100644 --- a/dlls/x11drv/clipboard.c +++ b/dlls/x11drv/clipboard.c @@ -1363,10 +1363,10 @@ HANDLE X11DRV_CLIPBOARD_SerializeMetafile(INT wformat, HANDLE hdata, INT cbytes, h = GlobalAlloc(0, size + sizeof(METAFILEPICT)); if (h) { - LPVOID pdata = GlobalLock(h); + METAFILEPICT *pdata = GlobalLock(h); memcpy(pdata, lpmfp, sizeof(METAFILEPICT)); - GetMetaFileBitsEx(lpmfp->hMF, size, pdata + sizeof(METAFILEPICT)); + GetMetaFileBitsEx(lpmfp->hMF, size, pdata + 1); GlobalUnlock(h); } @@ -1397,7 +1397,7 @@ HANDLE X11DRV_CLIPBOARD_SerializeMetafile(INT wformat, HANDLE hdata, INT cbytes, memcpy(pmfp, (LPVOID)hdata, sizeof(METAFILEPICT)); pmfp->hMF = SetMetaFileBitsEx(cbytes - sizeof(METAFILEPICT), - (LPVOID)hdata + sizeof(METAFILEPICT)); + (char *)hdata + sizeof(METAFILEPICT)); GlobalUnlock(h); } diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 4fed9372606..8609680d730 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -122,20 +122,22 @@ static inline unsigned char hex_to0(int x) static void hex_from(void* dst, const char* src, size_t len) { + unsigned char *p = dst; while (len--) { - *(unsigned char*)dst++ = (hex_from0(src[0]) << 4) | hex_from0(src[1]); + *p++ = (hex_from0(src[0]) << 4) | hex_from0(src[1]); src += 2; } } static void hex_to(char* dst, const void* src, size_t len) { + const unsigned char *p = src; while (len--) { - *dst++ = hex_to0(*(const unsigned char*)src >> 4); - *dst++ = hex_to0(*(const unsigned char*)src & 0x0F); - src++; + *dst++ = hex_to0(*p >> 4); + *dst++ = hex_to0(*p & 0x0F); + p++; } }