From 809edabfbee88e11f44118508c5c1558a5d86c2b Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 27 Jun 2005 09:53:46 +0000 Subject: [PATCH] Const correctness fixes. --- dlls/d3d9/device.c | 8 ++++---- dlls/dbghelp/dwarf.c | 18 +++++++++--------- dlls/dmstyle/commandtrack.c | 2 +- dlls/iphlpapi/iphlpapi_main.c | 15 +++++++++------ dlls/ole32/stg_prop.c | 2 +- dlls/user/win.c | 4 ++-- dlls/winsock/socket.c | 10 +++++----- dlls/x11drv/dib.c | 20 ++++++++++---------- libs/unicode/cptable.c | 2 +- tools/wrc/parser.y | 2 +- 10 files changed, 43 insertions(+), 40 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 8a08a5d4de8..d95f42a4954 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -465,7 +465,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport); + return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport); } HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) { @@ -477,7 +477,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVI HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial); + return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial); } HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) { @@ -489,7 +489,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMA HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight); + return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight); } HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) { @@ -537,7 +537,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3 HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus); + return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus); } HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) { diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 180acb77d2d..f16dd63bc7f 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -480,21 +480,21 @@ typedef struct dwarf2_parse_context_s { static unsigned char dwarf2_parse_byte(dwarf2_parse_context_t* ctx) { - unsigned char uvalue = *(unsigned char*) ctx->data; + unsigned char uvalue = *(const unsigned char*) ctx->data; ctx->data += 1; return uvalue; } static unsigned short dwarf2_parse_u2(dwarf2_parse_context_t* ctx) { - unsigned short uvalue = *(unsigned short*) ctx->data; + unsigned short uvalue = *(const unsigned short*) ctx->data; ctx->data += 2; return uvalue; } static unsigned long dwarf2_parse_u4(dwarf2_parse_context_t* ctx) { - unsigned long uvalue = *(unsigned int*) ctx->data; + unsigned long uvalue = *(const unsigned int*) ctx->data; ctx->data += 4; return uvalue; } @@ -706,7 +706,7 @@ static unsigned long dwarf2_parse_attr_as_addr(dwarf2_abbrev_entry_attr_t* attr, unsigned long offset = 0; switch (ctx->word_size) { case 4: - offset = *(unsigned int*) ctx->data; + offset = *(const unsigned int*) ctx->data; break; case 8: default: @@ -1941,7 +1941,7 @@ static struct symt_function* dwarf2_parse_subprogram(struct module* module, dwar return func_type; } -static void dwarf2_parse_compiland_content(struct module* module, dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx, struct symt_compiland* compiland) +static void dwarf2_parse_compiland_content(struct module* module, const dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx, struct symt_compiland* compiland) { if (entry->have_child) { /** any interest to not have child ? */ ++ctx->level; @@ -2044,7 +2044,7 @@ static void dwarf2_parse_compiland_content(struct module* module, dwarf2_abbrev_ } } -static struct symt_compiland* dwarf2_parse_compiland(struct module* module, dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx) +static struct symt_compiland* dwarf2_parse_compiland(struct module* module, const dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx) { struct symt_compiland* compiland = NULL; const char* name = NULL; @@ -2086,13 +2086,13 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset, while (comp_unit_cursor < end_debug) { dwarf2_abbrev_table_t* abbrev_table; - dwarf2_comp_unit_stream_t* comp_unit_stream; + const dwarf2_comp_unit_stream_t* comp_unit_stream; dwarf2_comp_unit_t comp_unit; dwarf2_parse_context_t ctx; dwarf2_parse_context_t abbrev_ctx; struct symt_compiland* compiland = NULL; - comp_unit_stream = (dwarf2_comp_unit_stream_t*) comp_unit_cursor; + comp_unit_stream = (const dwarf2_comp_unit_stream_t*) comp_unit_cursor; comp_unit.length = *(unsigned long*) comp_unit_stream->length; comp_unit.version = *(unsigned short*) comp_unit_stream->version; @@ -2131,7 +2131,7 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset, ctx.abbrev_table = abbrev_table; while (ctx.data < ctx.end_data) { - dwarf2_abbrev_entry_t* entry = NULL; + const dwarf2_abbrev_entry_t* entry = NULL; unsigned long entry_code; unsigned long entry_ref = 0; diff --git a/dlls/dmstyle/commandtrack.c b/dlls/dmstyle/commandtrack.c index ee7bb958e01..dfaf0173ca8 100644 --- a/dlls/dmstyle/commandtrack.c +++ b/dlls/dmstyle/commandtrack.c @@ -287,7 +287,7 @@ HRESULT WINAPI IDirectMusicCommandTrack_IPersistStream_Load (LPPERSISTSTREAM ifa int r = 0; DMUS_PRIVATE_COMMAND *tmpEntry; struct list *listEntry; - TRACE("*** IDirectMusicCommandTrack (%p) ***\n", (LPDIRECTMUSICTRACK8)This->TrackVtbl); + TRACE("*** IDirectMusicCommandTrack (%p) ***\n", This->TrackVtbl); TRACE(" - Commands:\n"); LIST_FOR_EACH (listEntry, &This->Commands) { tmpEntry = LIST_ENTRY (listEntry, DMUS_PRIVATE_COMMAND, entry); diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 77475555e96..62fdbf902da 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -858,7 +858,7 @@ static int IfTableSorter(const void *a, const void *b) int ret; if (a && b) - ret = ((PMIB_IFROW)a)->dwIndex - ((PMIB_IFROW)b)->dwIndex; + ret = ((const MIB_IFROW*)a)->dwIndex - ((const MIB_IFROW*)b)->dwIndex; else ret = 0; return ret; @@ -1011,7 +1011,7 @@ static int IpAddrTableSorter(const void *a, const void *b) int ret; if (a && b) - ret = ((PMIB_IPADDRROW)a)->dwAddr - ((PMIB_IPADDRROW)b)->dwAddr; + ret = ((const MIB_IPADDRROW*)a)->dwAddr - ((const MIB_IPADDRROW*)b)->dwAddr; else ret = 0; return ret; @@ -1110,7 +1110,8 @@ static int IpForwardTableSorter(const void *a, const void *b) int ret; if (a && b) { - PMIB_IPFORWARDROW rowA = (PMIB_IPFORWARDROW)a, rowB = (PMIB_IPFORWARDROW)b; + const MIB_IPFORWARDROW* rowA = (const MIB_IPFORWARDROW*)a; + const MIB_IPFORWARDROW* rowB = (const MIB_IPFORWARDROW*)b; ret = rowA->dwForwardDest - rowB->dwForwardDest; if (ret == 0) { @@ -1227,7 +1228,7 @@ static int IpNetTableSorter(const void *a, const void *b) int ret; if (a && b) - ret = ((PMIB_IPNETROW)a)->dwAddr - ((PMIB_IPNETROW)b)->dwAddr; + ret = ((const MIB_IPNETROW*)a)->dwAddr - ((const MIB_IPNETROW*)b)->dwAddr; else ret = 0; return ret; @@ -1503,7 +1504,8 @@ static int TcpTableSorter(const void *a, const void *b) int ret; if (a && b) { - PMIB_TCPROW rowA = (PMIB_TCPROW)a, rowB = (PMIB_TCPROW)b; + const MIB_TCPROW* rowA = a; + const MIB_TCPROW* rowB = b; ret = rowA->dwLocalAddr - rowB->dwLocalAddr; if (ret == 0) { @@ -1614,7 +1616,8 @@ static int UdpTableSorter(const void *a, const void *b) int ret; if (a && b) { - PMIB_UDPROW rowA = (PMIB_UDPROW)a, rowB = (PMIB_UDPROW)b; + const MIB_UDPROW* rowA = (const MIB_UDPROW*)a; + const MIB_UDPROW* rowB = (const MIB_UDPROW*)b; ret = rowA->dwLocalAddr - rowB->dwLocalAddr; if (ret == 0) diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c index af25e31ea2a..aab99dde8a9 100644 --- a/dlls/ole32/stg_prop.c +++ b/dlls/ole32/stg_prop.c @@ -2310,7 +2310,7 @@ HRESULT WINAPI FmtIdToPropStgName(const FMTID *rfmtid, LPOLESTR str) } else { - if (++fmtptr < (BYTE *)rfmtid + sizeof(FMTID)) + if (++fmtptr < (const BYTE *)rfmtid + sizeof(FMTID)) i |= *fmtptr << bitsRemaining; *pstr++ = (WCHAR)(fmtMap[i & CHARMASK]); bitsRemaining += BITS_PER_BYTE - BITS_IN_CHARMASK; diff --git a/dlls/user/win.c b/dlls/user/win.c index 4e3f6c1a62e..c05f0656dcc 100644 --- a/dlls/user/win.c +++ b/dlls/user/win.c @@ -880,8 +880,8 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, BOOL unicode = (type == WIN_PROC_32W); TRACE("%s %s ex=%08lx style=%08lx %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n", - (type == WIN_PROC_32W) ? debugstr_w((LPWSTR)cs->lpszName) : debugstr_a(cs->lpszName), - (type == WIN_PROC_32W) ? debugstr_w((LPWSTR)cs->lpszClass) : debugstr_a(cs->lpszClass), + (type == WIN_PROC_32W) ? debugstr_w((LPCWSTR)cs->lpszName) : debugstr_a(cs->lpszName), + (type == WIN_PROC_32W) ? debugstr_w((LPCWSTR)cs->lpszClass) : debugstr_a(cs->lpszClass), cs->dwExStyle, cs->style, cs->x, cs->y, cs->cx, cs->cy, cs->hwndParent, cs->hMenu, cs->hInstance, cs->lpCreateParams ); diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index a89e62ebd86..6d9b7784189 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -160,9 +160,9 @@ inline static const char *debugstr_sockaddr( const struct WS_sockaddr *a ) { if (!a) return "(nil)"; return wine_dbg_sprintf("{ family %d, address %s, port %d }", - ((struct sockaddr_in *)a)->sin_family, - inet_ntoa(((struct sockaddr_in *)a)->sin_addr), - ntohs(((struct sockaddr_in *)a)->sin_port)); + ((const struct sockaddr_in *)a)->sin_family, + inet_ntoa(((const struct sockaddr_in *)a)->sin_addr), + ntohs(((const struct sockaddr_in *)a)->sin_port)); } /* HANDLE<->SOCKET conversion (SOCKET is UINT_PTR). */ @@ -783,7 +783,7 @@ static const struct sockaddr* ws_sockaddr_ws2u(const struct WS_sockaddr* wsaddr, #ifdef HAVE_IPX case WS_AF_IPX: { - struct WS_sockaddr_ipx* wsipx=(struct WS_sockaddr_ipx*)wsaddr; + const struct WS_sockaddr_ipx* wsipx=(const struct WS_sockaddr_ipx*)wsaddr; struct sockaddr_ipx* uipx; if (wsaddrlenbmciHeader.bcBitCount; + colors = 1 << ((const BITMAPCOREINFO*) info)->bmciHeader.bcBitCount; } else { @@ -418,22 +418,22 @@ static RGBQUAD *X11DRV_DIB_BuildColorTable( X11DRV_PDEVICE *physDev, WORD coloru /* Convert RGBTRIPLEs to RGBQUADs */ for (i=0; i < colors; i++) { - colorTable[i].rgbRed = ((BITMAPCOREINFO*) info)->bmciColors[i].rgbtRed; - colorTable[i].rgbGreen = ((BITMAPCOREINFO*) info)->bmciColors[i].rgbtGreen; - colorTable[i].rgbBlue = ((BITMAPCOREINFO*) info)->bmciColors[i].rgbtBlue; + colorTable[i].rgbRed = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtRed; + colorTable[i].rgbGreen = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtGreen; + colorTable[i].rgbBlue = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtBlue; colorTable[i].rgbReserved = 0; } } else { - memcpy(colorTable, (LPBYTE) info + (WORD) info->bmiHeader.biSize, colors * sizeof(RGBQUAD)); + memcpy(colorTable, (const BYTE*) info + (WORD) info->bmiHeader.biSize, colors * sizeof(RGBQUAD)); } } else { HPALETTE hpal = GetCurrentObject(physDev->hdc, OBJ_PAL); PALETTEENTRY * pal_ents; - WORD *index = (WORD*) ((LPBYTE) info + (WORD) info->bmiHeader.biSize); + const WORD *index = (const WORD*) ((const BYTE*) info + (WORD) info->bmiHeader.biSize); int logcolors, entry; logcolors = GetPaletteEntries( hpal, 0, 0, NULL ); @@ -3761,7 +3761,7 @@ INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest, INT yDest, DWO LONG width, height; BOOL top_down; POINT pt; - void* colorPtr; + const void* colorPtr; if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &descr.infoBpp, &descr.compression ) == -1) @@ -3817,7 +3817,7 @@ INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest, INT yDest, DWO XSetFunction(gdi_display, physDev->gc, X11DRV_XROPfunction[GetROP2(physDev->hdc) - 1]); wine_tsx11_unlock(); - colorPtr = (LPBYTE) info + (WORD) info->bmiHeader.biSize; + colorPtr = (const BYTE*) info + (WORD) info->bmiHeader.biSize; switch (descr.infoBpp) { @@ -3887,7 +3887,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, BITMAP bitmap; LONG height, tmpheight; INT result; - void* colorPtr; + const void* colorPtr; descr.physDev = physDev; @@ -3906,7 +3906,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, if (startscan + lines > height) lines = height - startscan; - colorPtr = (LPBYTE) info + (WORD) info->bmiHeader.biSize; + colorPtr = (const BYTE*) info + (WORD) info->bmiHeader.biSize; switch (descr.infoBpp) { diff --git a/libs/unicode/cptable.c b/libs/unicode/cptable.c index ce5d6cfb660..58574b23fc3 100644 --- a/libs/unicode/cptable.c +++ b/libs/unicode/cptable.c @@ -156,7 +156,7 @@ static const union cptable * const cptables[60] = static int cmp_codepage( const void *codepage, const void *entry ) { - return (unsigned int)codepage - (*(const union cptable **)entry)->info.codepage; + return (unsigned int)codepage - (*(const union cptable *const *)entry)->info.codepage; } diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 6add4b2159d..b444540215c 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -2562,7 +2562,7 @@ static stringtable_t *find_stringtable(lvc_t *lvc) } /* qsort sorting function for string table entries */ -#define STE(p) ((stt_entry_t *)(p)) +#define STE(p) ((const stt_entry_t *)(p)) static int sort_stt_entry(const void *e1, const void *e2) { return STE(e1)->id - STE(e2)->id;