From e3a5ed0e2b29fabb06d7f3c4453cb540469a22e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 4 Aug 2014 17:13:43 +0000 Subject: [PATCH 1/1] [KERNEL32][CONSRV] Fix few MSVC dword -> short warnings (basically). Thanks GCC for not having noticed them... svn path=/branches/condrv_restructure/; revision=63804 --- dll/win32/kernel32/client/console/alias.c | 64 ++++++++++----------- dll/win32/kernel32/client/console/console.c | 4 +- dll/win32/kernel32/client/console/history.c | 30 +++++----- include/reactos/subsys/win/conmsg.h | 2 +- win32ss/user/winsrv/consrv/include/conio.h | 6 +- 5 files changed, 52 insertions(+), 54 deletions(-) diff --git a/dll/win32/kernel32/client/console/alias.c b/dll/win32/kernel32/client/console/alias.c index fce0eb21c61..a949c75cb6b 100644 --- a/dll/win32/kernel32/client/console/alias.c +++ b/dll/win32/kernel32/client/console/alias.c @@ -20,9 +20,9 @@ static BOOL IntAddConsoleAlias(LPCVOID Source, - DWORD SourceBufferLength, + USHORT SourceBufferLength, LPCVOID Target, - DWORD TargetBufferLength, + USHORT TargetBufferLength, LPCVOID lpExeName, BOOLEAN bUnicode) { @@ -31,9 +31,9 @@ IntAddConsoleAlias(LPCVOID Source, PCSR_CAPTURE_BUFFER CaptureBuffer; ULONG CapturedStrings; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -43,7 +43,7 @@ IntAddConsoleAlias(LPCVOID Source, /* Determine the needed sizes */ ConsoleAliasRequest->SourceLength = SourceBufferLength; - ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + ConsoleAliasRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); ConsoleAliasRequest->Unicode = ConsoleAliasRequest->Unicode2 = bUnicode; @@ -120,9 +120,8 @@ AddConsoleAliasW(LPCWSTR lpSource, LPCWSTR lpTarget, LPCWSTR lpExeName) { - DWORD SourceBufferLength, TargetBufferLength; - SourceBufferLength = wcslen(lpSource) * sizeof(WCHAR); - TargetBufferLength = (lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0); + USHORT SourceBufferLength = (USHORT)wcslen(lpSource) * sizeof(WCHAR); + USHORT TargetBufferLength = (USHORT)(lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0); DPRINT1("AddConsoleAliasW entered with lpSource '%S' lpTarget '%S' lpExeName '%S'\n", lpSource, lpTarget, lpExeName); @@ -145,9 +144,8 @@ AddConsoleAliasA(LPCSTR lpSource, LPCSTR lpTarget, LPCSTR lpExeName) { - DWORD SourceBufferLength, TargetBufferLength; - SourceBufferLength = strlen(lpSource) * sizeof(CHAR); - TargetBufferLength = (lpTarget ? strlen(lpTarget) * sizeof(CHAR) : 0); + USHORT SourceBufferLength = (USHORT)strlen(lpSource) * sizeof(CHAR); + USHORT TargetBufferLength = (USHORT)(lpTarget ? strlen(lpTarget) * sizeof(CHAR) : 0); DPRINT1("AddConsoleAliasA entered with lpSource '%s' lpTarget '%s' lpExeName '%s'\n", lpSource, lpTarget, lpExeName); @@ -163,9 +161,9 @@ AddConsoleAliasA(LPCSTR lpSource, static DWORD IntGetConsoleAlias(LPVOID Source, - DWORD SourceBufferLength, + USHORT SourceBufferLength, LPVOID Target, - DWORD TargetBufferLength, + USHORT TargetBufferLength, LPVOID lpExeName, BOOLEAN bUnicode) { @@ -173,7 +171,7 @@ IntGetConsoleAlias(LPVOID Source, PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); if (Source == NULL || Target == NULL) { @@ -181,7 +179,7 @@ IntGetConsoleAlias(LPVOID Source, return 0; } - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -191,7 +189,7 @@ IntGetConsoleAlias(LPVOID Source, /* Determine the needed sizes */ ConsoleAliasRequest->SourceLength = SourceBufferLength; - ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + ConsoleAliasRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); ConsoleAliasRequest->Unicode = ConsoleAliasRequest->Unicode2 = bUnicode; @@ -240,9 +238,9 @@ IntGetConsoleAlias(LPVOID Source, } /* Copy the returned target string into the user buffer */ - memcpy(Target, - ConsoleAliasRequest->Target, - ConsoleAliasRequest->TargetLength); + RtlCopyMemory(Target, + ConsoleAliasRequest->Target, + ConsoleAliasRequest->TargetLength); /* Release the capture buffer and exit */ CsrFreeCaptureBuffer(CaptureBuffer); @@ -265,7 +263,7 @@ GetConsoleAliasW(LPWSTR lpSource, lpSource, lpExeName); return IntGetConsoleAlias(lpSource, - wcslen(lpSource) * sizeof(WCHAR), + (USHORT)wcslen(lpSource) * sizeof(WCHAR), lpTargetBuffer, TargetBufferLength, lpExeName, @@ -287,7 +285,7 @@ GetConsoleAliasA(LPSTR lpSource, lpSource, lpExeName); return IntGetConsoleAlias(lpSource, - strlen(lpSource) * sizeof(CHAR), + (USHORT)strlen(lpSource) * sizeof(CHAR), lpTargetBuffer, TargetBufferLength, lpExeName, @@ -305,9 +303,9 @@ IntGetConsoleAliases(LPVOID AliasBuffer, PCONSOLE_GETALLALIASES GetAllAliasesRequest = &ApiMessage.Data.GetAllAliasesRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -316,7 +314,7 @@ IntGetConsoleAliases(LPVOID AliasBuffer, GetAllAliasesRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; /* Determine the needed sizes */ - GetAllAliasesRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + GetAllAliasesRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); GetAllAliasesRequest->Unicode = GetAllAliasesRequest->Unicode2 = bUnicode; @@ -354,9 +352,9 @@ IntGetConsoleAliases(LPVOID AliasBuffer, } /* Copy the returned aliases string into the user buffer */ - memcpy(AliasBuffer, - GetAllAliasesRequest->AliasesBuffer, - GetAllAliasesRequest->AliasesBufferLength); + RtlCopyMemory(AliasBuffer, + GetAllAliasesRequest->AliasesBuffer, + GetAllAliasesRequest->AliasesBufferLength); /* Release the capture buffer and exit */ CsrFreeCaptureBuffer(CaptureBuffer); @@ -410,16 +408,16 @@ IntGetConsoleAliasesLength(LPVOID lpExeName, BOOLEAN bUnicode) PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &ApiMessage.Data.GetAllAliasesLengthRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } GetAllAliasesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; - GetAllAliasesLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + GetAllAliasesLengthRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); GetAllAliasesLengthRequest->Unicode = GetAllAliasesLengthRequest->Unicode2 = bUnicode; @@ -511,9 +509,9 @@ IntGetConsoleAliasExes(PVOID lpExeNameBuffer, return 0; } - memcpy(lpExeNameBuffer, - GetAliasesExesRequest->ExeNames, - GetAliasesExesRequest->Length); + RtlCopyMemory(lpExeNameBuffer, + GetAliasesExesRequest->ExeNames, + GetAliasesExesRequest->Length); CsrFreeCaptureBuffer(CaptureBuffer); diff --git a/dll/win32/kernel32/client/console/console.c b/dll/win32/kernel32/client/console/console.c index 4d176c76b8d..7ce38ad3f78 100644 --- a/dll/win32/kernel32/client/console/console.c +++ b/dll/win32/kernel32/client/console/console.c @@ -1887,10 +1887,10 @@ IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode) PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0); + ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0); TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; - TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); TitleRequest->Unicode = bUnicode; CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length); diff --git a/dll/win32/kernel32/client/console/history.c b/dll/win32/kernel32/client/console/history.c index 76373ef2c49..2fc50245fb4 100644 --- a/dll/win32/kernel32/client/console/history.c +++ b/dll/win32/kernel32/client/console/history.c @@ -58,16 +58,16 @@ IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOLEAN bUnicode) PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return; } ExpungeCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; - ExpungeCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + ExpungeCommandHistoryRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); ExpungeCommandHistoryRequest->Unicode = ExpungeCommandHistoryRequest->Unicode2 = bUnicode; @@ -106,9 +106,9 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -116,7 +116,7 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName GetCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; GetCommandHistoryRequest->HistoryLength = cbHistory; - GetCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + GetCommandHistoryRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); GetCommandHistoryRequest->Unicode = GetCommandHistoryRequest->Unicode2 = bUnicode; @@ -153,9 +153,9 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName return 0; } - memcpy(lpHistory, - GetCommandHistoryRequest->History, - GetCommandHistoryRequest->HistoryLength); + RtlCopyMemory(lpHistory, + GetCommandHistoryRequest->History, + GetCommandHistoryRequest->HistoryLength); CsrFreeCaptureBuffer(CaptureBuffer); @@ -170,16 +170,16 @@ IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode) PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } GetCommandHistoryLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; - GetCommandHistoryLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + GetCommandHistoryLengthRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); GetCommandHistoryLengthRequest->Unicode = GetCommandHistoryLengthRequest->Unicode2 = bUnicode; @@ -225,9 +225,9 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands, PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); + USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0); - if (lpExeName == NULL || dwNumChars == 0) + if (lpExeName == NULL || NumChars == 0) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -235,7 +235,7 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands, SetHistoryNumberCommandsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; SetHistoryNumberCommandsRequest->NumCommands = dwNumCommands; - SetHistoryNumberCommandsRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + SetHistoryNumberCommandsRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); SetHistoryNumberCommandsRequest->Unicode = SetHistoryNumberCommandsRequest->Unicode2 = bUnicode; diff --git a/include/reactos/subsys/win/conmsg.h b/include/reactos/subsys/win/conmsg.h index 9a07d12e31f..56870f4e94e 100644 --- a/include/reactos/subsys/win/conmsg.h +++ b/include/reactos/subsys/win/conmsg.h @@ -422,7 +422,7 @@ typedef struct typedef struct { HANDLE ConsoleHandle; - DWORD Length; + ULONG Length; PVOID Title; BOOLEAN Unicode; } CONSOLE_GETSETCONSOLETITLE, *PCONSOLE_GETSETCONSOLETITLE; diff --git a/win32ss/user/winsrv/consrv/include/conio.h b/win32ss/user/winsrv/consrv/include/conio.h index b4e75fda666..c505c75d8c8 100644 --- a/win32ss/user/winsrv/consrv/include/conio.h +++ b/win32ss/user/winsrv/consrv/include/conio.h @@ -284,9 +284,9 @@ typedef struct _CONSOLE /** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/ PWCHAR LineBuffer; /* Current line being input, in line buffered mode */ - WORD LineMaxSize; /* Maximum size of line in characters (including CR+LF) */ - WORD LineSize; /* Current size of line */ - WORD LinePos; /* Current position within line */ + ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */ + ULONG LineSize; /* Current size of line */ + ULONG LinePos; /* Current position within line */ BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */ BOOLEAN LineUpPressed; BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */ -- 2.17.1