From 660ad50bae6fa7415cdd391c5d58cd414aa25c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 17 Jan 2016 01:29:43 +0000 Subject: [PATCH] [MKHIVE] - Fix two warnings in GCC Linux build (in KeBugCheckEx and in a call to the helper function RepGetValueData). - Remove two unused RTL ANSI functions. - Fix USHORT vs. ULONG type misuage. - Fix SIZE_T vs. ULONG usage. svn path=/trunk/; revision=70603 --- reactos/tools/mkhive/mkhive.h | 17 ++------- reactos/tools/mkhive/reginf.c | 18 ++++----- reactos/tools/mkhive/registry.c | 14 +++---- reactos/tools/mkhive/rtl.c | 67 +-------------------------------- 4 files changed, 22 insertions(+), 94 deletions(-) diff --git a/reactos/tools/mkhive/mkhive.h b/reactos/tools/mkhive/mkhive.h index 02f623c06b7..519ee91758c 100644 --- a/reactos/tools/mkhive/mkhive.h +++ b/reactos/tools/mkhive/mkhive.h @@ -57,15 +57,6 @@ typedef DWORD REGSAM; typedef LPVOID LPSECURITY_ATTRIBUTES; typedef HANDLE HKEY, *PHKEY; -NTSTATUS NTAPI -RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING UniDest, - IN PANSI_STRING AnsiSource, - IN BOOLEAN AllocateDestinationString); -VOID NTAPI -RtlInitAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCSTR SourceString); VOID NTAPI RtlInitUnicodeString( IN OUT PUNICODE_STRING DestinationString, @@ -79,9 +70,9 @@ RegQueryValueExW( IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, - OUT PULONG lpType, - OUT PUCHAR lpData, - OUT PSIZE_T lpcbData); + OUT PULONG lpType OPTIONAL, + OUT PUCHAR lpData OPTIONAL, + IN OUT PULONG lpcbData OPTIONAL); LONG WINAPI RegSetValueExW( @@ -90,7 +81,7 @@ RegSetValueExW( IN ULONG Reserved, IN ULONG dwType, IN const UCHAR* lpData, - IN USHORT cbData); + IN ULONG cbData); LONG WINAPI RegDeleteKeyW( diff --git a/reactos/tools/mkhive/reginf.c b/reactos/tools/mkhive/reginf.c index 6be3e0f4f5f..7783d94c12e 100644 --- a/reactos/tools/mkhive/reginf.c +++ b/reactos/tools/mkhive/reginf.c @@ -119,11 +119,11 @@ AppendMultiSzValue ( IN HKEY KeyHandle, IN PWCHAR ValueName, IN PWCHAR Strings, - IN SIZE_T StringSize) + IN ULONG StringSize) { - SIZE_T Size; + ULONG Size; ULONG Type; - size_t Total; + ULONG Total; PWCHAR Buffer; PWCHAR p; size_t len; @@ -182,7 +182,7 @@ AppendMultiSzValue ( 0, REG_MULTI_SZ, (PUCHAR)Buffer, - (ULONG)Total * sizeof(WCHAR)); + Total * sizeof(WCHAR)); } done: @@ -289,7 +289,7 @@ do_reg_operation( if (Str == NULL) return FALSE; - InfHostGetMultiSzField (Context, 5, Str, (ULONG)Size, NULL); + InfHostGetMultiSzField (Context, 5, Str, Size, NULL); } if (Flags & FLG_ADDREG_APPEND) @@ -319,7 +319,7 @@ do_reg_operation( if (Str == NULL) return FALSE; - InfHostGetStringField (Context, 5, Str, (ULONG)Size, NULL); + InfHostGetStringField (Context, 5, Str, Size, NULL); } } @@ -349,7 +349,7 @@ do_reg_operation( 0, Type, (PVOID)Str, - (ULONG)Size * sizeof(WCHAR)); + Size * sizeof(WCHAR)); } else { @@ -359,7 +359,7 @@ do_reg_operation( 0, Type, (PVOID)&EmptyStr, - (ULONG)sizeof(WCHAR)); + sizeof(WCHAR)); } } free (Str); @@ -387,7 +387,7 @@ do_reg_operation( 0, Type, (PVOID)Data, - (ULONG)Size); + Size); free (Data); } diff --git a/reactos/tools/mkhive/registry.c b/reactos/tools/mkhive/registry.c index 0c678b08adf..91f93d48d78 100644 --- a/reactos/tools/mkhive/registry.c +++ b/reactos/tools/mkhive/registry.c @@ -518,7 +518,7 @@ RegSetValueExW( IN ULONG Reserved, IN ULONG dwType, IN const UCHAR* lpData, - IN USHORT cbData) + IN ULONG cbData) { PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey PHHIVE Hive; @@ -528,7 +528,7 @@ RegSetValueExW( UNICODE_STRING ValueNameString; PVOID DataCell; - LONG DataCellSize; + ULONG DataCellSize; NTSTATUS Status; if (dwType == REG_LINK) @@ -597,7 +597,7 @@ RegSetValueExW( if (!DataCell) return ERROR_UNSUCCESSFUL; - DataCellSize = -HvGetCellSize(Hive, DataCell); + DataCellSize = (ULONG)(-HvGetCellSize(Hive, DataCell)); } else { @@ -613,12 +613,12 @@ RegSetValueExW( HvFreeCell(Hive, ValueCell->Data); RtlCopyMemory(&ValueCell->Data, lpData, cbData); - ValueCell->DataLength = (ULONG)(cbData | CM_KEY_VALUE_SPECIAL_SIZE); + ValueCell->DataLength = (cbData | CM_KEY_VALUE_SPECIAL_SIZE); ValueCell->Type = dwType; } else { - if (cbData > (SIZE_T)DataCellSize) + if (cbData > DataCellSize) { /* New data size is larger than the current, destroy current * data block and allocate a new one. */ @@ -642,7 +642,7 @@ RegSetValueExW( /* Copy new contents to cell */ RtlCopyMemory(DataCell, lpData, cbData); - ValueCell->DataLength = (ULONG)(cbData & ~CM_KEY_VALUE_SPECIAL_SIZE); + ValueCell->DataLength = (cbData & ~CM_KEY_VALUE_SPECIAL_SIZE); ValueCell->Type = dwType; HvMarkCellDirty(Hive, ValueCell->Data, FALSE); } @@ -712,7 +712,7 @@ RegQueryValueExW( IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, - IN OUT PSIZE_T lpcbData OPTIONAL) + IN OUT PULONG lpcbData OPTIONAL) { PMEMKEY ParentKey = HKEY_TO_MEMKEY(hKey); PHHIVE Hive = &ParentKey->RegistryHive->Hive; diff --git a/reactos/tools/mkhive/rtl.c b/reactos/tools/mkhive/rtl.c index 4275cf358ba..f2c84c7fdec 100644 --- a/reactos/tools/mkhive/rtl.c +++ b/reactos/tools/mkhive/rtl.c @@ -17,34 +17,6 @@ #include "mkhive.h" #include -/* - * @implemented - * - * NOTES - * If source is NULL the length of source is assumed to be 0. - */ -VOID NTAPI -RtlInitAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCSTR SourceString) -{ - SIZE_T DestSize; - - if(SourceString) - { - DestSize = strlen(SourceString); - DestinationString->Length = (USHORT)DestSize; - DestinationString->MaximumLength = (USHORT)DestSize + sizeof(CHAR); - } - else - { - DestinationString->Length = 0; - DestinationString->MaximumLength = 0; - } - - DestinationString->Buffer = (PCHAR)SourceString; -} - /* * @implemented * @@ -73,41 +45,6 @@ RtlInitUnicodeString( DestinationString->Buffer = (PWCHAR)SourceString; } -NTSTATUS NTAPI -RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING UniDest, - IN PANSI_STRING AnsiSource, - IN BOOLEAN AllocateDestinationString) -{ - ULONG Length; - PUCHAR WideString; - USHORT i; - - Length = AnsiSource->Length * sizeof(WCHAR); - if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; - UniDest->Length = (USHORT)Length; - - if (AllocateDestinationString) - { - UniDest->MaximumLength = (USHORT)Length + sizeof(WCHAR); - UniDest->Buffer = (PWSTR) malloc(UniDest->MaximumLength); - if (!UniDest->Buffer) - return STATUS_NO_MEMORY; - } - else if (UniDest->Length >= UniDest->MaximumLength) - { - return STATUS_BUFFER_OVERFLOW; - } - - WideString = (PUCHAR)UniDest->Buffer; - for (i = 0; i <= AnsiSource->Length; i++) - { - WideString[2 * i + 0] = AnsiSource->Buffer[i]; - WideString[2 * i + 1] = 0; - } - return STATUS_SUCCESS; -} - LONG NTAPI RtlCompareUnicodeString( IN PCUNICODE_STRING String1, @@ -222,14 +159,14 @@ RtlAssert(PVOID FailedAssertion, VOID NTAPI KeBugCheckEx( - IN ULONG BugCheckCode, + IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4) { char Buffer[70]; - printf("*** STOP: 0x%08lX (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", + printf("*** STOP: 0x%08X (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", BugCheckCode, BugCheckParameter1, BugCheckParameter2, BugCheckParameter3, BugCheckParameter4); ASSERT(FALSE);