Commit a67b6891 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32: Fix compilation warnings in 64-bit mode.

parent e142779b
......@@ -664,10 +664,10 @@ LONG WINAPI _hwrite( HFILE handle, LPCSTR buffer, LONG count )
if (!count)
{
/* Expand or truncate at current position */
if (!SetEndOfFile( (HANDLE)handle )) return HFILE_ERROR;
if (!SetEndOfFile( LongToHandle(handle) )) return HFILE_ERROR;
return 0;
}
if (!WriteFile( (HANDLE)handle, buffer, count, &result, NULL ))
if (!WriteFile( LongToHandle(handle), buffer, count, &result, NULL ))
return HFILE_ERROR;
return result;
}
......@@ -679,7 +679,7 @@ LONG WINAPI _hwrite( HFILE handle, LPCSTR buffer, LONG count )
HFILE WINAPI _lclose( HFILE hFile )
{
TRACE("handle %d\n", hFile );
return CloseHandle( (HANDLE)hFile ) ? 0 : HFILE_ERROR;
return CloseHandle( LongToHandle(hFile) ) ? 0 : HFILE_ERROR;
}
......@@ -688,12 +688,15 @@ HFILE WINAPI _lclose( HFILE hFile )
*/
HFILE WINAPI _lcreat( LPCSTR path, INT attr )
{
HANDLE hfile;
/* Mask off all flags not explicitly allowed by the doc */
attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
TRACE("%s %02x\n", path, attr );
return (HFILE)CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
hfile = CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, attr, 0 );
return HandleToLong(hfile);
}
......@@ -702,8 +705,11 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr )
*/
HFILE WINAPI _lopen( LPCSTR path, INT mode )
{
HANDLE hfile;
TRACE("(%s,%04x)\n", debugstr_a(path), mode );
return (HFILE)create_file_OF( path, mode & ~OF_CREATE );
hfile = create_file_OF( path, mode & ~OF_CREATE );
return HandleToLong(hfile);
}
/***********************************************************************
......@@ -712,7 +718,7 @@ HFILE WINAPI _lopen( LPCSTR path, INT mode )
UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
{
DWORD result;
if (!ReadFile( (HANDLE)handle, buffer, count, &result, NULL ))
if (!ReadFile( LongToHandle(handle), buffer, count, &result, NULL ))
return HFILE_ERROR;
return result;
}
......@@ -723,7 +729,7 @@ UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
*/
LONG WINAPI _llseek( HFILE hFile, LONG lOffset, INT nOrigin )
{
return SetFilePointer( (HANDLE)hFile, lOffset, NULL, nOrigin );
return SetFilePointer( LongToHandle(hFile), lOffset, NULL, nOrigin );
}
......@@ -2254,7 +2260,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
return TRUE;
}
handle = (HANDLE)_lopen( ofs->szPathName, mode );
handle = LongToHandle(_lopen( ofs->szPathName, mode ));
if (handle == INVALID_HANDLE_VALUE) goto error;
GetFileTime( handle, NULL, NULL, &filetime );
......@@ -2279,7 +2285,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
CloseHandle( handle );
return TRUE;
}
else return (HFILE)handle;
return HandleToLong(handle);
error: /* We get here if there was an error opening the file */
ofs->nErrCode = GetLastError();
......
......@@ -1240,7 +1240,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
lang_id = MAKELANGID(PRIMARYLANGID(lang_id), SUBLANG_DEFAULT);
if (!(hrsrc = FindResourceExW( kernel32_handle, (LPWSTR)RT_STRING,
(LPCWSTR)((lctype >> 4) + 1), lang_id )))
ULongToPtr((lctype >> 4) + 1), lang_id )))
{
SetLastError( ERROR_INVALID_FLAGS ); /* no such lctype */
return 0;
......
......@@ -499,8 +499,8 @@ LONG WINAPI LZCopy( HFILE src, HFILE dest )
/* Maintain the timestamp of source file to destination file */
srcfd = (!(lzs = GET_LZ_STATE(src))) ? src : lzs->realfd;
GetFileTime((HANDLE)srcfd, NULL, NULL, &filetime);
SetFileTime((HANDLE)dest, NULL, NULL, &filetime);
GetFileTime( LongToHandle(srcfd), NULL, NULL, &filetime );
SetFileTime( LongToHandle(dest), NULL, NULL, &filetime );
/* close handle */
if (usedlzinit)
......@@ -583,7 +583,7 @@ void WINAPI LZClose( HFILE fd )
else
{
HeapFree( GetProcessHeap(), 0, lzs->get );
CloseHandle((HANDLE)lzs->realfd);
CloseHandle( LongToHandle(lzs->realfd) );
lzstates[fd - LZ_MIN_HANDLE] = NULL;
HeapFree( GetProcessHeap(), 0, lzs );
}
......
......@@ -1848,7 +1848,7 @@ HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
if (!SearchPathA( NULL, name, ".exe", sizeof(filename), filename, NULL ) &&
!SearchPathA( NULL, name, NULL, sizeof(filename), filename, NULL ))
return (HINSTANCE)GetLastError();
return ULongToHandle(GetLastError());
len = (BYTE)params->lpCmdLine[0];
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + len + 2 )))
......@@ -1879,7 +1879,7 @@ HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
CloseHandle( info.hThread );
CloseHandle( info.hProcess );
}
else if ((hInstance = (HINSTANCE)GetLastError()) >= (HINSTANCE)32)
else if ((hInstance = ULongToHandle(GetLastError())) >= (HINSTANCE)32)
{
FIXME("Strange error set by CreateProcess: %p\n", hInstance );
hInstance = (HINSTANCE)11;
......@@ -2174,15 +2174,15 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
case GPD_WINDOWS_VERSION:
return GetExeVersion16();
case GPD_THDB:
return (DWORD)NtCurrentTeb() - 0x10 /* FIXME */;
return (DWORD_PTR)NtCurrentTeb() - 0x10 /* FIXME */;
case GPD_PDB:
return (DWORD)NtCurrentTeb()->Peb;
return (DWORD_PTR)NtCurrentTeb()->Peb; /* FIXME: truncating a pointer */
case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */
GetStartupInfoW(&siw);
return (DWORD)siw.hStdOutput;
return HandleToULong(siw.hStdOutput);
case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
GetStartupInfoW(&siw);
return (DWORD)siw.hStdInput;
return HandleToULong(siw.hStdInput);
case GPD_STARTF_SHOWWINDOW:
GetStartupInfoW(&siw);
return siw.wShowWindow;
......@@ -2289,7 +2289,7 @@ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
OBJECT_ATTRIBUTES attr;
CLIENT_ID cid;
cid.UniqueProcess = (HANDLE)id;
cid.UniqueProcess = ULongToHandle(id);
cid.UniqueThread = 0; /* FIXME ? */
attr.Length = sizeof(OBJECT_ATTRIBUTES);
......@@ -2363,7 +2363,7 @@ BOOL WINAPI CloseHandle( HANDLE handle )
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
(handle == (HANDLE)STD_ERROR_HANDLE))
handle = GetStdHandle( (DWORD)handle );
handle = GetStdHandle( HandleToULong(handle) );
if (is_console_handle(handle))
return CloseConsoleHandle(handle);
......
......@@ -82,7 +82,7 @@ static DWORD CALLBACK pthread_thread_start(LPVOID data)
{
struct pthread_thread_init init = *(struct pthread_thread_init*)data;
HeapFree(GetProcessHeap(),0,data);
return (DWORD)init.start_routine(init.arg);
return (DWORD_PTR)init.start_routine(init.arg);
}
static int wine_pthread_create(pthread_t* thread, const pthread_attr_t* attr, void*
......@@ -193,7 +193,7 @@ static int wine_pthread_mutex_unlock(pthread_mutex_t *mutex)
CRITICAL_SECTION *crit = ((wine_mutex)mutex)->critsect;
if (!crit) return 0;
if (crit->OwningThread != (HANDLE)GetCurrentThreadId()) return EPERM;
if (crit->OwningThread != ULongToHandle(GetCurrentThreadId())) return EPERM;
RtlLeaveCriticalSection( crit );
return 0;
}
......@@ -526,7 +526,7 @@ static int wine_pthread_equal(pthread_t thread1, pthread_t thread2)
static void wine_pthread_exit(void *retval, char *currentframe)
{
ExitThread((DWORD)retval);
ExitThread((DWORD_PTR)retval);
}
static void *wine_get_thread_data(void)
......
......@@ -60,7 +60,7 @@ static NTSTATUS get_res_nameA( LPCSTR name, UNICODE_STRING *str )
ULONG value;
if (RtlCharToInteger( name + 1, 10, &value ) != STATUS_SUCCESS || HIWORD(value))
return STATUS_INVALID_PARAMETER;
str->Buffer = (LPWSTR)value;
str->Buffer = ULongToPtr(value);
return STATUS_SUCCESS;
}
RtlCreateUnicodeStringFromAsciiz( str, name );
......@@ -82,7 +82,7 @@ static NTSTATUS get_res_nameW( LPCWSTR name, UNICODE_STRING *str )
RtlInitUnicodeString( str, name + 1 );
if (RtlUnicodeStringToInteger( str, 10, &value ) != STATUS_SUCCESS || HIWORD(value))
return STATUS_INVALID_PARAMETER;
str->Buffer = (LPWSTR)value;
str->Buffer = ULongToPtr(value);
return STATUS_SUCCESS;
}
RtlCreateUnicodeString( str, name );
......@@ -288,7 +288,7 @@ BOOL WINAPI EnumResourceTypesA( HMODULE hmod, ENUMRESTYPEPROCA lpfun, LONG_PTR l
}
else
{
ret = lpfun( hmod, (LPSTR)(int)et[i].u1.s2.Id, lparam );
ret = lpfun( hmod, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
......@@ -337,7 +337,7 @@ BOOL WINAPI EnumResourceTypesW( HMODULE hmod, ENUMRESTYPEPROCW lpfun, LONG_PTR l
}
else
{
ret = lpfun( hmod, (LPWSTR)(int)et[i].u1.s2.Id, lparam );
ret = lpfun( hmod, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
......@@ -370,7 +370,7 @@ BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfu
goto done;
if ((status = get_res_nameA( type, &typeW )) != STATUS_SUCCESS)
goto done;
info.Type = (ULONG)typeW.Buffer;
info.Type = (ULONG_PTR)typeW.Buffer;
if ((status = LdrFindResourceDirectory_U( hmod, &info, 1, &resdir )) != STATUS_SUCCESS)
goto done;
......@@ -397,7 +397,7 @@ BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfu
}
else
{
ret = lpfun( hmod, type, (LPSTR)(int)et[i].u1.s2.Id, lparam );
ret = lpfun( hmod, type, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
......@@ -432,7 +432,7 @@ BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpf
goto done;
if ((status = get_res_nameW( type, &typeW )) != STATUS_SUCCESS)
goto done;
info.Type = (ULONG)typeW.Buffer;
info.Type = (ULONG_PTR)typeW.Buffer;
if ((status = LdrFindResourceDirectory_U( hmod, &info, 1, &resdir )) != STATUS_SUCCESS)
goto done;
......@@ -458,7 +458,7 @@ BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpf
}
else
{
ret = lpfun( hmod, type, (LPWSTR)(int)et[i].u1.s2.Id, lparam );
ret = lpfun( hmod, type, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
......@@ -979,7 +979,7 @@ static LPWSTR resource_dup_string( const IMAGE_RESOURCE_DIRECTORY *root, const I
LPWSTR s;
if (!entry->u1.s1.NameIsString)
return (LPWSTR) (DWORD) entry->u1.s2.Id;
return UIntToPtr(entry->u1.s2.Id);
string = (const IMAGE_RESOURCE_DIR_STRING_U*) (((const char *)root) + entry->u1.s1.NameOffset);
s = HeapAlloc(GetProcessHeap(), 0, (string->Length + 1)*sizeof (WCHAR) );
......
......@@ -170,7 +170,7 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if ((handles[i] == (HANDLE)STD_INPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_OUTPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_ERROR_HANDLE))
hloc[i] = GetStdHandle( (DWORD)handles[i] );
hloc[i] = GetStdHandle( HandleToULong(handles[i]) );
else
hloc[i] = handles[i];
......@@ -1168,7 +1168,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
pipe_type = (dwPipeMode & PIPE_TYPE_MESSAGE) ? TRUE : FALSE;
read_mode = (dwPipeMode & PIPE_READMODE_MESSAGE) ? TRUE : FALSE;
non_block = (dwPipeMode & PIPE_NOWAIT) ? TRUE : FALSE;
if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES) nMaxInstances = ~0UL;
if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES) nMaxInstances = ~0U;
timeout.QuadPart = (ULONGLONG)nDefaultTimeOut * -10000;
......
......@@ -157,7 +157,7 @@ VOID WINAPI _KERNEL32_86(SYSLEVEL *lock)
*/
DWORD WINAPI _ConfirmSysLevel(SYSLEVEL *lock)
{
if ( lock && lock->crst.OwningThread == (HANDLE)GetCurrentThreadId() )
if ( lock && lock->crst.OwningThread == ULongToHandle(GetCurrentThreadId()) )
return lock->crst.RecursionCount;
else
return 0L;
......@@ -169,7 +169,7 @@ DWORD WINAPI _ConfirmSysLevel(SYSLEVEL *lock)
*/
VOID WINAPI _CheckNotSysLevel(SYSLEVEL *lock)
{
if (lock && lock->crst.OwningThread == (HANDLE)GetCurrentThreadId() &&
if (lock && lock->crst.OwningThread == ULongToHandle(GetCurrentThreadId()) &&
lock->crst.RecursionCount)
{
ERR( "Holding lock %p level %d\n", lock, lock->level );
......
......@@ -92,7 +92,7 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
(PRTL_THREAD_START_ROUTINE)start, param, &handle, &client_id );
if (status == STATUS_SUCCESS)
{
if (id) *id = (DWORD)client_id.UniqueThread;
if (id) *id = HandleToULong(client_id.UniqueThread);
if (sa && (sa->nLength >= sizeof(*sa)) && sa->bInheritHandle)
SetHandleInformation( handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT );
if (!(flags & CREATE_SUSPENDED))
......@@ -133,7 +133,7 @@ HANDLE WINAPI OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwTh
attr.SecurityQualityOfService = NULL;
cid.UniqueProcess = 0; /* FIXME */
cid.UniqueThread = (HANDLE)dwThreadId;
cid.UniqueThread = ULongToHandle(dwThreadId);
status = NtOpenThread( &handle, dwDesiredAccess, &attr, &cid );
if (status)
{
......@@ -621,7 +621,7 @@ DWORD WINAPI GetLastError(void)
*/
DWORD WINAPI GetCurrentProcessId(void)
{
return (DWORD)NtCurrentTeb()->ClientId.UniqueProcess;
return HandleToULong(NtCurrentTeb()->ClientId.UniqueProcess);
}
/***********************************************************************
......@@ -635,7 +635,7 @@ DWORD WINAPI GetCurrentProcessId(void)
*/
DWORD WINAPI GetCurrentThreadId(void)
{
return (DWORD)NtCurrentTeb()->ClientId.UniqueThread;
return HandleToULong(NtCurrentTeb()->ClientId.UniqueThread);
}
#endif /* __i386__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment