Another round of const correctness fixes.

oldstable
Eric Pouech 2004-12-06 20:43:55 +00:00 committed by Alexandre Julliard
parent 01035f172d
commit 294835a839
18 changed files with 67 additions and 66 deletions

View File

@ -134,7 +134,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 i
f += 4;
}
} else {
FLOAT* f = (FLOAT*) pConstantData;
const FLOAT* f = (const FLOAT*) pConstantData;
TRACE("(%p) : SetVertexShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]);
}
This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;

View File

@ -40,8 +40,8 @@ extern WORD USER_HeapSel;
#define USER_HEAP_LIN_ADDR(handle) \
((handle) ? MapSL(MAKESEGPTR(USER_HeapSel, LOWORD(handle))) : NULL)
#define GET_WORD(ptr) (*(WORD *)(ptr))
#define GET_DWORD(ptr) (*(DWORD *)(ptr))
#define GET_WORD(ptr) (*(const WORD *)(ptr))
#define GET_DWORD(ptr) (*(const DWORD *)(ptr))
#define USUD_LOCALALLOC 0x0001
#define USUD_LOCALFREE 0x0002

View File

@ -145,7 +145,7 @@ int wine_utf8_mbstowcs( int flags, const char *src, int srclen, WCHAR *dst, int
unsigned int res;
const char *srcend = src + srclen;
if (!dstlen) return get_length_mbs_utf8( src, srclen );
if (!dstlen) return get_length_mbs_utf8( (const unsigned char*)src, srclen );
for (count = dstlen; count && (src < srcend); count--, dst++)
{

View File

@ -361,8 +361,8 @@ char b;
}
int WCMD_dir_sort (const void *a, const void *b) {
return (lstrcmpi(((WIN32_FIND_DATA *)a)->cFileName,
((WIN32_FIND_DATA *)b)->cFileName));
int WCMD_dir_sort (const void *a, const void *b)
{
return (lstrcmpi(((const WIN32_FIND_DATA *)a)->cFileName,
((const WIN32_FIND_DATA *)b)->cFileName));
}

View File

@ -229,7 +229,7 @@ struct object *find_object( const struct namespace *namespace, const WCHAR *name
{
LIST_FOR_EACH( p, list )
{
struct object_name *ptr = LIST_ENTRY( p, struct object_name, entry );
const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
if (ptr->len != len) continue;
if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj );
}
@ -238,7 +238,7 @@ struct object *find_object( const struct namespace *namespace, const WCHAR *name
{
LIST_FOR_EACH( p, list )
{
struct object_name *ptr = LIST_ENTRY( p, struct object_name, entry );
const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
if (ptr->len != len) continue;
if (!strncmpiW( ptr->name, name, len/sizeof(WCHAR) )) return grab_object( ptr->obj );
}

View File

@ -108,10 +108,10 @@ static void dump_context( const CONTEXT *context )
context->SegCs, context->SegDs, context->SegEs, context->SegFs, context->SegGs,
context->Dr0, context->Dr1, context->Dr2, context->Dr3, context->Dr6, context->Dr7 );
fprintf( stderr, "float=" );
dump_uints( (int *)&context->FloatSave, sizeof(context->FloatSave) / sizeof(int) );
dump_uints( (const int *)&context->FloatSave, sizeof(context->FloatSave) / sizeof(int) );
fprintf( stderr, "}" );
#else
dump_uints( (int *)context, sizeof(*context) / sizeof(int) );
dump_uints( (const int *)context, sizeof(*context) / sizeof(int) );
#endif
}
@ -191,7 +191,7 @@ static void dump_varargs_bytes( size_t size )
static void dump_varargs_string( size_t size )
{
fprintf( stderr, "\"%.*s\"", (int)size, (char *)cur_data );
fprintf( stderr, "\"%.*s\"", (int)size, (const char *)cur_data );
remove_data( size );
}
@ -226,7 +226,7 @@ static void dump_varargs_exc_event( size_t size )
fprintf( stderr, "{context=" );
dump_context( ptr );
fprintf( stderr, ",rec=" );
dump_exc_record( (EXCEPTION_RECORD *)(ptr + 1) );
dump_exc_record( (const EXCEPTION_RECORD *)(ptr + 1) );
fputc( '}', stderr );
remove_data( size );
}

View File

@ -301,7 +301,7 @@ static struct keyword {
{"wire_marshal", tWIREMARSHAL}
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#define KWP(p) ((struct keyword *)(p))
#define KWP(p) ((const struct keyword *)(p))
static int kw_cmp_func(const void *s1, const void *s2)
{

View File

@ -110,7 +110,7 @@ static struct oatype {
{"VARIANT", VT_VARIANT}
};
#define NTYPES (sizeof(oatypes)/sizeof(oatypes[0]))
#define KWP(p) ((struct oatype *)(p))
#define KWP(p) ((const struct oatype *)(p))
static int kw_cmp_func(const void *s1, const void *s2)
{

View File

@ -309,7 +309,7 @@ static void set_module_name(unsigned setUC)
if (len > 4 && strcmp(ptr + len - 4, ".dll") == 0)
len -= 4;
buf = malloc(len + 1);
memcpy(buf, (void*)ptr, len);
memcpy(buf, (const void*)ptr, len);
buf[len] = 0;
globals.input_module = buf;
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";

View File

@ -67,7 +67,7 @@ static void dump_ne_header( const IMAGE_OS2_HEADER *ne )
static void dump_ne_names( const void *base, const IMAGE_OS2_HEADER *ne )
{
char *pstr = (char *)ne + ne->ne_restab;
const char *pstr = (const char *)ne + ne->ne_restab;
printf( "\nResident name table:\n" );
while (*pstr)
@ -112,28 +112,28 @@ static const char *get_resource_type( WORD id )
static void dump_ne_resources( const void *base, const IMAGE_OS2_HEADER *ne )
{
NE_NAMEINFO *name;
const void *res_ptr = (char *)ne + ne->ne_rsrctab;
const NE_NAMEINFO *name;
const void *res_ptr = (const char *)ne + ne->ne_rsrctab;
WORD size_shift = get_word(res_ptr);
NE_TYPEINFO *info = (NE_TYPEINFO *)((WORD *)res_ptr + 1);
const NE_TYPEINFO *info = (const NE_TYPEINFO *)((const WORD *)res_ptr + 1);
int count;
printf( "\nResources:\n" );
while (info->type_id != 0 && (char *)info < (char *)ne + ne->ne_restab)
while (info->type_id != 0 && (const char *)info < (const char *)ne + ne->ne_restab)
{
name = (NE_NAMEINFO *)(info + 1);
name = (const NE_NAMEINFO *)(info + 1);
for (count = info->count; count > 0; count--, name++)
{
if (name->id & 0x8000) printf( " %d", (name->id & ~0x8000) );
else printf( " %.*s", *((unsigned char *)res_ptr + name->id),
(char *)res_ptr + name->id + 1 );
else printf( " %.*s", *((const unsigned char *)res_ptr + name->id),
(const char *)res_ptr + name->id + 1 );
if (info->type_id & 0x8000) printf( " %s\n", get_resource_type(info->type_id) );
else printf( " %.*s\n", *((unsigned char *)res_ptr + info->type_id),
(char *)res_ptr + info->type_id + 1 );
dump_data( (unsigned char *)base + (name->offset << size_shift),
else printf( " %.*s\n", *((const unsigned char *)res_ptr + info->type_id),
(const char *)res_ptr + info->type_id + 1 );
dump_data( (const unsigned char *)base + (name->offset << size_shift),
name->length << size_shift, " " );
}
info = (NE_TYPEINFO *)name;
info = (const NE_TYPEINFO *)name;
}
}
@ -230,7 +230,7 @@ static void dump_ne_exports( const void *base, const IMAGE_OS2_HEADER *ne )
void ne_dump( const void *exe, size_t exe_size )
{
const IMAGE_DOS_HEADER *dos = exe;
const IMAGE_OS2_HEADER *ne = (IMAGE_OS2_HEADER *)((char *)dos + dos->e_lfanew);
const IMAGE_OS2_HEADER *ne = (const IMAGE_OS2_HEADER *)((const char *)dos + dos->e_lfanew);
dump_ne_header( ne );
dump_ne_names( exe, ne );

View File

@ -849,12 +849,12 @@ static void dump_msgtable_data( const void *ptr, unsigned int size, unsigned int
{
const MESSAGE_RESOURCE_ENTRY *entry;
entry = (MESSAGE_RESOURCE_ENTRY *)((char *)data + block->OffsetToEntries);
entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)data + block->OffsetToEntries);
for (j = block->LowId; j <= block->HighId; j++)
{
if (entry->Flags & MESSAGE_RESOURCE_UNICODE)
{
const WCHAR *str = (WCHAR *)entry->Text;
const WCHAR *str = (const WCHAR *)entry->Text;
printf( "%s%08x L\"", prefix, j );
dump_strW( str, strlenW(str) );
printf( "\"\n" );
@ -865,7 +865,7 @@ static void dump_msgtable_data( const void *ptr, unsigned int size, unsigned int
dump_strA( entry->Text, strlen(entry->Text) );
printf( "\"\n" );
}
entry = (MESSAGE_RESOURCE_ENTRY *)((char *)entry + entry->Length);
entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)entry + entry->Length);
}
}
}
@ -886,20 +886,20 @@ static void dump_dir_resource(void)
for (i = 0; i< root->NumberOfNamedEntries + root->NumberOfIdEntries; i++)
{
e1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(root + 1) + i;
namedir = (IMAGE_RESOURCE_DIRECTORY *)((char *)root + e1->u2.s3.OffsetToDirectory);
e1 = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(root + 1) + i;
namedir = (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + e1->u2.s3.OffsetToDirectory);
for (j = 0; j < namedir->NumberOfNamedEntries + namedir->NumberOfIdEntries; j++)
{
e2 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(namedir + 1) + j;
langdir = (IMAGE_RESOURCE_DIRECTORY *)((char *)root + e2->u2.s3.OffsetToDirectory);
e2 = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(namedir + 1) + j;
langdir = (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + e2->u2.s3.OffsetToDirectory);
for (k = 0; k < langdir->NumberOfNamedEntries + langdir->NumberOfIdEntries; k++)
{
e3 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(langdir + 1) + k;
e3 = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(langdir + 1) + k;
printf( "\n " );
if (e1->u1.s1.NameIsString)
{
string = (PIMAGE_RESOURCE_DIR_STRING_U)((char *)root + e1->u1.s1.NameOffset);
string = (const IMAGE_RESOURCE_DIR_STRING_U*)((const char *)root + e1->u1.s1.NameOffset);
dump_unicode_str( string->NameString, string->Length );
}
else
@ -912,14 +912,14 @@ static void dump_dir_resource(void)
printf( " Name=" );
if (e2->u1.s1.NameIsString)
{
string = (PIMAGE_RESOURCE_DIR_STRING_U) ((char *)root + e2->u1.s1.NameOffset);
string = (const IMAGE_RESOURCE_DIR_STRING_U*) ((const char *)root + e2->u1.s1.NameOffset);
dump_unicode_str( string->NameString, string->Length );
}
else
printf( "%04x", e2->u1.s2.Id );
printf( " Language=%04x:\n", e3->u1.s2.Id );
data = (IMAGE_RESOURCE_DATA_ENTRY *)((char *)root + e3->u2.OffsetToData);
data = (const IMAGE_RESOURCE_DATA_ENTRY *)((const char *)root + e3->u2.OffsetToData);
if (e1->u1.s1.NameIsString)
{
dump_data( RVA( data->OffsetToData, data->Size ), data->Size, " " );
@ -1130,7 +1130,7 @@ static dll_symbol *dll_current_symbol = NULL;
/* Compare symbols by ordinal for qsort */
static int symbol_cmp(const void *left, const void *right)
{
return ((dll_symbol *)left)->ordinal > ((dll_symbol *)right)->ordinal;
return ((const dll_symbol *)left)->ordinal > ((const dll_symbol *)right)->ordinal;
}
/*******************************************************************

View File

@ -153,14 +153,14 @@ int symbol_search (parsed_symbol *sym)
*/
static int symbol_from_prototype (parsed_symbol *sym, const char *proto)
{
char *iter;
const char *iter;
int found;
proto = get_type (sym, proto, -1); /* Get return type */
if (!proto)
return -1;
iter = (char *)str_match (proto, sym->symbol, &found);
iter = str_match (proto, sym->symbol, &found);
if (!found)
{
@ -177,7 +177,7 @@ static int symbol_from_prototype (parsed_symbol *sym, const char *proto)
else
sym->flags |= SYM_STDCALL;
free (call);
iter = (char *)str_match (iter, sym->symbol, &found);
iter = str_match (iter, sym->symbol, &found);
if (!found)
return -1;
@ -232,13 +232,14 @@ static int symbol_from_prototype (parsed_symbol *sym, const char *proto)
static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
{
int is_const, is_volatile, is_struct, is_signed, is_unsigned, ptrs = 0;
char *iter, *type_str, *base_type, *catch_unsigned, dest_type;
const char *iter, *type_str, *base_type, *catch_unsigned;
char dest_type;
assert (sym && sym->symbol);
assert (proto && *proto);
assert (arg < 0 || (unsigned)arg == sym->argc);
type_str = (char *)proto;
type_str = proto;
proto = str_match (proto, "const", &is_const);
proto = str_match (proto, "volatile", &is_volatile);
@ -246,7 +247,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
if (!is_struct)
proto = str_match (proto, "union", &is_struct);
catch_unsigned = (char *)proto;
catch_unsigned = proto;
proto = str_match (proto, "unsigned", &is_unsigned);
proto = str_match (proto, "signed", &is_signed);
@ -257,8 +258,8 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
if (!is_volatile)
proto = str_match (proto, "volatile", &is_volatile);
base_type = (char *)proto;
iter = (char *)str_find_set (proto, " ,*)");
base_type = proto;
iter = str_find_set (proto, " ,*)");
if (!iter)
return NULL;
@ -268,7 +269,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
if (strncmp (base_type, "int", 3) && strncmp (base_type, "long", 4) &&
strncmp (base_type, "short", 5) && strncmp (base_type, "char", 4))
{
iter = (char *)proto;
iter = proto;
base_type = catch_unsigned;
}
}
@ -290,7 +291,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
{
/* 'unsigned' with no type */
char *tmp = str_create (2, type_str, " int");
free (type_str);
free ((char*)type_str);
type_str = tmp;
}
symbol_clean_string (type_str);
@ -299,7 +300,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
if (arg < 0)
{
sym->return_text = type_str;
sym->return_text = (char*)type_str;
sym->return_type = dest_type;
}
else
@ -311,16 +312,16 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
sym->arg_name [arg] = str_create_num (1, arg, "arg");
else
{
iter = (char *)str_find_set (proto, " ,)");
iter = str_find_set (proto, " ,)");
if (!iter)
{
free (type_str);
free ((char*)type_str);
return NULL;
}
sym->arg_name [arg] = str_substring (proto, iter);
proto = iter;
}
sym->arg_text [arg] = type_str;
sym->arg_text [arg] = (char*)type_str;
}
return proto;

View File

@ -140,7 +140,7 @@ void show_languages(void)
static int langcmp(const void *p1, const void *p2)
{
return *(unsigned *)p1 - ((language_t *)p2)->id;
return *(const unsigned *)p1 - ((const language_t *)p2)->id;
}
const language_t *find_language(unsigned id)

View File

@ -547,7 +547,7 @@ static void newline(void)
static int unisort(const void *p1, const void *p2)
{
return unistricmp(((token_t *)p1)->name, ((token_t *)p2)->name);
return unistricmp(((const token_t *)p1)->name, ((const token_t *)p2)->name);
}
static token_t *tokentable = NULL;

View File

@ -208,7 +208,7 @@ static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse )
if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)info;
const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
return sizeof(BITMAPCOREHEADER) + colors *
((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
@ -569,8 +569,8 @@ static CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir,
* directly from corresponding DIB sections
* Note: wResId is index to array of pointer returned in ptrs (origin is 1)
*/
static BOOL CURSORICON_SimulateLoadingFromResourceW( LPWSTR filename, BOOL fCursor,
CURSORICONDIR **res, LPBYTE **ptr)
static BOOL CURSORICON_SimulateLoadingFromResourceW( LPCWSTR filename, BOOL fCursor,
CURSORICONDIR **res, LPBYTE **ptr)
{
LPBYTE _free;
CURSORICONFILEDIR *bits;
@ -907,7 +907,7 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name,
if ( loadflags & LR_LOADFROMFILE ) /* Load from file */
{
LPBYTE *ptr;
if (!CURSORICON_SimulateLoadingFromResourceW((LPWSTR)name, fCursor, &dir, &ptr))
if (!CURSORICON_SimulateLoadingFromResourceW(name, fCursor, &dir, &ptr))
return 0;
if (fCursor)
dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestCursor(dir, width, height, 1);
@ -2198,7 +2198,7 @@ HANDLE WINAPI LoadImageA( HINSTANCE hinst, LPCSTR name, UINT type,
LPWSTR u_name;
if (!HIWORD(name))
return LoadImageW(hinst, (LPWSTR)name, type, desiredx, desiredy, loadflags);
return LoadImageW(hinst, (LPCWSTR)name, type, desiredx, desiredy, loadflags);
__TRY {
DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );

View File

@ -296,7 +296,7 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
TRACE(" BEGIN\n" );
while (items--)
{
template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
template = (LPCSTR)DIALOG_GetControl32( (const WORD *)template, &info,
dlgTemplate->dialogEx );
/* Is this it? */
if (info.style & WS_BORDER)

View File

@ -1905,6 +1905,6 @@ static HWND MDI_MoreWindowsDialog(HWND hwnd)
return 0;
return (HWND) DialogBoxIndirectParamA(user32_module,
(LPDLGTEMPLATEA) template,
(const DLGTEMPLATE*) template,
hwnd, MDI_MoreWindowsDlgProc, (LPARAM) hwnd);
}

View File

@ -1316,7 +1316,7 @@ typedef struct
{
const WCHAR *classname; /* class name to match */
const USER_MSG *classmsg; /* pointer to first USER_MSG for class */
USER_MSG *lastmsg; /* pointer to last USER_MSG for class */
const USER_MSG *lastmsg; /* pointer to last USER_MSG for class */
} CONTROL_CLASS;
#define USM(a,b) { #a ,a,b}