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"
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

View File

@ -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};

View File

@ -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; i<cRects; i++) {
CONST RECT *r = &pSourceRectsArray[i];
CONST POINT *p = &pDestPointsArray[i];
void *from;
void *to;
char *from;
char *to;
int copyperline = (r->right - r->left) * bytesPerPixel;
int j;

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
/*

View File

@ -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) {

View File

@ -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;

View File

@ -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);
}

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)
{
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++;
}
}