Added -Wpointer-arith gcc flag, and fixed the resulting warnings.

This commit is contained in:
Alexandre Julliard 2003-01-23 21:32:35 +00:00
parent 92cc5868ae
commit f8aa3b506c
14 changed files with 49 additions and 45 deletions

2
configure vendored
View file

@ -10668,7 +10668,7 @@ fi
if test "x${GCC}" = "xyes" if test "x${GCC}" = "xyes"
then then
CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wall -Wpointer-arith"
echo "$as_me:$LINENO: checking for gcc strength-reduce bug" >&5 echo "$as_me:$LINENO: checking for gcc strength-reduce bug" >&5
echo $ECHO_N "checking for gcc strength-reduce bug... $ECHO_C" >&6 echo $ECHO_N "checking for gcc strength-reduce bug... $ECHO_C" >&6
if test "${ac_cv_c_gcc_strength_bug+set}" = set; then if test "${ac_cv_c_gcc_strength_bug+set}" = set; then

View file

@ -638,7 +638,7 @@ dnl **** Check for gcc strength-reduce bug ****
if test "x${GCC}" = "xyes" if test "x${GCC}" = "xyes"
then then
CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wall -Wpointer-arith"
AC_CACHE_CHECK( [for gcc strength-reduce bug], ac_cv_c_gcc_strength_bug, AC_CACHE_CHECK( [for gcc strength-reduce bug], ac_cv_c_gcc_strength_bug,
AC_TRY_RUN([ AC_TRY_RUN([
int L[[4]] = {0,1,2,3}; int L[[4]] = {0,1,2,3};

View file

@ -143,10 +143,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
BOOL isLastUByte4; BOOL isLastUByte4;
int numTextures; int numTextures;
int textureNo; int textureNo;
const void *curVtx = NULL; const char *curVtx = NULL;
const short *pIdxBufS = NULL; const short *pIdxBufS = NULL;
const long *pIdxBufL = NULL; const long *pIdxBufL = NULL;
const void *curPos; const char *curPos;
BOOL isLightingOn = FALSE; BOOL isLightingOn = FALSE;
BOOL enableTexture = FALSE; BOOL enableTexture = FALSE;
int vx_index; int vx_index;
@ -286,7 +286,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
glBegin(primType); glBegin(primType);
/* Draw the primitives */ /* Draw the primitives */
curVtx = vertexBufData + (StartVertexIndex * skip); curVtx = (const char *)vertexBufData + (StartVertexIndex * skip);
for (vx_index = 0; vx_index < NumVertexes; vx_index++) { for (vx_index = 0; vx_index < NumVertexes; vx_index++) {
@ -580,7 +580,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
/* Faster version, harder to debug */ /* Faster version, harder to debug */
/* Shuffle to the beginning of the vertexes to render and index from there */ /* 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; curPos = curVtx;
/* Set up the vertex pointers */ /* Set up the vertex pointers */
@ -727,17 +727,19 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
TRACE("glElements(%x, %d, %d, ...)\n", primType, NumVertexes, minIndex); TRACE("glElements(%x, %d, %d, ...)\n", primType, NumVertexes, minIndex);
if (idxBytes==2) { if (idxBytes==2) {
#if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */ #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 #else
glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes, glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes,
GL_UNSIGNED_SHORT, idxData+(2 * StartIdx)); GL_UNSIGNED_SHORT, (char *)idxData+(2 * StartIdx));
#endif #endif
} else { } else {
#if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */ #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 #else
glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes, glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes,
GL_UNSIGNED_INT, idxData+(2 * StartIdx)); GL_UNSIGNED_INT, (char *)idxData+(2 * StartIdx));
#endif #endif
} }
checkGLcall("glDrawRangeElements"); checkGLcall("glDrawRangeElements");
@ -1436,15 +1438,15 @@ HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect
int pitchFrom = ((IDirect3DSurface8Impl *)pSourceSurface)->myDesc.Width * bytesPerPixel; int pitchFrom = ((IDirect3DSurface8Impl *)pSourceSurface)->myDesc.Width * bytesPerPixel;
int pitchTo = ((IDirect3DSurface8Impl *)pDestinationSurface)->myDesc.Width * bytesPerPixel; int pitchTo = ((IDirect3DSurface8Impl *)pDestinationSurface)->myDesc.Width * bytesPerPixel;
void *copyfrom = ((IDirect3DSurface8Impl *)pSourceSurface)->allocatedMemory; char *copyfrom = ((IDirect3DSurface8Impl *)pSourceSurface)->allocatedMemory;
void *copyto = ((IDirect3DSurface8Impl *)pDestinationSurface)->allocatedMemory; char *copyto = ((IDirect3DSurface8Impl *)pDestinationSurface)->allocatedMemory;
/* Copy rect by rect */ /* Copy rect by rect */
for (i=0; i<cRects; i++) { for (i=0; i<cRects; i++) {
CONST RECT *r = &pSourceRectsArray[i]; CONST RECT *r = &pSourceRectsArray[i];
CONST POINT *p = &pDestPointsArray[i]; CONST POINT *p = &pDestPointsArray[i];
void *from; char *from;
void *to; char *to;
int copyperline = (r->right - r->left) * bytesPerPixel; int copyperline = (r->right - r->left) * bytesPerPixel;
int j; int j;

View file

@ -107,7 +107,7 @@ HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 ifa
} else { } else {
FIXME("(%p) : stub, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags); 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; return D3D_OK;
} }

View file

@ -957,7 +957,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader,
/*DWORD tokenlen;*/ /*DWORD tokenlen;*/
DWORD tokentype; DWORD tokentype;
/** for input readers */ /** for input readers */
const void* curPos = NULL; const char* curPos = NULL;
FLOAT x, y, z, w; FLOAT x, y, z, w;
SHORT u, v, r, t; SHORT u, v, r, t;
DWORD dw; DWORD dw;
@ -970,7 +970,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader,
/** FVF generation block */ /** FVF generation block */
if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) {
IDirect3DVertexBuffer8* pVB; IDirect3DVertexBuffer8* pVB;
const void* startVtx = NULL; const char* startVtx = NULL;
int skip = 0; int skip = 0;
++pToken; ++pToken;
@ -982,7 +982,7 @@ void vshader_fill_input(VERTEXSHADER8* vshader,
if (0 == stream) { if (0 == stream) {
skip = device->StateBlock.stream_stride[0]; skip = device->StateBlock.stream_stride[0];
startVtx = vertexFirstStream + (StartVertexIndex * skip); startVtx = (const char *)vertexFirstStream + (StartVertexIndex * skip);
curPos = startVtx + idxDecal; curPos = startVtx + idxDecal;
/*TRACE(" using stream[%lu] with %lu decal => curPos %p\n", stream, idxDecal, curPos);*/ /*TRACE(" using stream[%lu] with %lu decal => curPos %p\n", stream, idxDecal, curPos);*/
} else { } else {

View file

@ -192,8 +192,8 @@ static void execute(IDirect3DExecuteBufferImpl *This,
/* DWORD vc = This->data.dwVertexCount; */ /* DWORD vc = This->data.dwVertexCount; */
DWORD is = This->data.dwInstructionOffset; DWORD is = This->data.dwInstructionOffset;
/* DWORD il = This->data.dwInstructionLength; */ /* 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 */ /* 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 */ /* Enough for the moment */
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) { if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
int nb; 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; OGL_Vertex *dst = ((OGL_Vertex *) (This->vertex_data)) + ci->wDest;
D3DMATRIX *mat = lpDevice->world_mat; D3DMATRIX *mat = lpDevice->world_mat;
@ -533,7 +533,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
} }
} else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) { } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
int nb; 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; OGL_LVertex *dst = ((OGL_LVertex *) (This->vertex_data)) + ci->wDest;
D3DMATRIX *mat = lpDevice->world_mat; D3DMATRIX *mat = lpDevice->world_mat;
@ -558,7 +558,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
dst++; dst++;
} }
} else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) { } 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; D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
This->vertex_type = D3DVT_TLVERTEX; This->vertex_type = D3DVT_TLVERTEX;

View file

@ -1597,7 +1597,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
for(contour = 0; contour < outline->n_contours; contour++) { for(contour = 0; contour < outline->n_contours; contour++) {
pph_start = needed; pph_start = needed;
pph = buf + needed; pph = (TTPOLYGONHEADER *)((char *)buf + needed);
first_pt = point; first_pt = point;
if(buf) { if(buf) {
pph->dwType = TT_POLYGON_TYPE; pph->dwType = TT_POLYGON_TYPE;
@ -1606,7 +1606,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
needed += sizeof(*pph); needed += sizeof(*pph);
point++; point++;
while(point <= outline->contours[contour]) { while(point <= outline->contours[contour]) {
ppc = buf + needed; ppc = (TTPOLYCURVE *)((char *)buf + needed);
type = (outline->tags[point] & FT_Curve_Tag_On) ? type = (outline->tags[point] & FT_Curve_Tag_On) ?
TT_PRIM_LINE : TT_PRIM_QSPLINE; TT_PRIM_LINE : TT_PRIM_QSPLINE;
cpfx = 0; cpfx = 0;
@ -1673,7 +1673,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
for(contour = 0; contour < outline->n_contours; contour++) { for(contour = 0; contour < outline->n_contours; contour++) {
pph_start = needed; pph_start = needed;
pph = buf + needed; pph = (TTPOLYGONHEADER *)((char *)buf + needed);
first_pt = point; first_pt = point;
if(buf) { if(buf) {
pph->dwType = TT_POLYGON_TYPE; pph->dwType = TT_POLYGON_TYPE;
@ -1682,7 +1682,7 @@ DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
needed += sizeof(*pph); needed += sizeof(*pph);
point++; point++;
while(point <= outline->contours[contour]) { while(point <= outline->contours[contour]) {
ppc = buf + needed; ppc = (TTPOLYCURVE *)((char *)buf + needed);
type = (outline->tags[point] & FT_Curve_Tag_On) ? type = (outline->tags[point] & FT_Curve_Tag_On) ?
TT_PRIM_LINE : TT_PRIM_CSPLINE; TT_PRIM_LINE : TT_PRIM_CSPLINE;
cpfx = 0; cpfx = 0;

View file

@ -1172,7 +1172,7 @@ static DWORD CDROM_ScsiPassThrough(int dev, PSCSI_PASS_THROUGH pPacket)
} }
else else
{ {
cmd.buffer = ((void*)pPacket) + pPacket->DataBufferOffset; cmd.buffer = (char*)pPacket + pPacket->DataBufferOffset;
} }
cmd.buflen = pPacket->DataTransferLength; cmd.buflen = pPacket->DataTransferLength;
cmd.sense = &sense; cmd.sense = &sense;

View file

@ -165,7 +165,7 @@ HRESULT WINAPI SafeArrayAllocDescriptor(
{ {
SAFEARRAYBOUND *sab; SAFEARRAYBOUND *sab;
LONG allocSize = 0; LONG allocSize = 0;
LPVOID ptr; char *ptr;
if (!cDims || cDims >= 0x10000) /* 65536 appears to be the limit */ if (!cDims || cDims >= 0x10000) /* 65536 appears to be the limit */
return E_INVALIDARG; return E_INVALIDARG;
@ -181,7 +181,7 @@ HRESULT WINAPI SafeArrayAllocDescriptor(
ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize); ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize);
if (!ptr) if (!ptr)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*ppsaOut = ptr+sizeof(GUID); *ppsaOut = (SAFEARRAY *)(ptr + sizeof(GUID));
(*ppsaOut)->cDims = cDims; (*ppsaOut)->cDims = cDims;
TRACE("(%d): %lu bytes allocated for descriptor.\n", cDims, allocSize); TRACE("(%d): %lu bytes allocated for descriptor.\n", cDims, allocSize);

View file

@ -76,7 +76,7 @@ static int vga_fb_depth;
static int vga_fb_pitch; static int vga_fb_pitch;
static int vga_fb_offset; static int vga_fb_offset;
static int vga_fb_size = 0; static int vga_fb_size = 0;
static void *vga_fb_data = 0; static char *vga_fb_data = 0;
static int vga_fb_window = 0; static int vga_fb_window = 0;
/* /*

View file

@ -290,21 +290,21 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32)
{ {
LPWINE_MLD mld; LPWINE_MLD mld;
UINT i;
mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (!mld) return NULL; if (!mld) return NULL;
/* find an empty slot in MM_MLDrvs table */ /* find an empty slot in MM_MLDrvs table */
for (*hndl = 0; (DWORD)*hndl < MAX_MM_MLDRVS; (*hndl)++) { for (i = 0; i < MAX_MM_MLDRVS; i++) if (!MM_MLDrvs[i]) break;
if (!MM_MLDrvs[(UINT)*hndl]) break;
} if (i == MAX_MM_MLDRVS) {
if ((DWORD)*hndl == MAX_MM_MLDRVS) {
/* the MM_MLDrvs table could be made growable in the future if needed */ /* the MM_MLDrvs table could be made growable in the future if needed */
ERR("Too many open drivers\n"); ERR("Too many open drivers\n");
return NULL; return NULL;
} }
MM_MLDrvs[(UINT)*hndl] = mld; MM_MLDrvs[i] = mld;
*hndl = (HANDLE)((UINT)*hndl | 0x8000); *hndl = (HANDLE)(i | 0x8000);
mld->type = type; mld->type = type;
if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) {

View file

@ -2257,7 +2257,7 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
DWORD dwSleepTime; DWORD dwSleepTime;
DWORD bytesRead; DWORD bytesRead;
LPVOID buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, wwi->dwFragmentSize); LPVOID buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, wwi->dwFragmentSize);
LPVOID pOffset = buffer; char *pOffset = buffer;
audio_buf_info info; audio_buf_info info;
int xs; int xs;
enum win_wm_message msg; enum win_wm_message msg;

View file

@ -1363,10 +1363,10 @@ HANDLE X11DRV_CLIPBOARD_SerializeMetafile(INT wformat, HANDLE hdata, INT cbytes,
h = GlobalAlloc(0, size + sizeof(METAFILEPICT)); h = GlobalAlloc(0, size + sizeof(METAFILEPICT));
if (h) if (h)
{ {
LPVOID pdata = GlobalLock(h); METAFILEPICT *pdata = GlobalLock(h);
memcpy(pdata, lpmfp, sizeof(METAFILEPICT)); memcpy(pdata, lpmfp, sizeof(METAFILEPICT));
GetMetaFileBitsEx(lpmfp->hMF, size, pdata + sizeof(METAFILEPICT)); GetMetaFileBitsEx(lpmfp->hMF, size, pdata + 1);
GlobalUnlock(h); GlobalUnlock(h);
} }
@ -1397,7 +1397,7 @@ HANDLE X11DRV_CLIPBOARD_SerializeMetafile(INT wformat, HANDLE hdata, INT cbytes,
memcpy(pmfp, (LPVOID)hdata, sizeof(METAFILEPICT)); memcpy(pmfp, (LPVOID)hdata, sizeof(METAFILEPICT));
pmfp->hMF = SetMetaFileBitsEx(cbytes - sizeof(METAFILEPICT), pmfp->hMF = SetMetaFileBitsEx(cbytes - sizeof(METAFILEPICT),
(LPVOID)hdata + sizeof(METAFILEPICT)); (char *)hdata + sizeof(METAFILEPICT));
GlobalUnlock(h); GlobalUnlock(h);
} }

View file

@ -122,20 +122,22 @@ static inline unsigned char hex_to0(int x)
static void hex_from(void* dst, const char* src, size_t len) static void hex_from(void* dst, const char* src, size_t len)
{ {
unsigned char *p = dst;
while (len--) 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; src += 2;
} }
} }
static void hex_to(char* dst, const void* src, size_t len) static void hex_to(char* dst, const void* src, size_t len)
{ {
const unsigned char *p = src;
while (len--) while (len--)
{ {
*dst++ = hex_to0(*(const unsigned char*)src >> 4); *dst++ = hex_to0(*p >> 4);
*dst++ = hex_to0(*(const unsigned char*)src & 0x0F); *dst++ = hex_to0(*p & 0x0F);
src++; p++;
} }
} }