[KERNEL32]

Fix MSVC warnings.

svn path=/trunk/; revision=60095
This commit is contained in:
Timo Kreuzer 2013-09-14 10:20:11 +00:00
parent ba3d6d39e7
commit 5550a1f54e
13 changed files with 72 additions and 70 deletions

View file

@ -121,7 +121,7 @@ InitConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
ConsoleStartInfo->dwStartupFlags = si.dwFlags;
if (si.dwFlags & STARTF_USEFILLATTRIBUTE)
{
ConsoleStartInfo->wFillAttribute = si.dwFillAttribute;
ConsoleStartInfo->wFillAttribute = (WORD)si.dwFillAttribute;
}
if (si.dwFlags & STARTF_USECOUNTCHARS)
{
@ -134,13 +134,13 @@ InitConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
}
if (si.dwFlags & STARTF_USEPOSITION)
{
ConsoleStartInfo->dwWindowOrigin.X = (LONG)(si.dwX);
ConsoleStartInfo->dwWindowOrigin.Y = (LONG)(si.dwY);
ConsoleStartInfo->dwWindowOrigin.X = (SHORT)(si.dwX);
ConsoleStartInfo->dwWindowOrigin.Y = (SHORT)(si.dwY);
}
if (si.dwFlags & STARTF_USESIZE)
{
ConsoleStartInfo->dwWindowSize.X = (LONG)(si.dwXSize);
ConsoleStartInfo->dwWindowSize.Y = (LONG) (si.dwYSize);
ConsoleStartInfo->dwWindowSize.X = (SHORT)(si.dwXSize);
ConsoleStartInfo->dwWindowSize.Y = (SHORT)(si.dwYSize);
}
/* Set up the title for the console */

View file

@ -660,7 +660,7 @@ IntWriteConsoleOutputCode(HANDLE hConsoleOutput,
WriteOutputCodeRequest->CodeType = CodeType;
WriteOutputCodeRequest->Coord = dwWriteCoord;
WriteOutputCodeRequest->Length = nLength;
WriteOutputCodeRequest->Length = (USHORT)nLength;
/* Call the server */
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,

View file

@ -50,7 +50,7 @@ GetEnvironmentVariableA(IN LPCSTR lpName,
if (nSize)
{
/* Keep the given size, minus a NULL-char */
UniSize = nSize - 1;
UniSize = (USHORT)(nSize - 1);
}
else
{
@ -114,7 +114,7 @@ GetEnvironmentVariableA(IN LPCSTR lpName,
{
/* Check if the size is too big to fit */
UniSize = UNICODE_STRING_MAX_BYTES - 1;
if (nSize <= UniSize) UniSize = nSize;
if (nSize <= UniSize) UniSize = (USHORT)nSize;
/* Check the size */
Result = RtlUnicodeStringToAnsiSize(&VarValueU);
@ -169,7 +169,7 @@ GetEnvironmentVariableW(IN LPCWSTR lpName,
{
if (nSize)
{
UniSize = nSize * sizeof(WCHAR) - sizeof(UNICODE_NULL);
UniSize = (USHORT)nSize * sizeof(WCHAR) - sizeof(UNICODE_NULL);
}
else
{
@ -180,7 +180,7 @@ GetEnvironmentVariableW(IN LPCWSTR lpName,
{
UniSize = UNICODE_STRING_MAX_BYTES - sizeof(UNICODE_NULL);
}
Status = RtlInitUnicodeStringEx(&VarName, lpName);
if (!NT_SUCCESS(Status))
{
@ -404,11 +404,11 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
/* Check if the size is too big to fit */
UniSize = UNICODE_STRING_MAX_CHARS - 2;
if (nSize <= UniSize) UniSize = nSize;
if (nSize <= UniSize) UniSize = (USHORT)nSize;
/* Clear the input buffer */
if (lpDst) *lpDst = ANSI_NULL;
/* Initialize all the strings */
RtlInitAnsiString(&Source, lpSrc);
RtlInitUnicodeString(&SourceU, NULL);
@ -446,7 +446,7 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
if (!(NT_SUCCESS(Status)) && (Status == STATUS_BUFFER_TOO_SMALL))
{
/* Fixup the length that the API returned */
DestU.MaximumLength = Length;
DestU.MaximumLength = (SHORT)Length;
/* Free old Unicode buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, DestU.Buffer);
@ -474,7 +474,7 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
{
/* Check if the size is too big to fit */
UniSize = UNICODE_STRING_MAX_BYTES - 1;
if (nSize <= UniSize) UniSize = nSize;
if (nSize <= UniSize) UniSize = (USHORT)nSize;
/* Check the size */
Result = RtlUnicodeStringToAnsiSize(&DestU);
@ -483,7 +483,7 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
/* Convert the string */
RtlInitEmptyAnsiString(&Dest, lpDst, UniSize);
Status = RtlUnicodeStringToAnsiString(&Dest, &DestU, FALSE);
/* Write a NULL-char in case of failure only */
if (!NT_SUCCESS(Status)) *lpDst = ANSI_NULL;
}
@ -517,13 +517,13 @@ ExpandEnvironmentStringsW(IN LPCWSTR lpSrc,
UNICODE_STRING Source, Destination;
NTSTATUS Status;
USHORT UniSize;
UniSize = UNICODE_STRING_MAX_CHARS - 2;
if (nSize <= UniSize) UniSize = nSize;
if (nSize <= UniSize) UniSize = (USHORT)nSize;
RtlInitUnicodeString(&Source, (LPWSTR)lpSrc);
RtlInitEmptyUnicodeString(&Destination, lpDst, UniSize * sizeof(WCHAR));
Status = RtlExpandEnvironmentStrings_U(NULL,
&Source,
&Destination,

View file

@ -418,7 +418,7 @@ OpenFile(LPCSTR lpFileName,
lpReOpenBuff->szPathName,
NULL))
{
lpReOpenBuff->nErrCode = GetLastError();
lpReOpenBuff->nErrCode = (WORD)GetLastError();
return HFILE_ERROR;
}
@ -492,7 +492,7 @@ OpenFile(LPCSTR lpFileName,
if (Len == 0 || Len > OFS_MAXPATHNAME)
{
lpReOpenBuff->nErrCode = GetLastError();
lpReOpenBuff->nErrCode = (WORD)GetLastError();
return (HFILE)INVALID_HANDLE_VALUE;
}
@ -500,7 +500,7 @@ OpenFile(LPCSTR lpFileName,
{
if (!DeleteFileW(PathNameW))
{
lpReOpenBuff->nErrCode = GetLastError();
lpReOpenBuff->nErrCode = (WORD)GetLastError();
return HFILE_ERROR;
}
TRACE("(%s): OF_DELETE return = OK\n", lpFileName);
@ -546,7 +546,7 @@ OpenFile(LPCSTR lpFileName,
RtlFreeHeap(RtlGetProcessHeap(), 0, FileNameString.Buffer);
lpReOpenBuff->nErrCode = RtlNtStatusToDosError(errCode);
lpReOpenBuff->nErrCode = (WORD)RtlNtStatusToDosError(errCode);
if (!NT_SUCCESS(errCode))
{

View file

@ -552,7 +552,7 @@ GetModuleFileNameA(HINSTANCE hModule,
}
/* Call unicode API */
FilenameW.Length = GetModuleFileNameW(hModule, FilenameW.Buffer, nSize) * sizeof(WCHAR);
FilenameW.Length = (USHORT)GetModuleFileNameW(hModule, FilenameW.Buffer, nSize) * sizeof(WCHAR);
FilenameW.MaximumLength = FilenameW.Length + sizeof(WCHAR);
if (FilenameW.Length)

View file

@ -557,7 +557,7 @@ IsShortName_U(IN PWCHAR Name,
IN ULONG Length)
{
BOOLEAN HasExtension;
WCHAR c;
UCHAR c;
NTSTATUS Status;
UNICODE_STRING UnicodeName;
ANSI_STRING AnsiName;
@ -587,7 +587,7 @@ IsShortName_U(IN PWCHAR Name,
/* Initialize our two strings */
RtlInitEmptyAnsiString(&AnsiName, AnsiBuffer, MAX_PATH);
RtlInitEmptyUnicodeString(&UnicodeName, Name, Length * sizeof(WCHAR));
RtlInitEmptyUnicodeString(&UnicodeName, Name, (USHORT)Length * sizeof(WCHAR));
UnicodeName.Length = UnicodeName.MaximumLength;
/* Now do the conversion */
@ -914,7 +914,7 @@ GetDllDirectoryA(IN DWORD nBufferLength,
ANSI_STRING AnsiDllDirectory;
ULONG Length;
RtlInitEmptyAnsiString(&AnsiDllDirectory, lpBuffer, nBufferLength);
RtlInitEmptyAnsiString(&AnsiDllDirectory, lpBuffer, (USHORT)nBufferLength);
RtlEnterCriticalSection(&BaseDllDirectoryLock);
@ -1363,7 +1363,7 @@ SearchPathW(IN LPCWSTR lpPath,
}
/* Set the path size now that we have it */
PathString.MaximumLength = PathString.Length = LengthNeeded * sizeof(WCHAR);
PathString.MaximumLength = PathString.Length = (USHORT)LengthNeeded * sizeof(WCHAR);
/* Request SxS isolation from RtlDosSearchPath_Ustr */
Flags |= 1;
@ -1377,7 +1377,7 @@ SearchPathW(IN LPCWSTR lpPath,
if (nBufferLength <= UNICODE_STRING_MAX_CHARS)
{
/* Add it into the string */
CallerBuffer.MaximumLength = nBufferLength * sizeof(WCHAR);
CallerBuffer.MaximumLength = (USHORT)nBufferLength * sizeof(WCHAR);
}
else
{
@ -1707,9 +1707,9 @@ GetLongPathNameA(IN LPCSTR lpszShortPath,
if (!PathLength) goto Quickie;
ShortPathUni.MaximumLength = PathLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
ShortPathUni.MaximumLength = (USHORT)PathLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
LongPathUni.Buffer = LongPath;
LongPathUni.Length = PathLength * sizeof(WCHAR);
LongPathUni.Length = (USHORT)PathLength * sizeof(WCHAR);
Status = BasepUnicodeStringTo8BitString(&LongPathAnsi, &LongPathUni, TRUE);
if (!NT_SUCCESS(Status))
@ -1788,9 +1788,9 @@ GetShortPathNameA(IN LPCSTR lpszLongPath,
if (!PathLength) goto Quickie;
LongPathUni.MaximumLength = PathLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
LongPathUni.MaximumLength = (USHORT)PathLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
ShortPathUni.Buffer = ShortPath;
ShortPathUni.Length = PathLength * sizeof(WCHAR);
ShortPathUni.Length = (USHORT)PathLength * sizeof(WCHAR);
Status = BasepUnicodeStringTo8BitString(&ShortPathAnsi, &ShortPathUni, TRUE);
if (!NT_SUCCESS(Status))
@ -2150,8 +2150,8 @@ GetCurrentDirectoryA(IN DWORD nBufferLength,
MaxLength = UNICODE_STRING_MAX_BYTES - 1;
}
StaticString->Length = RtlGetCurrentDirectory_U(StaticString->MaximumLength,
StaticString->Buffer);
StaticString->Length = (USHORT)RtlGetCurrentDirectory_U(StaticString->MaximumLength,
StaticString->Buffer);
Status = RtlUnicodeToMultiByteSize(&nBufferLength,
StaticString->Buffer,
StaticString->Length);
@ -2167,7 +2167,7 @@ GetCurrentDirectoryA(IN DWORD nBufferLength,
}
AnsiString.Buffer = lpBuffer;
AnsiString.MaximumLength = MaxLength;
AnsiString.MaximumLength = (USHORT)MaxLength;
Status = BasepUnicodeStringTo8BitString(&AnsiString, StaticString, FALSE);
if (!NT_SUCCESS(Status))
{

View file

@ -53,7 +53,7 @@ GetSystemPowerStatus(IN LPSYSTEM_POWER_STATUS PowerStatus)
{
if (Current <= Max)
{
PowerStatus->BatteryLifePercent = (100 * Current + Max / 2) / Max;
PowerStatus->BatteryLifePercent = (UCHAR)((100 * Current + Max / 2) / Max);
}
else
{

View file

@ -102,7 +102,7 @@ BuildSubSysCommandLine(IN LPCWSTR SubsystemName,
/* Allocate buffer for the output string */
Length = CommandLineString.MaximumLength + ApplicationNameString.MaximumLength + 32;
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
RtlInitEmptyUnicodeString(SubsysCommandLine, Buffer, Length);
RtlInitEmptyUnicodeString(SubsysCommandLine, Buffer, (USHORT)Length);
if (!Buffer)
{
/* Fail, no memory */
@ -2295,7 +2295,8 @@ CreateProcessInternalW(IN HANDLE hUserToken,
SECTION_IMAGE_INFORMATION ImageInformation;
IO_STATUS_BLOCK IoStatusBlock;
CLIENT_ID ClientId;
ULONG NoWindow, RegionSize, StackSize, ImageMachine, ErrorCode, Flags;
ULONG NoWindow, RegionSize, StackSize, ErrorCode, Flags;
USHORT ImageMachine;
ULONG ParameterFlags, PrivilegeValue, HardErrorMode, ErrorResponse;
ULONG_PTR ErrorParameters[2];
BOOLEAN InJob, SaferNeeded, UseLargePages, HavePrivilege;
@ -2576,7 +2577,7 @@ CreateProcessInternalW(IN HANDLE hUserToken,
}
/* Use the allocated size and convert */
UnicodeEnv.MaximumLength = RegionSize;
UnicodeEnv.MaximumLength = (USHORT)RegionSize;
Status = RtlAnsiStringToUnicodeString(&UnicodeEnv, &AnsiEnv, FALSE);
if (!NT_SUCCESS(Status))
{
@ -3784,7 +3785,7 @@ StartScan:
/* Set the length */
RtlInitEmptyUnicodeString(&DebuggerString,
DebuggerString.Buffer,
n);
(USHORT)n);
/* Now perform the command line creation */
ImageDbgStatus = RtlAppendUnicodeToString(&DebuggerString,

View file

@ -920,7 +920,7 @@ WINAPI
SetThreadUILanguage(IN LANGID LangId)
{
UNIMPLEMENTED;
return NtCurrentTeb()->CurrentLocale;
return (LANGID)NtCurrentTeb()->CurrentLocale;
}
/*

View file

@ -531,7 +531,7 @@ GetSystemTimes(OUT LPFILETIME lpIdleTime OPTIONAL,
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION ProcPerfInfo;
LARGE_INTEGER TotalUserTime, TotalKernTime, TotalIdleTime;
SIZE_T BufferSize, ReturnLength;
ULONG i;
CCHAR i;
NTSTATUS Status;
TotalUserTime.QuadPart = TotalKernTime.QuadPart = TotalIdleTime.QuadPart = 0;

View file

@ -382,8 +382,8 @@ BaseCreateVDMEnvironment(IN PWCHAR lpEnvironment,
/* Initialize the unicode string to hold it */
EnvironmentSize = (p - NewEnvironment) * sizeof(WCHAR);
RtlInitEmptyUnicodeString(UnicodeEnv, NewEnvironment, EnvironmentSize);
UnicodeEnv->Length = EnvironmentSize;
RtlInitEmptyUnicodeString(UnicodeEnv, NewEnvironment, (USHORT)EnvironmentSize);
UnicodeEnv->Length = (USHORT)EnvironmentSize;
/* Create the ASCII version of it */
Status = RtlUnicodeStringToAnsiString(AnsiEnv, UnicodeEnv, TRUE);

View file

@ -212,7 +212,7 @@ static LPCWSTR format_insert( BOOL unicode_caller, int insert, LPCWSTR format,
(unicode_caller && format[0] == 'C') ||
(!unicode_caller && format[0] == 'c'))
{
char ch = arg;
char ch = (char)arg;
wstring = HeapAlloc( GetProcessHeap(), 0, 2 * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, &ch, 1, wstring, 1 );
wstring[1] = 0;
@ -446,9 +446,9 @@ DWORD WINAPI FormatMessageA(
else if (dwFlags & (FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM))
{
if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE)
from = load_message( (HMODULE)lpSource, dwMessageId, dwLanguageId );
from = load_message( (HMODULE)lpSource, dwMessageId, (WORD)dwLanguageId );
if (!from && (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM))
from = load_message( kernel32_handle, dwMessageId, dwLanguageId );
from = load_message( kernel32_handle, dwMessageId, (WORD)dwLanguageId );
if (!from) return 0;
}
else
@ -549,9 +549,9 @@ DWORD WINAPI FormatMessageW(
else if (dwFlags & (FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM))
{
if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE)
from = load_message( (HMODULE)lpSource, dwMessageId, dwLanguageId );
from = load_message( (HMODULE)lpSource, dwMessageId, (WORD)dwLanguageId );
if (!from && (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM))
from = load_message( kernel32_handle, dwMessageId, dwLanguageId );
from = load_message( kernel32_handle, dwMessageId, (WORD)dwLanguageId );
if (!from) return 0;
}
else

View file

@ -551,10 +551,10 @@ IntMultiByteToWideCharCP(UINT CodePage,
static
INT
WINAPI
IntMultiByteToWideCharSYMBOL(DWORD Flags,
WINAPI
IntMultiByteToWideCharSYMBOL(DWORD Flags,
LPCSTR MultiByteString,
INT MultiByteCount,
INT MultiByteCount,
LPWSTR WideCharString,
INT WideCharCount)
{
@ -569,7 +569,7 @@ IntMultiByteToWideCharSYMBOL(DWORD Flags,
return 0;
}
if (WideCharCount == 0)
if (WideCharCount == 0)
{
return MultiByteCount;
}
@ -588,7 +588,7 @@ IntMultiByteToWideCharSYMBOL(DWORD Flags,
WideCharString[Count] = Char + 0xf000;
}
}
if (MultiByteCount > WideCharMaxLen)
if (MultiByteCount > WideCharMaxLen)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return 0;
@ -624,7 +624,7 @@ IntWideCharToMultiByteSYMBOL(DWORD Flags,
}
if (MultiByteCount == 0)
if (MultiByteCount == 0)
{
return WideCharCount;
}
@ -635,11 +635,11 @@ IntWideCharToMultiByteSYMBOL(DWORD Flags,
Char = WideCharString[Count];
if (Char < 0x20)
{
MultiByteString[Count] = Char;
MultiByteString[Count] = (CHAR)Char;
}
else
else
{
if ((Char>=0xf020)&&(Char<0xf100))
if ((Char >= 0xf020) && (Char < 0xf100))
{
MultiByteString[Count] = Char - 0xf000;
}
@ -650,7 +650,8 @@ IntWideCharToMultiByteSYMBOL(DWORD Flags,
}
}
}
if (WideCharCount > MaxLen)
if (WideCharCount > MaxLen)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return 0;
@ -1013,7 +1014,7 @@ IntWideCharToMultiByteCP(UINT CodePage,
if (DefaultChar)
DefChar = *DefaultChar;
else
DefChar = CodePageTable->TransDefaultChar;
DefChar = (CHAR)CodePageTable->TransDefaultChar;
/* Convert the WideCharString to the MultiByteString and verify if the mapping is valid */
for (TempLength = MultiByteCount;
@ -1259,16 +1260,16 @@ IsValidCodePage(UINT CodePage)
return GetCPFileNameFromRegistry(CodePage, NULL, 0);
}
static const signed char
base64inv[] =
static const signed char
base64inv[] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
};
@ -1334,7 +1335,7 @@ static INT Utf7ToWideCharSize(LPCSTR pszUtf7, INT cchUtf7)
}
cchUtf7--;
pch = pszUtf7;
while(cchUtf7 > 0 && (BYTE) *pszUtf7 < 0x80 &&
while(cchUtf7 > 0 && (BYTE) *pszUtf7 < 0x80 &&
base64inv[*pszUtf7] >= 0)
{
cchUtf7--;
@ -1390,7 +1391,7 @@ static INT Utf7ToWideChar(LPCSTR pszUtf7, INT cchUtf7, LPWSTR pszWide, INT cchWi
}
cchUtf7--;
pch = pszUtf7;
while(cchUtf7 > 0 && (BYTE) *pszUtf7 < 0x80 &&
while(cchUtf7 > 0 && (BYTE) *pszUtf7 < 0x80 &&
base64inv[*pszUtf7] >= 0)
{
cchUtf7--;
@ -2166,5 +2167,5 @@ GetNLSVersion(IN NLS_FUNCTION Function,
STUB;
return TRUE;
}
/* EOF */