From 62a860988c50b2311c385449e2a33b16a12656ae Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 14 Jun 2004 17:04:34 +0000 Subject: [PATCH] Const correctness, pointer cast correctness, removed extraneous ';'. --- dlls/kernel/console.c | 4 ++-- dlls/kernel/dosmem.c | 4 ++-- dlls/kernel/format_msg.c | 10 +++++----- dlls/kernel/heap.c | 2 +- dlls/kernel/instr.c | 2 +- dlls/kernel/locale.c | 5 +++-- dlls/kernel/profile.c | 15 +++++++++------ dlls/kernel/selector.c | 8 ++++---- dlls/kernel/thread.c | 8 ++++---- misc/registry.c | 4 ++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/dlls/kernel/console.c b/dlls/kernel/console.c index 3be2025a03a..96f9b19b5d5 100644 --- a/dlls/kernel/console.c +++ b/dlls/kernel/console.c @@ -1827,7 +1827,7 @@ static int next_line(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi) * */ static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi, - DWORD mode, LPWSTR ptr, int len) + DWORD mode, LPCWSTR ptr, int len) { int blk; /* number of chars to write on current line */ int done; /* number of chars already written */ @@ -1875,7 +1875,7 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber { DWORD mode; DWORD nw = 0; - WCHAR* psz = (WCHAR*)lpBuffer; + const WCHAR* psz = lpBuffer; CONSOLE_SCREEN_BUFFER_INFO csbi; int k, first = 0; diff --git a/dlls/kernel/dosmem.c b/dlls/kernel/dosmem.c index 10f88614b23..9023961c531 100644 --- a/dlls/kernel/dosmem.c +++ b/dlls/kernel/dosmem.c @@ -215,7 +215,7 @@ static DWORD DOSMEM_GetTicksSinceMidnight(void) */ static void DOSMEM_FillBiosSegments(void) { - BYTE *pBiosSys = DOSMEM_dosmem + 0xf0000; + char *pBiosSys = DOSMEM_dosmem + 0xf0000; BYTE *pBiosROMTable = pBiosSys+0xe6f5; BIOSDATA *pBiosData = DOSMEM_BiosData(); @@ -261,7 +261,7 @@ static void DOSMEM_FillBiosSegments(void) *(pBiosROMTable+0x9) = 0x00; /* feature byte 5 */ /* BIOS date string */ - strcpy((char *)pBiosSys+0xfff5, "13/01/99"); + strcpy(pBiosSys+0xfff5, "13/01/99"); /* BIOS ID */ *(pBiosSys+0xfffe) = 0xfc; diff --git a/dlls/kernel/format_msg.c b/dlls/kernel/format_msg.c index 6df11604d65..54412ebe3c9 100644 --- a/dlls/kernel/format_msg.c +++ b/dlls/kernel/format_msg.c @@ -90,7 +90,7 @@ static INT load_messageW( HMODULE instance, UINT id, WORD lang, if (i>0) { if (mre->Flags & MESSAGE_RESOURCE_UNICODE) - lstrcpynW(buffer, (LPWSTR)mre->Text, i); + lstrcpynW(buffer, (LPCWSTR)mre->Text, i); else MultiByteToWideChar( CP_ACP, 0, mre->Text, -1, buffer, i); buffer[i]=0; @@ -170,8 +170,8 @@ DWORD WINAPI FormatMessageA( from = NULL; if (dwFlags & FORMAT_MESSAGE_FROM_STRING) { - from = HeapAlloc( GetProcessHeap(), 0, strlen((LPSTR)lpSource)+1 ); - strcpy( from, (LPSTR)lpSource ); + from = HeapAlloc( GetProcessHeap(), 0, strlen((LPCSTR)lpSource)+1 ); + strcpy( from, (LPCSTR)lpSource ); } else { bufsize = 0; @@ -398,9 +398,9 @@ DWORD WINAPI FormatMessageW( FIXME("line wrapping not supported.\n"); from = NULL; if (dwFlags & FORMAT_MESSAGE_FROM_STRING) { - from = HeapAlloc( GetProcessHeap(), 0, (strlenW((LPWSTR)lpSource) + 1) * + from = HeapAlloc( GetProcessHeap(), 0, (strlenW((LPCWSTR)lpSource) + 1) * sizeof(WCHAR) ); - strcpyW( from, (LPWSTR)lpSource ); + strcpyW( from, (LPCWSTR)lpSource ); } else { bufsize = 0; diff --git a/dlls/kernel/heap.c b/dlls/kernel/heap.c index dd680f60344..2e67cb90299 100644 --- a/dlls/kernel/heap.c +++ b/dlls/kernel/heap.c @@ -516,7 +516,7 @@ HGLOBAL WINAPI GlobalHandle( maybe_intern = HANDLE_TO_INTERN( handle ); if (maybe_intern->Magic == MAGIC_GLOBAL_USED) { test = maybe_intern->Pointer; - if (HeapValidate( GetProcessHeap(), 0, (char *)test - HGLOBAL_STORAGE ) && /* obj(-handle) valid arena? */ + if (HeapValidate( GetProcessHeap(), 0, (const char *)test - HGLOBAL_STORAGE ) && /* obj(-handle) valid arena? */ HeapValidate( GetProcessHeap(), 0, maybe_intern )) /* intern valid arena? */ break; /* valid moveable block */ } diff --git a/dlls/kernel/instr.c b/dlls/kernel/instr.c index 2eb6ba5b62f..dcb3301f722 100644 --- a/dlls/kernel/instr.c +++ b/dlls/kernel/instr.c @@ -275,7 +275,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr, wine_ldt_get_entry( seg, &entry ); if (wine_ldt_is_empty( &entry )) return NULL; if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL; - return (char *)wine_ldt_get_base(&entry) + base + (index << ss); + return (BYTE *)wine_ldt_get_base(&entry) + base + (index << ss); #undef GET_VAL } diff --git a/dlls/kernel/locale.c b/dlls/kernel/locale.c index ed9ca0c505a..c6f765bc058 100644 --- a/dlls/kernel/locale.c +++ b/dlls/kernel/locale.c @@ -40,6 +40,7 @@ #include "wine/unicode.h" #include "winnls.h" #include "winerror.h" +#include "winver.h" #include "thread.h" #include "kernel_private.h" #include "wine/debug.h" @@ -464,8 +465,8 @@ END: */ static int charset_cmp( const void *name, const void *entry ) { - const struct charset_entry *charset = (struct charset_entry *)entry; - return strcasecmp( (char *)name, charset->charset_name ); + const struct charset_entry *charset = (const struct charset_entry *)entry; + return strcasecmp( (const char *)name, charset->charset_name ); } /*********************************************************************** diff --git a/dlls/kernel/profile.c b/dlls/kernel/profile.c index 83ff47a972b..61df6630298 100644 --- a/dlls/kernel/profile.c +++ b/dlls/kernel/profile.c @@ -1048,7 +1048,7 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry, BOOL allow_section_name_copy ) { int ret; - LPWSTR pDefVal = NULL; + LPCWSTR pDefVal = NULL; if (!filename) filename = wininiW; @@ -1070,13 +1070,16 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry, if (*p == ' ') /* ouch, contained trailing ' ' */ { int len = (int)(p - def_val); - pDefVal = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); - strncpyW(pDefVal, def_val, len); - pDefVal[len] = '\0'; + LPWSTR p; + + p = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + strncpyW(p, def_val, len); + p[len] = '\0'; + pDefVal = p; } } if (!pDefVal) - pDefVal = (LPWSTR)def_val; + pDefVal = (LPCWSTR)def_val; RtlEnterCriticalSection( &PROFILE_CritSect ); @@ -1094,7 +1097,7 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry, RtlLeaveCriticalSection( &PROFILE_CritSect ); if (pDefVal != def_val) /* allocated */ - HeapFree(GetProcessHeap(), 0, pDefVal); + HeapFree(GetProcessHeap(), 0, (void*)pDefVal); TRACE("returning %s, %d\n", debugstr_w(buffer), ret); diff --git a/dlls/kernel/selector.c b/dlls/kernel/selector.c index cae4e5698dd..42e29d92e9e 100644 --- a/dlls/kernel/selector.c +++ b/dlls/kernel/selector.c @@ -479,12 +479,12 @@ static struct mapls_entry *first_entry; SEGPTR WINAPI MapLS( LPCVOID ptr ) { struct mapls_entry *entry, *free = NULL; - void *base; + const void *base; SEGPTR ret = 0; if (!HIWORD(ptr)) return (SEGPTR)ptr; - base = (char *)ptr - ((unsigned int)ptr & 0x7fff); + base = (const char *)ptr - ((unsigned int)ptr & 0x7fff); HeapLock( GetProcessHeap() ); for (entry = first_entry; entry; entry = entry->next) { @@ -507,11 +507,11 @@ SEGPTR WINAPI MapLS( LPCVOID ptr ) first_entry = free; } SetSelectorBase( free->sel, (DWORD)base ); - free->addr = base; + free->addr = (void*)base; entry = free; } entry->count++; - ret = MAKESEGPTR( entry->sel, (char *)ptr - (char *)entry->addr ); + ret = MAKESEGPTR( entry->sel, (const char *)ptr - (char *)entry->addr ); done: HeapUnlock( GetProcessHeap() ); return ret; diff --git a/dlls/kernel/thread.c b/dlls/kernel/thread.c index 3c5bbd90fd1..ee8fffed7c6 100644 --- a/dlls/kernel/thread.c +++ b/dlls/kernel/thread.c @@ -625,28 +625,28 @@ __ASM_GLOBAL_FUNC( SetLastError, "movl 4(%esp),%eax\n\t" ".byte 0x64\n\t" "movl %eax,0x34\n\t" - "ret $4" ); + "ret $4" ) /*********************************************************************** * GetLastError (KERNEL.148) * GetLastError (KERNEL32.@) */ /* DWORD WINAPI GetLastError(void); */ -__ASM_GLOBAL_FUNC( GetLastError, ".byte 0x64\n\tmovl 0x34,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( GetLastError, ".byte 0x64\n\tmovl 0x34,%eax\n\tret" ) /*********************************************************************** * GetCurrentProcessId (KERNEL.471) * GetCurrentProcessId (KERNEL32.@) */ /* DWORD WINAPI GetCurrentProcessId(void) */ -__ASM_GLOBAL_FUNC( GetCurrentProcessId, ".byte 0x64\n\tmovl 0x20,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( GetCurrentProcessId, ".byte 0x64\n\tmovl 0x20,%eax\n\tret" ) /*********************************************************************** * GetCurrentThreadId (KERNEL.462) * GetCurrentThreadId (KERNEL32.@) */ /* DWORD WINAPI GetCurrentThreadId(void) */ -__ASM_GLOBAL_FUNC( GetCurrentThreadId, ".byte 0x64\n\tmovl 0x24,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( GetCurrentThreadId, ".byte 0x64\n\tmovl 0x24,%eax\n\tret" ) #else /* __i386__ */ diff --git a/misc/registry.c b/misc/registry.c index f75f1f441b8..ffc6a3fbf41 100644 --- a/misc/registry.c +++ b/misc/registry.c @@ -322,7 +322,7 @@ struct _w31_valent { }; /* recursive helper function to display a directory tree [Internal] */ -static void _w31_dumptree(unsigned short idx, unsigned char *txt, +static void _w31_dumptree(unsigned short idx, char *txt, struct _w31_tabent *tab, struct _w31_header *head, HKEY hkey, ULONG lastmodified, int level) { @@ -398,7 +398,7 @@ static void _w31_loadreg( const WCHAR *path ) UNICODE_STRING nameW; struct _w31_header head; struct _w31_tabent* tab = NULL; - unsigned char* txt = NULL; + char* txt = NULL; unsigned int len; ULONG lastmodified; NTSTATUS status;