From cd616fb1b2af89ecc4f0483ad1d61badb6642361 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Thu, 23 Feb 2012 13:06:11 +0000 Subject: [PATCH] [CMAKE] - Specify C4700 (uninitialized variable usage) to cause an error on compile as this is very likely to result in broken code. [NTDLL] - Disable ASSERT in LdrpSearchPath that could be reading an uninitialized variable. The routine is not fully implemented so this should likely be re-enabled once it is. [BROWSEUI] - Add missing call to BuildRebarBandInfo, or we would end up with an unitialized variable sent to SendMessage. [PCIX] - Fix broken ASSERT - Fix usage of wrong (and uninitialized) variable in the Unicode case for PciGetDescriptionMessage. [DDK] - Prepend "_" to local variable of NdisChainBufferAtBack. Fixes code in ndisuio that called this using the same name as the macro's variable (which resulted in NdisChainBufferAtBack assigning the variable to itself). [WIN32K] - Fix WinPosShowIconTitle that checked if a variable was NULL before assigning it to anything. svn path=/trunk/; revision=55834 --- reactos/cmake/msvc.cmake | 3 +++ reactos/dll/ntdll/ldr/ldrutils.c | 2 ++ reactos/dll/win32/browseui/bandsite.cpp | 1 + reactos/drivers/bus/pcix/pci/id.c | 6 +++--- reactos/include/ddk/ndis.h | 10 +++++----- reactos/subsystems/win32/win32k/ntuser/winpos.c | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/reactos/cmake/msvc.cmake b/reactos/cmake/msvc.cmake index 4bd9b985f7a..e6a0b0d57ed 100644 --- a/reactos/cmake/msvc.cmake +++ b/reactos/cmake/msvc.cmake @@ -21,6 +21,9 @@ add_definitions(/Dinline=__inline /D__STDC__=1) add_compile_flags("/X /GR- /GS- /Zl /W3") +# C4700 is almost always likely to result in broken code, so mark it as an error +add_compile_flags("/we4700") + # Debugging if(${CMAKE_BUILD_TYPE} MATCHES Debug) if(NOT _PREFAST_) diff --git a/reactos/dll/ntdll/ldr/ldrutils.c b/reactos/dll/ntdll/ldr/ldrutils.c index 4bc12c0705a..e553e5fe672 100644 --- a/reactos/dll/ntdll/ldr/ldrutils.c +++ b/reactos/dll/ntdll/ldr/ldrutils.c @@ -1860,7 +1860,9 @@ LdrpSearchPath(IN PWCHAR *SearchPath, /* Sanity check */ TestName.Length = (USHORT)ALIGN_DOWN((BufEnd - Buffer), WCHAR); +#if 0 ASSERT(TestName.Length < TestName.MaximumLength); +#endif /* Check if the file exists */ #if 0 diff --git a/reactos/dll/win32/browseui/bandsite.cpp b/reactos/dll/win32/browseui/bandsite.cpp index aa80e1796f7..15293a84200 100644 --- a/reactos/dll/win32/browseui/bandsite.cpp +++ b/reactos/dll/win32/browseui/bandsite.cpp @@ -409,6 +409,7 @@ HRESULT STDMETHODCALLTYPE CBandSiteBase::AddBand(IUnknown *punk) WARN("IBandSite::AddBand(): Call to IDeskBand::SetSite() failed: %x\n", hRet); /* Remove the band from the ReBar control */ + BuildRebarBandInfo(NewBand, &rbi); uBand = (UINT)SendMessageW(fRebarWindow, RB_IDTOINDEX, (WPARAM)rbi.wID, 0); if (uBand != (UINT)-1) { diff --git a/reactos/drivers/bus/pcix/pci/id.c b/reactos/drivers/bus/pcix/pci/id.c index 9db7d703fb0..205265d7802 100644 --- a/reactos/drivers/bus/pcix/pci/id.c +++ b/reactos/drivers/bus/pcix/pci/id.c @@ -51,7 +51,7 @@ PciGetDescriptionMessage(IN ULONG Identifier, /* Validate valid message length, ending with a newline character */ ASSERT(TextLength > 1); - ASSERT(Description[TextLength / sizeof(WCHAR) == L'\n']); + ASSERT(Description[TextLength / sizeof(WCHAR)] == L'\n'); /* Allocate the buffer to hold the message string */ Buffer = ExAllocatePoolWithTag(PagedPool, TextLength, 'BicP'); @@ -61,8 +61,8 @@ PciGetDescriptionMessage(IN ULONG Identifier, RtlCopyMemory(Buffer, Entry->Text, TextLength - 1); Buffer[TextLength / sizeof(WCHAR)] = UNICODE_NULL; - /* Return the length to the caller */ - if (Length) *Length = UnicodeString.Length; + /* Return the length to the caller, minus the terminating NULL */ + if (Length) *Length = TextLength - 1; } else { diff --git a/reactos/include/ddk/ndis.h b/reactos/include/ddk/ndis.h index ba7fa0d30f5..bacae3a3f4b 100644 --- a/reactos/include/ddk/ndis.h +++ b/reactos/include/ddk/ndis.h @@ -3101,19 +3101,19 @@ NdisGetFirstBufferFromPacket( #define NdisChainBufferAtBack(Packet, \ Buffer) \ { \ - PNDIS_BUFFER NdisBuffer = (Buffer); \ + PNDIS_BUFFER _NdisBuffer = (Buffer); \ \ - while (NdisBuffer->Next != NULL) \ - NdisBuffer = NdisBuffer->Next; \ + while (_NdisBuffer->Next != NULL) \ + _NdisBuffer = _NdisBuffer->Next; \ \ - NdisBuffer->Next = NULL; \ + _NdisBuffer->Next = NULL; \ \ if ((Packet)->Private.Head != NULL) \ (Packet)->Private.Tail->Next = (Buffer); \ else \ (Packet)->Private.Head = (Buffer); \ \ - (Packet)->Private.Tail = NdisBuffer; \ + (Packet)->Private.Tail = _NdisBuffer; \ (Packet)->Private.ValidCounts = FALSE; \ } diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index 32b811faff3..1cb43ba0ced 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -134,7 +134,7 @@ WinPosShowIconTitle( PWND pWnd, BOOL bShow ) { HICON hIcon; if (!pWnd->pcls || pWnd->fnid == FNID_DESKTOP) return FALSE; - if (!hIcon) hIcon = pWnd->pcls->hIconSm; + hIcon = pWnd->pcls->hIconSm; if (!hIcon) hIcon = pWnd->pcls->hIcon; if (!hIcon) return FALSE;