From 03486498534b66c8bc7b4491e3c9b33ef17c2f7a Mon Sep 17 00:00:00 2001 From: Daniel Marmier Date: Mon, 6 Oct 2003 21:03:32 +0000 Subject: [PATCH] Fixed warnings with gcc option "-Wwrite-strings". --- dlls/ddraw/d3ddevice/mesa.c | 24 +++++++++++++++--------- dlls/ddraw/helper.c | 2 +- dlls/ddraw/main.c | 2 +- dlls/ntdll/tests/path.c | 6 ++++-- dlls/ntdll/tests/rtlstr.c | 4 ++-- dlls/ole32/compobj.c | 2 +- dlls/oleaut32/tests/vartest.c | 4 ++-- dlls/oleaut32/typelib.c | 4 ++-- dlls/oleaut32/variant.c | 8 ++++---- dlls/user/tests/sysparams.c | 4 ++-- dlls/winmm/lolvldrv.c | 2 +- dlls/winmm/mci.c | 2 +- windows/dialog.c | 5 +++-- windows/spy.c | 2 +- windows/sysparams.c | 6 +++--- windows/winpos.c | 2 +- 16 files changed, 44 insertions(+), 35 deletions(-) diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 9942700adca..6510d510ec3 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -393,20 +393,24 @@ HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD v if (version > 1) { /* It seems that enumerating the reference IID on Direct3D 1 games (AvP / Motoracer2) breaks them */ + char interface_name[] = "WINE Reference Direct3DX using OpenGL"; TRACE(" enumerating OpenGL D3DDevice interface using reference IID (IID %s).\n", debugstr_guid(&IID_IDirect3DRefDevice)); d1 = dref; d2 = dref; - ret_value = cb((LPIID) &IID_IDirect3DRefDevice, "WINE Reference Direct3DX using OpenGL", device_name, &d1, &d2, context); + ret_value = cb((LPIID) &IID_IDirect3DRefDevice, interface_name, device_name, &d1, &d2, context); + if (ret_value != D3DENUMRET_OK) + return ret_value; + } + + { + char interface_name[] = "WINE Direct3DX using OpenGL"; + TRACE(" enumerating OpenGL D3DDevice interface (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL)); + d1 = dref; + d2 = dref; + ret_value = cb((LPIID) &IID_D3DDEVICE_OpenGL, interface_name, device_name, &d1, &d2, context); if (ret_value != D3DENUMRET_OK) return ret_value; } - - TRACE(" enumerating OpenGL D3DDevice interface (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL)); - d1 = dref; - d2 = dref; - ret_value = cb((LPIID) &IID_D3DDEVICE_OpenGL, "WINE Direct3DX using OpenGL", device_name, &d1, &d2, context); - if (ret_value != D3DENUMRET_OK) - return ret_value; return D3DENUMRET_OK; } @@ -414,12 +418,14 @@ HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD v HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) { D3DDEVICEDESC7 ddesc; + char interface_name[] = "WINE Direct3D7 using OpenGL"; + char device_name[] = "Wine D3D7 device"; fill_opengl_caps_7(&ddesc); TRACE(" enumerating OpenGL D3DDevice7 interface.\n"); - return cb("WINE Direct3D7 using OpenGL", "Wine D3D7 device", &ddesc, context); + return cb(interface_name, device_name, &ddesc, context); } ULONG WINAPI diff --git a/dlls/ddraw/helper.c b/dlls/ddraw/helper.c index e20359e62c0..e748ab4847f 100644 --- a/dlls/ddraw/helper.c +++ b/dlls/ddraw/helper.c @@ -270,7 +270,7 @@ void DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf) { ); } if (pf->dwFlags & DDPF_RGB) { - char *cmd; + const char *cmd; DPRINTF(", RGB bits: %ld, ", pf->u1.dwRGBBitCount); switch (pf->u1.dwRGBBitCount) { case 4: cmd = "%1lx"; break; diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 7bdcb14f96e..eb1b6559f2f 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -85,7 +85,7 @@ static void *gl_handle = NULL; static BOOL DDRAW_bind_to_opengl( void ) { - char *glname = SONAME_LIBGL; + const char *glname = SONAME_LIBGL; BOOL ret_value; gl_handle = wine_dlopen(glname, RTLD_NOW, NULL, 0); diff --git a/dlls/ntdll/tests/path.c b/dlls/ntdll/tests/path.c index de913f07a5a..fec515e4a90 100644 --- a/dlls/ntdll/tests/path.c +++ b/dlls/ntdll/tests/path.c @@ -157,7 +157,7 @@ static void test_RtlIsNameLegalDOS8Dot3(void) { struct test { - char *path; + const char *path; BOOLEAN result; BOOLEAN spaces; }; @@ -199,7 +199,9 @@ static void test_RtlIsNameLegalDOS8Dot3(void) ustr.Buffer = buffer; for (test = tests; test->path; test++) { - oem.Buffer = test->path; + char path[100]; + strcpy(path, test->path); + oem.Buffer = path; oem.Length = strlen(test->path); oem.MaximumLength = oem.Length + 1; pRtlOemStringToUnicodeString( &ustr, &oem, FALSE ); diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c index 26f3117a5e8..cd2ec9c6a7a 100644 --- a/dlls/ntdll/tests/rtlstr.c +++ b/dlls/ntdll/tests/rtlstr.c @@ -41,7 +41,7 @@ static NTSTATUS (WINAPI *pRtlAppendAsciizToString)(STRING *, LPCSTR); static NTSTATUS (WINAPI *pRtlAppendStringToString)(STRING *, const STRING *); static NTSTATUS (WINAPI *pRtlAppendUnicodeStringToString)(UNICODE_STRING *, const UNICODE_STRING *); static NTSTATUS (WINAPI *pRtlAppendUnicodeToString)(UNICODE_STRING *, LPCWSTR); -static NTSTATUS (WINAPI *pRtlCharToInteger)(char *, ULONG, int *); +static NTSTATUS (WINAPI *pRtlCharToInteger)(PCSZ, ULONG, int *); static VOID (WINAPI *pRtlCopyString)(STRING *, const STRING *); static BOOLEAN (WINAPI *pRtlCreateUnicodeString)(PUNICODE_STRING, LPCWSTR); static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, LPCSTR); @@ -1211,7 +1211,7 @@ static void test_RtlFindCharInUnicodeString(void) typedef struct { int base; - char *str; + const char *str; int value; NTSTATUS result; } str2int_t; diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 3a36301a631..49af9790698 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -506,7 +506,7 @@ HRESULT WINAPI __CLSIDFromStringA( LPCSTR idstr, /* [in] string representation of guid */ CLSID *id) /* [out] GUID converted from string */ { - BYTE *s = (BYTE *) idstr; + const BYTE *s = (BYTE *) idstr; int i; BYTE table[256]; diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 2082256fb77..0269ae9b2ed 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -117,7 +117,7 @@ static char* WtoA( OLECHAR* p ) return buffer; } -static OLECHAR* AtoW( char* p ) +static OLECHAR* AtoW( const char* p ) { OLECHAR *buffer; DWORD len = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 ); @@ -381,7 +381,7 @@ static const char *strfromr8[] = { /* These are the strings we use for the XxxFromStr tests. * The arrays that follow define the expected results for each type. */ -static char* _pTestStrA[] = { +static const char* _pTestStrA[] = { "-2", "-1", "-0.51", diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index d43bd830ef3..63c1e3d9319 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -927,7 +927,7 @@ void dump_IDLDESC(IDLDESC *idl) { MESSAGE("\t\twIdlflags: %d\n",idl->wIDLFlags); } -static char * typekind_desc[] = +static const char * typekind_desc[] = { "TKIND_ENUM", "TKIND_RECORD", @@ -1924,7 +1924,7 @@ ITypeInfoImpl * MSFT_DoTypeInfo( } else { /* FIXME: This is a really bad hack to add IDispatch */ - char* szStdOle = "stdole2.tlb\0"; + const char* szStdOle = "stdole2.tlb\0"; int nStdOleLen = strlen(szStdOle); TLBRefType **ppRef = &ptiRet->reflist; diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index a636c8abba4..9f1375daa87 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -143,10 +143,10 @@ static const double DAYS_IN_ONE_YEAR = 365.0; #define TOK_AMPM 0x2e typedef struct tagFORMATTOKEN { - char *str; - BYTE tokenSize; - BYTE tokenId; - int varTypeRequired; + const char *str; + BYTE tokenSize; + BYTE tokenId; + int varTypeRequired; } FORMATTOKEN; typedef struct tagFORMATHDR { diff --git a/dlls/user/tests/sysparams.c b/dlls/user/tests/sysparams.c index f232e18b8c7..d68f57cb983 100644 --- a/dlls/user/tests/sysparams.c +++ b/dlls/user/tests/sysparams.c @@ -149,7 +149,7 @@ static void test_change_message( int action, int optional ) * lpsRegName - registry entry name * lpsTestValue - value to test */ -static void _test_reg_key( LPSTR subKey1, LPSTR subKey2, LPSTR valName, LPSTR testValue ) +static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName, LPCSTR testValue ) { CHAR value[MAX_PATH]; DWORD valueLen; @@ -256,7 +256,7 @@ static void test_SPI_SETBEEP( void ) /* 2 */ ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } -static char *setmouse_valuenames[3] = { +static const char *setmouse_valuenames[3] = { SPI_SETMOUSE_VALNAME1, SPI_SETMOUSE_VALNAME2, SPI_SETMOUSE_VALNAME3 diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c index ae02a73486b..30481d85e07 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -39,7 +39,7 @@ unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DRIVER) /* /* each known type of driver has an instance of this structure */ typedef struct tagWINE_LLTYPE { /* those attributes depend on the specification of the type */ - LPSTR typestr; /* name (for debugging) */ + LPCSTR typestr; /* name (for debugging) */ BOOL bSupportMapper; /* if type is allowed to support mapper */ MMDRV_MAPFUNC Map16To32A; /* those are function pointers to handle */ MMDRV_UNMAPFUNC UnMap16To32A; /* the parameter conversion (16 vs 32 bit) */ diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c index 0aa8104e81b..f3c5f180070 100644 --- a/dlls/winmm/mci.c +++ b/dlls/winmm/mci.c @@ -291,7 +291,7 @@ static UINT MCI_GetCommandTable(UINT uDevType) { UINT uTbl; char buf[32]; - LPSTR str = NULL; + LPCSTR str = NULL; /* first look up existing for existing devType */ for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) { diff --git a/windows/dialog.c b/windows/dialog.c index e0a1607fe1b..434644d44e3 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -155,7 +155,7 @@ BOOL DIALOG_DisableOwner( HWND hOwner ) BOOL DIALOG_GetCharSize( HDC hDC, HFONT hFont, SIZE * pSize ) { HFONT hFontPrev = 0; - char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; SIZE sz; TEXTMETRICA tm; @@ -1553,6 +1553,7 @@ static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, { HWND hwnd; LPSTR orig_spec = spec; + char any[] = "*.*"; #define SENDMSG(msg,wparam,lparam) \ ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \ @@ -1562,7 +1563,7 @@ static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib ); /* If the path exists and is a directory, chdir to it */ - if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*"; + if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = any; else { char *p, *p2; diff --git a/windows/spy.c b/windows/spy.c index 30f2cf83c27..7c5ae73c7d0 100644 --- a/windows/spy.c +++ b/windows/spy.c @@ -2045,7 +2045,7 @@ const SPY_NOTIFY *SPY_Bsearch_Notify( const SPY_NOTIFY *first, const SPY_NOTIFY /*********************************************************************** * SPY_DumpMem */ -void SPY_DumpMem (LPSTR header, UINT *q, INT len) +void SPY_DumpMem (LPCSTR header, UINT *q, INT len) { int i; diff --git a/windows/sysparams.c b/windows/sysparams.c index 4078be6e9b8..2c18f62d45b 100644 --- a/windows/sysparams.c +++ b/windows/sysparams.c @@ -373,7 +373,7 @@ void SYSPARAMS_NotifyChange( UINT uiAction, UINT fWinIni ) /*********************************************************************** * Loads system parameter from user profile. */ -BOOL SYSPARAMS_Load( LPSTR lpRegKey, LPSTR lpValName, LPSTR lpBuf, DWORD count ) +static BOOL SYSPARAMS_Load( LPCSTR lpRegKey, LPCSTR lpValName, LPSTR lpBuf, DWORD count ) { BOOL ret = FALSE; DWORD type; @@ -391,8 +391,8 @@ BOOL SYSPARAMS_Load( LPSTR lpRegKey, LPSTR lpValName, LPSTR lpBuf, DWORD count ) /*********************************************************************** * Saves system parameter to user profile. */ -BOOL SYSPARAMS_Save( LPSTR lpRegKey, LPSTR lpValName, LPSTR lpValue, - UINT fWinIni ) +static BOOL SYSPARAMS_Save( LPCSTR lpRegKey, LPCSTR lpValName, LPCSTR lpValue, + UINT fWinIni ) { HKEY hKey; HKEY hBaseKey; diff --git a/windows/winpos.c b/windows/winpos.c index 7e5ae7bb616..cadedf4ac74 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -79,7 +79,7 @@ static LPCSTR atomInternalPos; */ BOOL WINPOS_CreateInternalPosAtom() { - LPSTR str = "SysIP"; + LPCSTR str = "SysIP"; atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtomA(str); return (atomInternalPos) ? TRUE : FALSE; }