Fix some MSVC warnings (type conversions).

Ready for merging (TM) :)

svn path=/branches/ros-csrss/; revision=58758
This commit is contained in:
Hermès Bélusca-Maïto 2013-04-14 16:04:46 +00:00
parent f51caa6299
commit ddfa887b86
9 changed files with 71 additions and 75 deletions

View file

@ -456,7 +456,7 @@ BaseInitializeStaticServerData(IN PCSR_SERVER_DLL LoadedServerDll)
sizeof(LuidEnabled),
NULL);
ASSERT(NT_SUCCESS(Status));
BaseStaticServerData->LUIDDeviceMapsEnabled = LuidEnabled;
BaseStaticServerData->LUIDDeviceMapsEnabled = (BOOLEAN)LuidEnabled;
if (!BaseStaticServerData->LUIDDeviceMapsEnabled)
{
/* Make Global point back to BNO */

View file

@ -568,7 +568,7 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
if (Console->LineBuffer == NULL)
{
/* Starting a new line */
Console->LineMaxSize = max(256, nNumberOfCharsToRead);
Console->LineMaxSize = (WORD)max(256, nNumberOfCharsToRead);
Console->LineBuffer = RtlAllocateHeap(ConSrvHeap, 0, Console->LineMaxSize * sizeof(WCHAR));
if (Console->LineBuffer == NULL)
{

View file

@ -60,13 +60,13 @@ static VOID FASTCALL
ClearLineBuffer(PCONSOLE_SCREEN_BUFFER Buff)
{
PBYTE Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
UINT Pos;
SHORT Pos;
for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++)
{
/* Fill the cell */
*Ptr++ = ' ';
*Ptr++ = Buff->ScreenDefaultAttrib;
*Ptr++ = (BYTE)Buff->ScreenDefaultAttrib;
}
}
@ -155,7 +155,7 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
UINT i;
PBYTE Ptr;
SMALL_RECT UpdateRect;
LONG CursorStartX, CursorStartY;
SHORT CursorStartX, CursorStartY;
UINT ScrolledLines;
CursorStartX = Buff->CursorPosition.X;
@ -178,8 +178,8 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
if (Buffer[i] == '\r')
{
Buff->CursorPosition.X = 0;
UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CursorPosition.X);
UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
continue;
}
/* --- LF --- */
@ -200,7 +200,7 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
/* slide virtual position up */
Buff->CursorPosition.X = Buff->ScreenBufferSize.X - 1;
Buff->CursorPosition.Y--;
UpdateRect.Top = min(UpdateRect.Top, (LONG)Buff->CursorPosition.Y);
UpdateRect.Top = min(UpdateRect.Top, Buff->CursorPosition.Y);
}
else
{
@ -208,9 +208,9 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
}
Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Ptr[0] = ' ';
Ptr[1] = Buff->ScreenDefaultAttrib;
UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CursorPosition.X);
Ptr[1] = (BYTE)Buff->ScreenDefaultAttrib;
UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
}
continue;
}
@ -219,17 +219,17 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
{
UINT EndX;
UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CursorPosition.X);
UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
EndX = (Buff->CursorPosition.X + TAB_WIDTH) & ~(TAB_WIDTH - 1);
EndX = min(EndX, Buff->ScreenBufferSize.X);
EndX = min(EndX, (UINT)Buff->ScreenBufferSize.X);
Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
while (Buff->CursorPosition.X < EndX)
{
*Ptr++ = ' ';
*Ptr++ = Buff->ScreenDefaultAttrib;
*Ptr++ = (BYTE)Buff->ScreenDefaultAttrib;
Buff->CursorPosition.X++;
}
UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CursorPosition.X - 1);
UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X - 1);
if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
{
if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
@ -253,13 +253,13 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
// continue;
// }
}
UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CursorPosition.X);
UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Ptr[0] = Buffer[i];
if (Attrib)
{
Ptr[1] = Buff->ScreenDefaultAttrib;
Ptr[1] = (BYTE)Buff->ScreenDefaultAttrib;
}
Buff->CursorPosition.X++;
if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
@ -278,8 +278,8 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
if (!ConioIsRectEmpty(&UpdateRect) && Buff == Console->ActiveBuffer)
{
ConioWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY, ScrolledLines,
Buffer, Length);
ConioWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY,
ScrolledLines, Buffer, Length);
}
return STATUS_SUCCESS;
@ -466,7 +466,7 @@ ConioResizeBuffer(PCONSOLE Console,
for (i = 0; i < diff; i++)
{
Buffer[Offset++] = ' ';
Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
Buffer[Offset++] = (BYTE)ScreenBuffer->ScreenDefaultAttrib;
}
#endif
}
@ -481,7 +481,7 @@ ConioResizeBuffer(PCONSOLE Console,
for (i = 0; i < diff; i++)
{
Buffer[Offset++] = ' ';
Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
Buffer[Offset++] = (BYTE)ScreenBuffer->ScreenDefaultAttrib;
}
#endif
}
@ -730,7 +730,7 @@ CSR_API(SrvReadConsoleOutput)
PCHAR_INFO CharInfo;
PCHAR_INFO CurCharInfo;
PCONSOLE_SCREEN_BUFFER Buff;
DWORD SizeX, SizeY;
SHORT SizeX, SizeY;
NTSTATUS Status;
COORD BufferSize;
COORD BufferCoord;
@ -905,7 +905,7 @@ CSR_API(SrvWriteConsoleOutput)
AsciiChar = CurCharInfo->Char.AsciiChar;
}
*Ptr++ = AsciiChar;
*Ptr++ = CurCharInfo->Attributes;
*Ptr++ = (BYTE)CurCharInfo->Attributes;
CurCharInfo++;
}
}
@ -929,7 +929,7 @@ CSR_API(SrvReadConsoleOutputString)
PCONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
USHORT CodeType;
DWORD Xpos, Ypos;
SHORT Xpos, Ypos;
PVOID ReadBuffer;
DWORD i;
ULONG CodeSize;
@ -1324,8 +1324,8 @@ CSR_API(SrvSetConsoleCursorPosition)
PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorPositionRequest;
PCONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
LONG OldCursorX, OldCursorY;
LONG NewCursorX, NewCursorY;
SHORT OldCursorX, OldCursorY;
SHORT NewCursorX, NewCursorY;
DPRINT("SrvSetConsoleCursorPosition\n");

View file

@ -523,7 +523,7 @@ ConSrvInitConsole(OUT PCONSOLE* NewConsole,
*/
if (ConsoleStartInfo->dwStartupFlags & STARTF_USEFILLATTRIBUTE)
{
ConsoleInfo.ScreenAttrib = ConsoleStartInfo->FillAttribute;
ConsoleInfo.ScreenAttrib = (USHORT)ConsoleStartInfo->FillAttribute;
}
if (ConsoleStartInfo->dwStartupFlags & STARTF_USECOUNTCHARS)
{

View file

@ -595,11 +595,7 @@ GuiConsolePaint(PCONSOLE Console,
}
MultiByteToWideChar(Console->OutputCodePage,
0,
(PCHAR)From,
1,
To,
1);
0, (PCHAR)From, 1, To, 1);
To++;
From += 2;
}
@ -611,13 +607,14 @@ GuiConsolePaint(PCONSOLE Console,
RightChar - Start + 1);
}
if (Buff->CursorInfo.bVisible && Buff->CursorBlinkOn &&
!Buff->ForceCursorOff)
if (Buff->CursorInfo.bVisible &&
Buff->CursorBlinkOn &&
!Buff->ForceCursorOff)
{
CursorX = Buff->CursorPosition.X;
CursorY = Buff->CursorPosition.Y;
if (LeftChar <= CursorX && CursorX <= RightChar &&
TopLine <= CursorY && CursorY <= BottomLine)
TopLine <= CursorY && CursorY <= BottomLine)
{
CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight);
From = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y) + 1;
@ -836,7 +833,7 @@ GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM l
}
static VOID
GuiInvalidateCell(PCONSOLE Console, UINT x, UINT y)
GuiInvalidateCell(PCONSOLE Console, SHORT x, SHORT y)
{
SMALL_RECT CellRect = { x, y, x, y };
GuiDrawRegion(Console, &CellRect);
@ -971,8 +968,8 @@ PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
COORD Coord;
Coord.X = Buffer->ShowX + ((short)LOWORD(lParam) / (int)GuiData->CharWidth);
Coord.Y = Buffer->ShowY + ((short)HIWORD(lParam) / (int)GuiData->CharHeight);
Coord.X = Buffer->ShowX + ((SHORT)LOWORD(lParam) / (int)GuiData->CharWidth);
Coord.Y = Buffer->ShowY + ((SHORT)HIWORD(lParam) / (int)GuiData->CharHeight);
/* Clip coordinate to ensure it's inside buffer */
if (Coord.X < 0)
@ -2029,12 +2026,12 @@ GuiCleanupConsole(PCONSOLE Console)
}
static VOID WINAPI
GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG CursorStartY,
GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, SHORT CursorStartX, SHORT CursorStartY,
UINT ScrolledLines, CHAR *Buffer, UINT Length)
{
PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
PCONSOLE_SCREEN_BUFFER Buff = Console->ActiveBuffer;
LONG CursorEndX, CursorEndY;
SHORT CursorEndX, CursorEndY;
RECT ScrollRect;
if (NULL == GuiData || NULL == GuiData->hWindow)
@ -2104,7 +2101,7 @@ GuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
}
static BOOL WINAPI
GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT OldCursorY)
GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, SHORT OldCursorX, SHORT OldCursorY)
{
if (Console->ActiveBuffer == Buff)
{

View file

@ -480,7 +480,7 @@ TuiCleanupConsole(PCONSOLE Console)
}
static VOID WINAPI
TuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG CursorStartY,
TuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, SHORT CursorStartX, SHORT CursorStartY,
UINT ScrolledLines, CHAR *Buffer, UINT Length)
{
DWORD BytesWritten;
@ -554,7 +554,7 @@ TuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
}
static BOOL WINAPI
TuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT OldCursorY)
TuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, SHORT OldCursorX, SHORT OldCursorY)
{
CONSOLE_SCREEN_BUFFER_INFO Info;
DWORD BytesReturned;

View file

@ -93,8 +93,8 @@ typedef struct _FRONTEND_VTBL
VOID (WINAPI *CleanupConsole)(struct _CONSOLE* Console);
VOID (WINAPI *WriteStream)(struct _CONSOLE* Console,
SMALL_RECT* Block,
LONG CursorStartX,
LONG CursorStartY,
SHORT CursorStartX,
SHORT CursorStartY,
UINT ScrolledLines,
CHAR *Buffer,
UINT Length);
@ -104,8 +104,8 @@ typedef struct _FRONTEND_VTBL
PCONSOLE_SCREEN_BUFFER ScreenBuffer);
BOOL (WINAPI *SetScreenInfo)(struct _CONSOLE* Console,
PCONSOLE_SCREEN_BUFFER ScreenBuffer,
UINT OldCursorX,
UINT OldCursorY);
SHORT OldCursorX,
SHORT OldCursorY);
BOOL (WINAPI *UpdateScreenInfo)(struct _CONSOLE* Console,
PCONSOLE_SCREEN_BUFFER ScreenBuffer);
BOOL (WINAPI *IsBufferResizeSupported)(struct _CONSOLE* Console);

View file

@ -67,15 +67,14 @@ static VOID
HistoryAddEntry(PCONSOLE Console)
{
UNICODE_STRING NewEntry;
PHISTORY_BUFFER Hist;
PHISTORY_BUFFER Hist = HistoryCurrentBuffer(Console);
INT i;
if (!Hist) return;
NewEntry.Length = NewEntry.MaximumLength = Console->LineSize * sizeof(WCHAR);
NewEntry.Buffer = Console->LineBuffer;
if (!(Hist = HistoryCurrentBuffer(Console)))
return;
/* Don't add blank or duplicate entries */
if (NewEntry.Length == 0 || Hist->MaxEntries == 0 ||
(Hist->NumEntries > 0 &&
@ -118,8 +117,9 @@ HistoryAddEntry(PCONSOLE Console)
static VOID
HistoryGetCurrentEntry(PCONSOLE Console, PUNICODE_STRING Entry)
{
PHISTORY_BUFFER Hist;
if (!(Hist = HistoryCurrentBuffer(Console)) || Hist->NumEntries == 0)
PHISTORY_BUFFER Hist = HistoryCurrentBuffer(Console);
if (!Hist || Hist->NumEntries == 0)
Entry->Length = 0;
else
*Entry = Hist->Entries[Hist->Position];
@ -173,8 +173,8 @@ LineInputSetPos(PCONSOLE Console, UINT Pos)
if (Pos != Console->LinePos && Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
{
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
UINT OldCursorX = Buffer->CursorPosition.X;
UINT OldCursorY = Buffer->CursorPosition.Y;
SHORT OldCursorX = Buffer->CursorPosition.X;
SHORT OldCursorY = Buffer->CursorPosition.Y;
INT XY = OldCursorY * Buffer->ScreenBufferSize.X + OldCursorX;
XY += (Pos - Console->LinePos);
@ -196,7 +196,7 @@ LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Inser
{
UINT Pos = Console->LinePos;
UINT NewSize = Console->LineSize - NumToDelete + NumToInsert;
INT i;
UINT i;
/* Make sure there's always enough room for ending \r\n */
if (NewSize + 2 > Console->LineMaxSize)
@ -231,20 +231,19 @@ LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Inser
static VOID
LineInputRecallHistory(PCONSOLE Console, INT Offset)
{
PHISTORY_BUFFER Hist;
PHISTORY_BUFFER Hist = HistoryCurrentBuffer(Console);
UINT Position = 0;
if (!(Hist = HistoryCurrentBuffer(Console)) || Hist->NumEntries == 0)
return;
if (!Hist || Hist->NumEntries == 0) return;
Offset += Hist->Position;
Offset = max(Offset, 0);
Offset = min(Offset, Hist->NumEntries - 1);
Hist->Position = Offset;
Position = Hist->Position + Offset;
Position = min(max(Position, 0), Hist->NumEntries - 1);
Hist->Position = Position;
LineInputSetPos(Console, 0);
LineInputEdit(Console, Console->LineSize,
Hist->Entries[Offset].Length / sizeof(WCHAR),
Hist->Entries[Offset].Buffer);
Hist->Entries[Hist->Position].Length / sizeof(WCHAR),
Hist->Entries[Hist->Position].Buffer);
}
VOID FASTCALL
@ -357,8 +356,8 @@ LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
return;
case VK_F8:
/* Search for history entries starting with input. */
if (!(Hist = HistoryCurrentBuffer(Console)) || Hist->NumEntries == 0)
return;
Hist = HistoryCurrentBuffer(Console);
if (!Hist || Hist->NumEntries == 0) return;
/* Like Up/F5, on first time start from current (usually last) entry,
* but on subsequent times start at previous entry. */
@ -455,7 +454,7 @@ CSR_API(SrvGetConsoleCommandHistory)
PHISTORY_BUFFER Hist;
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
ULONG BufferSize = GetCommandHistoryRequest->Length;
INT i;
UINT i;
if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&GetCommandHistoryRequest->History,
@ -502,7 +501,7 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
NTSTATUS Status;
PHISTORY_BUFFER Hist;
ULONG Length = 0;
INT i;
UINT i;
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&GetCommandHistoryLengthRequest->ExeName.Buffer,

View file

@ -268,7 +268,7 @@ ConSrvReadUserSettings(IN OUT PCONSOLE_INFO ConsoleInfo,
}
else if (!wcscmp(szValueName, L"HistoryNoDup"))
{
ConsoleInfo->HistoryNoDup = Value;
ConsoleInfo->HistoryNoDup = (BOOLEAN)Value;
RetVal = TRUE;
}
else if (!wcscmp(szValueName, L"FullScreen"))
@ -278,12 +278,12 @@ ConSrvReadUserSettings(IN OUT PCONSOLE_INFO ConsoleInfo,
}
else if (!wcscmp(szValueName, L"QuickEdit"))
{
ConsoleInfo->QuickEdit = Value;
ConsoleInfo->QuickEdit = (BOOLEAN)Value;
RetVal = TRUE;
}
else if (!wcscmp(szValueName, L"InsertMode"))
{
ConsoleInfo->InsertMode = Value;
ConsoleInfo->InsertMode = (BOOLEAN)Value;
RetVal = TRUE;
}
else if (!wcscmp(szValueName, L"ScreenBufferSize"))
@ -305,12 +305,12 @@ ConSrvReadUserSettings(IN OUT PCONSOLE_INFO ConsoleInfo,
}
else if (!wcscmp(szValueName, L"ScreenColors"))
{
ConsoleInfo->ScreenAttrib = Value;
ConsoleInfo->ScreenAttrib = (USHORT)Value;
RetVal = TRUE;
}
else if (!wcscmp(szValueName, L"PopupColors"))
{
ConsoleInfo->PopupAttrib = Value;
ConsoleInfo->PopupAttrib = (USHORT)Value;
RetVal = TRUE;
}
}