diff options
author | Aaron Robinson <arobins@microsoft.com> | 2022-03-17 05:30:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 05:30:39 +0300 |
commit | a5ec8aa173e4bc76b173a70aa7fa3be1867011eb (patch) | |
tree | 1f88664910318b3fd1dd014aa03093f7de910d78 | |
parent | 82239a2a0def33c00159c0372226427099cfa355 (diff) |
Reenable CA 4701 (#66676)
* Reenable 4701
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
50 files changed, 152 insertions, 143 deletions
diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index ca92fe6a311..cdf1a8f766a 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -600,7 +600,6 @@ if (MSVC) add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4463>) # overflow; assigning value to bit-field that can only hold values from low_value to high_value add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4505>) # unreferenced function with internal linkage has been removed add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4611>) # interaction between 'function' and C++ object destruction is non-portable - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4701>) # potentially uninitialized local variable 'var' used add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4702>) # unreachable code add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4703>) # potentially uninitialized local pointer variable 'var' used add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4706>) # assignment within conditional expression diff --git a/src/coreclr/classlibnative/bcltype/arraynative.cpp b/src/coreclr/classlibnative/bcltype/arraynative.cpp index dfa1b336474..284573d219e 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.cpp +++ b/src/coreclr/classlibnative/bcltype/arraynative.cpp @@ -228,7 +228,7 @@ ArrayNative::AssignArrayEnum ArrayNative::CanAssignArrayType(const BASEARRAYREF TypeHandle srcTH = pSrcMT->GetArrayElementTypeHandle(); TypeHandle destTH = pDestMT->GetArrayElementTypeHandle(); _ASSERTE(srcTH != destTH); // Handled by fast path - + // Value class boxing if (srcTH.IsValueType() && !destTH.IsValueType()) { @@ -862,7 +862,7 @@ FCIMPL4(Object*, ArrayNative::CreateInstance, ReflectClassBaseObject* pElementTy HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(pElementType); TypeHandle elementType(pElementType->GetType()); - + CheckElementType(elementType); CorElementType CorType = elementType.GetSignatureCorElementType(); @@ -956,7 +956,7 @@ FCIMPL2(Object*, ArrayNative::GetValue, ArrayBase* refThisUNSAFE, INT_PTR flatte _ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents()); void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); - OBJECTREF Obj; + OBJECTREF Obj = NULL; MethodTable* pElementTypeMT = arrayElementType.GetMethodTable(); if (pElementTypeMT->IsValueType()) @@ -1146,7 +1146,7 @@ FCIMPL3_VVI(void*, ArrayNative::GetSpanDataFrom, FCALLRuntimeFieldHandle structF } gc; gc.refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField)); gc.refClass = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(FCALL_RTH_TO_REFLECTCLASS(targetTypeUnsafe)); - void* data; + void* data = NULL; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); FieldDesc* pField = (FieldDesc*)gc.refField->GetField(); diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 7e7e5fe7c1d..ff676ee0190 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -4377,7 +4377,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification( ClrDataModule* pubModule = NULL; ClrDataMethodInstance* pubMethodInst = NULL; ClrDataExceptionState* pubExState = NULL; - GcEvtArgs pubGcEvtArgs; + GcEvtArgs pubGcEvtArgs = {}; ULONG32 notifyType = 0; DWORD catcherNativeOffset = 0; TADDR nativeCodeLocation = NULL; @@ -5491,7 +5491,7 @@ HRESULT ClrDataAccess::Initialize(void) { HRESULT hr; - CLRDATA_ADDRESS base; + CLRDATA_ADDRESS base = { 0 }; // // We do not currently support cross-platform @@ -6458,7 +6458,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly, { SUPPORTS_DAC_HOST_ONLY; PEImage *mdImage = NULL; - PEImageLayout *layout; + PEImageLayout *layout = NULL; IMAGE_DATA_DIRECTORY *pDir = NULL; COUNT_T uniPathChars = 0; diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index c0c9c465596..f5420a30401 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -2796,7 +2796,7 @@ void DacDbiInterfaceImpl::GetMethodDescParams( *pcGenericClassTypeParams = cGenericClassTypeParams; TypeHandle thSpecificClass; - MethodDesc * pSpecificMethod; + MethodDesc * pSpecificMethod = NULL; // Try to retrieve a more specific MethodDesc and TypeHandle via the generics type token. // The generics token is not always guaranteed to be available. diff --git a/src/coreclr/debug/daccess/enummem.cpp b/src/coreclr/debug/daccess/enummem.cpp index 712f0b35c73..7b3c5d3ee97 100644 --- a/src/coreclr/debug/daccess/enummem.cpp +++ b/src/coreclr/debug/daccess/enummem.cpp @@ -830,7 +830,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, // MethodTable ReleaseHolder<IXCLRDataValue> pDV(NULL); ReleaseHolder<IXCLRDataValue> pAssociatedValue(NULL); - CLRDATA_ADDRESS address; + CLRDATA_ADDRESS address = 0; PTR_Object pObjThis = NULL; if (SUCCEEDED(pFrame->GetArgumentByIndex(0, &pDV, 0, NULL, NULL)) && diff --git a/src/coreclr/debug/dbgutil/dbgutil.cpp b/src/coreclr/debug/dbgutil/dbgutil.cpp index 242bf65eb8a..52701c5ccf2 100644 --- a/src/coreclr/debug/dbgutil/dbgutil.cpp +++ b/src/coreclr/debug/dbgutil/dbgutil.cpp @@ -64,14 +64,12 @@ HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, // after the signature is a 20 byte image file header // we need to parse this to figure out the target architecture - IMAGE_FILE_HEADER imageFileHeader; + IMAGE_FILE_HEADER imageFileHeader = {}; if (SUCCEEDED(hr)) { hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer + 4, (BYTE*)&imageFileHeader, IMAGE_SIZEOF_FILE_HEADER); } - - WORD optHeaderMagic = 0; DWORD peOptImageHeaderFilePointer = 0; if (SUCCEEDED(hr)) diff --git a/src/coreclr/debug/di/module.cpp b/src/coreclr/debug/di/module.cpp index 55f9e8a29c8..c01ab6ce0e6 100644 --- a/src/coreclr/debug/di/module.cpp +++ b/src/coreclr/debug/di/module.cpp @@ -3258,9 +3258,8 @@ HRESULT CordbILCode::GetLocalVarSig(SigParser *pLocalSigParser, // A function will not have a local var sig if it has no locals! if (m_localVarSigToken != mdSignatureNil) { - PCCOR_SIGNATURE localSignature; - ULONG size; - uint32_t localCount; + PCCOR_SIGNATURE localSignature = NULL; + ULONG size = 0; EX_TRY // // @dbgtodo exceptions - push this up { @@ -3286,6 +3285,7 @@ HRESULT CordbILCode::GetLocalVarSig(SigParser *pLocalSigParser, _ASSERTE(data == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG); // Snagg the count of locals in the sig. + uint32_t localCount; IfFailRet(sigParser.GetData(&localCount)); LOG((LF_CORDB, LL_INFO100000, "CIC::GLVS localCount=0x%x\n", localCount)); if (pLocalSigParser != NULL) diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index 1abed121f3e..0427cc0dd7d 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -2726,7 +2726,7 @@ HRESULT CordbRefEnum::Next(ULONG celt, COR_GC_REFERENCE refs[], ULONG *pceltFetc { CordbAppDomain *pDomain = process->LookupOrCreateAppDomain(dacRefs[i].vmDomain); - ICorDebugAppDomain *pAppDomain; + ICorDebugAppDomain *pAppDomain = NULL; ICorDebugValue *pOutObject = NULL; if (dacRefs[i].pObject & 1) { @@ -11440,9 +11440,6 @@ void CordbWin32EventThread::Win32EventLoop() LOG((LF_CORDB, LL_INFO1000, "W32ET::W32EL: entered win32 event loop\n")); - - DEBUG_EVENT event; - // Allow the timeout for WFDE to be adjustable. Default to 25 ms based off perf numbers (see issue VSWhidbey 132368). DWORD dwWFDETimeout = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgWFDETimeout); @@ -11468,7 +11465,7 @@ void CordbWin32EventThread::Win32EventLoop() rghWaitSet[0] = m_threadControlEvent; DWORD dwWaitTimeout = INFINITE; - + DEBUG_EVENT event = {}; if (m_pProcess != NULL) { // Process is always built on Native debugging pipeline, so it needs to always be prepared to call WFDE diff --git a/src/coreclr/debug/di/rsclass.cpp b/src/coreclr/debug/di/rsclass.cpp index 4fe8930712a..43bfa15923a 100644 --- a/src/coreclr/debug/di/rsclass.cpp +++ b/src/coreclr/debug/di/rsclass.cpp @@ -335,7 +335,7 @@ HRESULT CordbClass::GetStaticFieldValue2(CordbModule * pModule, !pFieldData->m_fFldIsTLS); TargetBuffer remoteValue(pRmtStaticValue, CordbValue::GetSizeForType(pType, fIsBoxed ? kBoxed : kUnboxed)); - ICorDebugValue * pValue; + ICorDebugValue * pValue = NULL; EX_TRY { diff --git a/src/coreclr/debug/di/rsfunction.cpp b/src/coreclr/debug/di/rsfunction.cpp index f2384411bc0..c7109e34003 100644 --- a/src/coreclr/debug/di/rsfunction.cpp +++ b/src/coreclr/debug/di/rsfunction.cpp @@ -1010,8 +1010,8 @@ HRESULT CordbFunction::GetSig(SigParser *pMethodSigParser, // may change and the cached value will not match. if (!m_fCachedMethodValuesValid) { - PCCOR_SIGNATURE functionSignature; - ULONG size; + PCCOR_SIGNATURE functionSignature = NULL; + ULONG size = 0; DWORD methodAttr = 0; uint32_t argCount; diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 38a49875277..c3543ad96cd 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -6884,7 +6884,7 @@ CordbNativeFrame::GetLocalMemoryValue(CORDB_ADDRESS address, _ASSERTE(m_nativeCode->GetFunction() != NULL); HRESULT hr = S_OK; - ICorDebugValue *pValue; + ICorDebugValue *pValue = NULL; EX_TRY { CordbValue::CreateValueByType(GetCurrentAppDomain(), diff --git a/src/coreclr/debug/di/rstype.cpp b/src/coreclr/debug/di/rstype.cpp index af6a8f5e14a..ace21deab50 100644 --- a/src/coreclr/debug/di/rstype.cpp +++ b/src/coreclr/debug/di/rstype.cpp @@ -2313,7 +2313,7 @@ HRESULT CordbType::GetTypeID(COR_TYPEID *pId) hr = Init(FALSE); IfFailThrow(hr); - VMPTR_TypeHandle vmTypeHandle; + VMPTR_TypeHandle vmTypeHandle = VMPTR_TypeHandle::NullPtr(); CorElementType et = GetElementType(); switch (et) diff --git a/src/coreclr/debug/di/valuehome.cpp b/src/coreclr/debug/di/valuehome.cpp index c27c949cae2..bc1b71d9747 100644 --- a/src/coreclr/debug/di/valuehome.cpp +++ b/src/coreclr/debug/di/valuehome.cpp @@ -800,7 +800,7 @@ void RegisterValueHome::SetEnregisteredValue(MemoryRange src, bool fIsSigned) { _ASSERTE(m_pRemoteRegAddr != NULL); // Get the thread's context so we can update it. - DT_CONTEXT * cTemp; + DT_CONTEXT * cTemp = NULL; const CordbNativeFrame * frame = m_pRemoteRegAddr->GetFrame(); // Can't set an enregistered value unless the frame the value was diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 9077dfcbd34..06e1b609a23 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -4041,11 +4041,13 @@ GetSetFrameHelper::Init(MethodDesc *pMD) mdSignature mdLocalSig = (decoderOldIL.GetLocalVarSigTok()) ? (decoderOldIL.GetLocalVarSigTok()): (mdSignatureNil); + PCCOR_SIGNATURE pLocalSig = NULL; + ULONG cbLocalSigSize = 0; + PCCOR_SIGNATURE pCallSig; DWORD cbCallSigSize; pMD->GetSig(&pCallSig, &cbCallSigSize); - if (pCallSig != NULL) { // Yes, we do need to pass in the text because this might be generic function! @@ -4079,18 +4081,15 @@ GetSetFrameHelper::Init(MethodDesc *pMD) } // allocation of pArgSig succeeded - ULONG cbSig; - PCCOR_SIGNATURE pLocalSig; - pLocalSig = NULL; if (mdLocalSig != mdSignatureNil) { - IfFailGo(pMD->GetModule()->GetMDImport()->GetSigFromToken(mdLocalSig, &cbSig, &pLocalSig)); + IfFailGo(pMD->GetModule()->GetMDImport()->GetSigFromToken(mdLocalSig, &cbLocalSigSize, &pLocalSig)); } if (pLocalSig != NULL) { SigTypeContext tmpContext(pMD); pLocSig = new (interopsafe, nothrow) MetaSig(pLocalSig, - cbSig, + cbLocalSigSize, pMD->GetModule(), &tmpContext, MetaSig::sigLocalVars); @@ -10510,7 +10509,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) // If we haven't been either JITted or EnC'd yet, then // we'll put a patch in by offset, implicitly relative // to the first version of the code. - + fSuccess = FALSE; pDebuggerBP = new (interopsafe, nothrow) DebuggerBreakpoint(pModule, pEvent->BreakpointData.funcMetadataToken, pEvent->vmAppDomain.GetRawPtr(), @@ -11111,12 +11110,14 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) objectHandle = pAppDomain->CreatePinningHandle(objref); break; default: + objectHandle = NULL; pEvent->hr = E_INVALIDARG; } - } - if (SUCCEEDED(pEvent->hr)) - { - pEvent->CreateHandleResult.vmObjectHandle.SetRawPtr(objectHandle); + + if (SUCCEEDED(pEvent->hr)) + { + pEvent->CreateHandleResult.vmObjectHandle.SetRawPtr(objectHandle); + } } } diff --git a/src/coreclr/debug/shim/debugshim.cpp b/src/coreclr/debug/shim/debugshim.cpp index a162bc65acb..0e3be125b9a 100644 --- a/src/coreclr/debug/shim/debugshim.cpp +++ b/src/coreclr/debug/shim/debugshim.cpp @@ -97,13 +97,13 @@ STDMETHODIMP CLRDebuggingImpl::OpenVirtualProcess( HMODULE hDac = NULL; LPWSTR pDacModulePath = NULL; LPWSTR pDbiModulePath = NULL; - DWORD dbiTimestamp; - DWORD dbiSizeOfImage; + DWORD dbiTimestamp = 0; + DWORD dbiSizeOfImage = 0; WCHAR dbiName[MAX_PATH_FNAME] = { 0 }; DWORD dacTimestamp; DWORD dacSizeOfImage; WCHAR dacName[MAX_PATH_FNAME] = { 0 }; - CLR_DEBUGGING_VERSION version; + CLR_DEBUGGING_VERSION version = { 0 }; BOOL versionSupportedByCaller = FALSE; // argument checking @@ -541,7 +541,7 @@ HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget* pDataTarget, hr = CORDBG_E_NOT_CLR; } - CLR_DEBUG_RESOURCE debugResource; + CLR_DEBUG_RESOURCE debugResource = {}; if(SUCCEEDED(hr) && debugResourceSize != sizeof(debugResource)) { hr = CORDBG_E_NOT_CLR; diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index ab71a94ac8b..5874c5d2db4 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -26993,7 +26993,7 @@ void gc_heap::check_loh_compact_mode (BOOL all_heaps_compacted_p) BOOL gc_heap::plan_loh() { #ifdef FEATURE_EVENT_TRACE - uint64_t start_time, end_time; + uint64_t start_time = 0, end_time; if (informational_event_enabled_p) { memset (loh_compact_info, 0, (sizeof (etw_loh_compact_info) * get_num_heaps())); @@ -27161,7 +27161,7 @@ void gc_heap::compact_loh() assert (loh_compaction_requested() || heap_hard_limit || conserve_mem_setting); #ifdef FEATURE_EVENT_TRACE - uint64_t start_time, end_time; + uint64_t start_time = 0, end_time; if (informational_event_enabled_p) { start_time = GetHighPrecisionTimeStamp(); @@ -27324,7 +27324,7 @@ void gc_heap::relocate_in_loh_compact() #ifdef FEATURE_EVENT_TRACE size_t total_refs = 0; size_t zero_refs = 0; - uint64_t start_time, end_time; + uint64_t start_time = 0, end_time; if (informational_event_enabled_p) { start_time = GetHighPrecisionTimeStamp(); @@ -30918,7 +30918,7 @@ void gc_heap::make_free_lists (int condemned_gen_number) //Promotion has to happen in sweep case. assert (settings.promotion); - make_free_args args; + make_free_args args = {}; int stop_gen_idx = get_stop_generation_index (condemned_gen_number); for (int i = condemned_gen_number; i >= stop_gen_idx; i--) { diff --git a/src/coreclr/gc/windows/gcenv.windows.cpp b/src/coreclr/gc/windows/gcenv.windows.cpp index 10d3128de20..06ad13221b7 100644 --- a/src/coreclr/gc/windows/gcenv.windows.cpp +++ b/src/coreclr/gc/windows/gcenv.windows.cpp @@ -1181,7 +1181,7 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n bool success = false; // Locate heap_number-th available processor - uint16_t procIndex; + uint16_t procIndex = 0; size_t cnt = heap_number; for (uint16_t i = 0; i < GCToOSInterface::GetTotalProcessorCount(); i++) { diff --git a/src/coreclr/ilasm/assembler.cpp b/src/coreclr/ilasm/assembler.cpp index 85183bfae75..313088735d0 100644 --- a/src/coreclr/ilasm/assembler.cpp +++ b/src/coreclr/ilasm/assembler.cpp @@ -1161,7 +1161,7 @@ void Assembler::EmitLocals(BinStr* sig) ARG_NAME_LIST *pAN, *pList= getArgNameList(); if(pList) { - VarDescr* pVD; + VarDescr* pVD = NULL; for(pAN=pList; pAN; pAN = pAN->pNext) { if(pAN->dwAttr == 0) pAN->dwAttr = m_pCurMethod->m_Locals.COUNT() +1; diff --git a/src/coreclr/ilasm/grammar_after.cpp b/src/coreclr/ilasm/grammar_after.cpp index f1f83bd21fa..6353ebedad0 100644 --- a/src/coreclr/ilasm/grammar_after.cpp +++ b/src/coreclr/ilasm/grammar_after.cpp @@ -137,7 +137,7 @@ char* NewStaticStrFromTokenW(_In_reads_(tokLen) char* curTok, size_t tokLen, _Ou unsigned GetDoubleAU(_In_ __nullterminated char* begNum, unsigned L, double** ppRes) { static char dbuff[128]; - char* pdummy; + char* pdummy = NULL; if(L > 127) L = 127; memcpy(dbuff,begNum,L); dbuff[L] = 0; @@ -148,7 +148,7 @@ unsigned GetDoubleAU(_In_ __nullterminated char* begNum, unsigned L, double** pp unsigned GetDoubleW(_In_ __nullterminated char* begNum, unsigned L, double** ppRes) { static char dbuff[256]; - char* pdummy; + char* pdummy = NULL; if(L > 254) L = 254; memcpy(dbuff,begNum,L); dbuff[L] = 0; diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index ae7dcd603c9..7f91690e220 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -3333,8 +3333,8 @@ void PrettyPrintOverrideDecl(ULONG i, __inout __nullterminated char* szString, v // In that case the full "method" syntax must be used if ((TypeFromToken(tkOverrider) == mdtMethodDef) && !needsFullTokenPrint) { - PCCOR_SIGNATURE pComSigDecl; - ULONG cComSigDecl; + PCCOR_SIGNATURE pComSigDecl = NULL; + ULONG cComSigDecl = 0; mdToken tkDeclSigTok = tkDecl; bool successfullyGotDeclSig = false; bool successfullyGotBodySig = false; @@ -3875,7 +3875,7 @@ BOOL DumpMethod(mdToken FuncToken, const char *pszClassName, DWORD dwEntryPointT szString[0] = 0; if (dwTargetRVA != 0) { - void* newTarget; + void* newTarget = NULL; if(g_pPELoader->getVAforRVA(dwTargetRVA,&newTarget)) { DisassembleWrapper(g_pImport, (unsigned char*)newTarget, GUICookie, FuncToken,pszArgname, ulArgs); @@ -6056,7 +6056,7 @@ void DumpStatistics(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) { ++methodBodies; - COR_ILMETHOD_FAT *pMethod; + COR_ILMETHOD_FAT *pMethod = NULL; g_pPELoader->getVAforRVA(rva, (void **) &pMethod); if (pMethod->IsFat()) { @@ -6646,8 +6646,8 @@ void DumpEATEntries(void* GUICookie, #endif if(pExpTable->dwNumATEntries && pExpTable->dwAddrTableRVA) { - DWORD* pExpAddr; - BYTE *pCont; + DWORD* pExpAddr = NULL; + BYTE *pCont = NULL; DWORD dwTokRVA; mdToken* pTok; g_pPELoader->getVAforRVA(VAL32(pExpTable->dwAddrTableRVA), (void **) &pExpAddr); @@ -6695,9 +6695,9 @@ void DumpEATEntries(void* GUICookie, } if(pExpTable->dwNumNamePtrs && pExpTable->dwNamePtrRVA && pExpTable->dwOrdTableRVA) { - DWORD *pNamePtr; - WORD *pOrd; - char* szName; + DWORD* pNamePtr = NULL; + WORD* pOrd = NULL; + char* szName = NULL; g_pPELoader->getVAforRVA(VAL32(pExpTable->dwNamePtrRVA), (void **) &pNamePtr); g_pPELoader->getVAforRVA(VAL32(pExpTable->dwOrdTableRVA), (void **) &pOrd); #ifdef _DEBUG diff --git a/src/coreclr/md/compiler/assemblymd_emit.cpp b/src/coreclr/md/compiler/assemblymd_emit.cpp index 161f9125e2b..32d8f63f038 100644 --- a/src/coreclr/md/compiler/assemblymd_emit.cpp +++ b/src/coreclr/md/compiler/assemblymd_emit.cpp @@ -36,7 +36,7 @@ STDMETHODIMP RegMeta::DefineAssembly( // S_OK or error. HRESULT hr = S_OK; AssemblyRec *pRecord = NULL; // The assembly record. - RID iRecord; // RID of the assembly record. + RID iRecord = 0; // RID of the assembly record. if (szName == NULL || pMetaData == NULL || pma == NULL) return E_INVALIDARG; diff --git a/src/coreclr/md/compiler/emit.cpp b/src/coreclr/md/compiler/emit.cpp index 3a2e5ff2f73..8fbcdd10675 100644 --- a/src/coreclr/md/compiler/emit.cpp +++ b/src/coreclr/md/compiler/emit.cpp @@ -1178,7 +1178,7 @@ HRESULT RegMeta::_DefinePermissionSet( DeclSecurityRec *pDeclSec = NULL; RID iDeclSec; short sAction = static_cast<short>(dwAction); // To match with the type in DeclSecurityRec. - mdPermission tkPerm; // New permission token. + mdPermission tkPerm = mdTokenNil; // New permission token. _ASSERTE(TypeFromToken(tk) == mdtTypeDef || TypeFromToken(tk) == mdtMethodDef || TypeFromToken(tk) == mdtAssembly); @@ -2624,7 +2624,7 @@ HRESULT RegMeta::_DefinePinvokeMap( // Return hresult. return E_NOTIMPL; #else //!FEATURE_METADATA_EMIT_IN_DEBUGGER ImplMapRec *pRecord; - RID iRecord; + RID iRecord = 0; bool bDupFound = false; HRESULT hr = S_OK; @@ -2736,8 +2736,8 @@ STDMETHODIMP RegMeta::SetPinvokeMap( // Return code. if (InvalidRid(iRecord)) IfFailGo(CLDB_E_RECORD_NOTFOUND); - else - IfFailGo(m_pStgdb->m_MiniMd.GetImplMapRecord(iRecord, &pRecord)); + + IfFailGo(m_pStgdb->m_MiniMd.GetImplMapRecord(iRecord, &pRecord)); // Set the data. if (dwMappingFlags != UINT32_MAX) diff --git a/src/coreclr/md/compiler/helper.cpp b/src/coreclr/md/compiler/helper.cpp index a4e7b10c8be..71e12fa2643 100644 --- a/src/coreclr/md/compiler/helper.cpp +++ b/src/coreclr/md/compiler/helper.cpp @@ -253,7 +253,7 @@ STDMETHODIMP RegMeta::AddDeclarativeSecurityHelper( DeclSecurityRec *pDeclSec = NULL; RID iDeclSec; short sAction = static_cast<short>(dwAction); - mdPermission tkPerm; + mdPermission tkPerm = mdTokenNil; LOG((LOGMD, "MD RegMeta::AddDeclarativeSecurityHelper(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n", tk, dwAction, pValue, cbValue, pmdPermission)); diff --git a/src/coreclr/md/compiler/import.cpp b/src/coreclr/md/compiler/import.cpp index fb1ed6c8138..20832ad3bb5 100644 --- a/src/coreclr/md/compiler/import.cpp +++ b/src/coreclr/md/compiler/import.cpp @@ -2549,8 +2549,8 @@ STDMETHODIMP RegMeta::GetPinvokeMap( // S_OK or error. { IfFailGo( CLDB_E_RECORD_NOTFOUND ); } - else - IfFailGo(m_pStgdb->m_MiniMd.GetImplMapRecord(iRecord, &pRecord)); + + IfFailGo(m_pStgdb->m_MiniMd.GetImplMapRecord(iRecord, &pRecord)); if (pdwMappingFlags) *pdwMappingFlags = m_pStgdb->m_MiniMd.getMappingFlagsOfImplMap(pRecord); diff --git a/src/coreclr/md/compiler/regmeta_emit.cpp b/src/coreclr/md/compiler/regmeta_emit.cpp index 6508dbb78d5..5433d35409f 100644 --- a/src/coreclr/md/compiler/regmeta_emit.cpp +++ b/src/coreclr/md/compiler/regmeta_emit.cpp @@ -1078,24 +1078,23 @@ HRESULT RegMeta::_DefineMethodSemantics( // S_OK or error. mdToken tkAssoc, // [IN] Association. BOOL bClear) // [IN] Specifies whether to delete the exisiting entries. { - HRESULT hr = S_OK; - MethodSemanticsRec *pRecord = 0; - MethodSemanticsRec *pRecord1; // Use this to recycle a MethodSemantics record. - RID iRecord; - HENUMInternal hEnum; - - + HRESULT hr = S_OK; + MethodSemanticsRec *pRecord = NULL; + MethodSemanticsRec *pRecord1 = NULL; // Use this to recycle a MethodSemantics record. + RID iRecord = 0; _ASSERTE(TypeFromToken(md) == mdtMethodDef || IsNilToken(md)); _ASSERTE(RidFromToken(tkAssoc)); + + HENUMInternal hEnum; HENUMInternal::ZeroEnum(&hEnum); // Clear all matching records by setting association to a Nil token. if (bClear) { - RID i; + IfFailGo( m_pStgdb->m_MiniMd.FindMethodSemanticsHelper(tkAssoc, &hEnum)); - IfFailGo( m_pStgdb->m_MiniMd.FindMethodSemanticsHelper(tkAssoc, &hEnum) ); + RID i; while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&i)) { IfFailGo(m_pStgdb->m_MiniMd.GetMethodSemanticsRecord(i, &pRecord1)); @@ -1581,10 +1580,10 @@ HRESULT RegMeta::_DefineSetConstant( // Return hresult. (pValue || (pValue == 0 && (dwCPlusTypeFlag == ELEMENT_TYPE_STRING || dwCPlusTypeFlag == ELEMENT_TYPE_CLASS)))) { - ConstantRec *pConstRec = 0; - RID iConstRec; - ULONG cbBlob; - ULONG ulValue = 0; + ConstantRec* pConstRec = 0; + RID iConstRec = 0; + ULONG ulValue = 0; + ULONG cbBlob; if (bSearch) { diff --git a/src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c index 1bfba29c0d4..0f765adf7e5 100644 --- a/src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c +++ b/src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c @@ -910,15 +910,15 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, unw_dyn_info_t *di, unw_proc_info_t *pi, int need_unwind_info, void *arg) { - const struct table_entry *e = NULL, *table; + const struct table_entry *e = NULL, *table = NULL; unw_word_t ip_base = 0, segbase = 0, last_ip, fde_addr; unw_accessors_t *a; #ifndef UNW_LOCAL_ONLY struct table_entry ent; #endif int ret; - unw_word_t debug_frame_base; - size_t table_len; + unw_word_t debug_frame_base = 0; + size_t table_len = 0; #ifdef UNW_REMOTE_ONLY assert (is_remote_table(di->format)); diff --git a/src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c b/src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c index d4cf533a035..cf24d4ec1c2 100644 --- a/src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c +++ b/src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c @@ -907,7 +907,7 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) static int find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr) { - dwarf_reg_state_t *rs; + dwarf_reg_state_t *rs = NULL; struct dwarf_rs_cache *cache; int ret = 0; intrmask_t saved_mask; @@ -985,6 +985,7 @@ dwarf_make_proc_info (struct dwarf_cursor *c) args_size, and set cursor appropriately. Only needed for unw_resume */ dwarf_state_record_t sr; + sr.args_size = 0; int ret; /* Lookup it up the slow way... */ diff --git a/src/coreclr/pal/src/libunwind/src/x86_64/Gstep.c b/src/coreclr/pal/src/libunwind/src/x86_64/Gstep.c index 3c5c3830ff4..bbc3d9847e8 100644 --- a/src/coreclr/pal/src/libunwind/src/x86_64/Gstep.c +++ b/src/coreclr/pal/src/libunwind/src/x86_64/Gstep.c @@ -112,7 +112,7 @@ unw_step (unw_cursor_t *cursor) unw_word_t invalid_prev_rip = 0; unw_word_t prev_ip = c->dwarf.ip, prev_cfa = c->dwarf.cfa; - struct dwarf_loc rbp_loc, rsp_loc, rip_loc; + struct dwarf_loc rbp_loc = DWARF_NULL_LOC, rsp_loc = DWARF_NULL_LOC, rip_loc = DWARF_NULL_LOC; /* We could get here because of missing/bad unwind information. Validate all addresses before dereferencing. */ @@ -253,7 +253,7 @@ unw_step (unw_cursor_t *cursor) } /* Mark all registers unsaved */ for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; + c->dwarf.loc[i] = DWARF_NULL_LOC; c->dwarf.loc[RBP] = rbp_loc; c->dwarf.loc[RSP] = rsp_loc; diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 8351b8de24b..1b19fd559fc 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -1877,7 +1877,7 @@ void MDInfo::DisplayCustomAttributeInfo(mdCustomAttribute inValue, const char *p LPCUTF8 pMethName=0; // Name of custom attribute ctor, if any. CQuickBytes qSigName; // Buffer to pretty-print signature. PCCOR_SIGNATURE pSig=0; // Signature of ctor. - ULONG cbSig; // Size of the signature. + ULONG cbSig=0; // Size of the signature. BOOL bCoffSymbol = false; // true for coff symbol CA's. WCHAR rcName[MAX_CLASS_NAME]; // Name of the type. diff --git a/src/coreclr/tools/superpmi/superpmi/superpmi.cpp b/src/coreclr/tools/superpmi/superpmi/superpmi.cpp index f71ee9c1fe3..e5a7d7f3263 100644 --- a/src/coreclr/tools/superpmi/superpmi/superpmi.cpp +++ b/src/coreclr/tools/superpmi/superpmi/superpmi.cpp @@ -149,7 +149,7 @@ int __cdecl main(int argc, char* argv[]) SimpleTimer st3; SimpleTimer st4; st2.Start(); - JitInstance::Result res, res2; + JitInstance::Result res, res2 = JitInstance::RESULT_ERROR; HRESULT hr = E_FAIL; MethodContext* mc = nullptr; JitInstance * jit = nullptr, *jit2 = nullptr; diff --git a/src/coreclr/unwinder/amd64/unwinder_amd64.cpp b/src/coreclr/unwinder/amd64/unwinder_amd64.cpp index fc3c746d875..127fde33c07 100644 --- a/src/coreclr/unwinder/amd64/unwinder_amd64.cpp +++ b/src/coreclr/unwinder/amd64/unwinder_amd64.cpp @@ -448,11 +448,11 @@ HRESULT. ULONG Index; PULONG64 IntegerAddress; PULONG64 IntegerRegister; - ULONG OpInfo; + ULONG OpInfo = 0; PULONG64 ReturnAddress; PULONG64 StackAddress; PUNWIND_INFO UnwindInfo; - UNWIND_CODE UnwindOp; + UNWIND_CODE UnwindOp = {}; // // A canonical epilogue sequence consists of the following operations: @@ -1074,10 +1074,10 @@ Arguments: ULONG64 BranchTarget; LONG Displacement; - ULONG EpilogueOffset; + ULONG EpilogueOffset = 0; ULONG EpilogueSize; PEXCEPTION_ROUTINE FoundHandler; - ULONG FrameRegister; + ULONG FrameRegister = 0; ULONG FrameOffset; ULONG Index; BOOL InEpilogue; diff --git a/src/coreclr/unwinder/arm/unwinder_arm.cpp b/src/coreclr/unwinder/arm/unwinder_arm.cpp index 2ad5d3de94a..5ba057cbcd6 100644 --- a/src/coreclr/unwinder/arm/unwinder_arm.cpp +++ b/src/coreclr/unwinder/arm/unwinder_arm.cpp @@ -771,6 +771,12 @@ RtlpUnwindFunctionCompact( if (OffsetInFunction < PrologLength) { OffsetInScope = PrologLength - OffsetInFunction; } + } else { + ComputeFramePointerLength = 0; + PushPopParamsLength = 0; + PushPopFloatingPointLength = 0; + PushPopIntegerLength = 0; + StackAdjustLength = 0; } // @@ -1043,6 +1049,8 @@ Return Value: if ((HeaderWord & (1 << 21)) != 0) { UnwindIndex = EpilogScopeCount; EpilogScopeCount = 0; + } else { + UnwindIndex = 0; } // diff --git a/src/coreclr/unwinder/arm64/unwinder_arm64.cpp b/src/coreclr/unwinder/arm64/unwinder_arm64.cpp index d812e7be3f1..e037c3ab209 100644 --- a/src/coreclr/unwinder/arm64/unwinder_arm64.cpp +++ b/src/coreclr/unwinder/arm64/unwinder_arm64.cpp @@ -720,6 +720,8 @@ Return Value: if ((HeaderWord & (1 << 21)) != 0) { UnwindIndex = EpilogScopeCount; EpilogScopeCount = 0; + } else { + UnwindIndex = 0; } // diff --git a/src/coreclr/utilcode/longfilepathwrappers.cpp b/src/coreclr/utilcode/longfilepathwrappers.cpp index d1372faf303..024ef3294cd 100644 --- a/src/coreclr/utilcode/longfilepathwrappers.cpp +++ b/src/coreclr/utilcode/longfilepathwrappers.cpp @@ -50,7 +50,7 @@ LoadLibraryExWrapper( HRESULT hr = S_OK; HMODULE ret = NULL; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -102,7 +102,7 @@ CreateFileWrapper( CONTRACTL_END; HRESULT hr = S_OK; - DWORD lastError; + DWORD lastError = 0; HANDLE ret = INVALID_HANDLE_VALUE; EX_TRY @@ -150,7 +150,7 @@ GetFileAttributesWrapper( HRESULT hr = S_OK; DWORD ret = INVALID_FILE_ATTRIBUTES; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -194,7 +194,7 @@ GetFileAttributesExWrapper( HRESULT hr = S_OK; BOOL ret = FALSE; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -239,7 +239,7 @@ DeleteFileWrapper( HRESULT hr = S_OK; BOOL ret = FALSE; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -283,7 +283,7 @@ MoveFileExWrapper( HRESULT hr = S_OK; BOOL ret = FALSE; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -334,7 +334,7 @@ SearchPathWrapper( HRESULT hr = S_OK; DWORD ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -424,7 +424,7 @@ GetModuleFileNameWrapper( HRESULT hr = S_OK; DWORD ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -482,7 +482,7 @@ UINT WINAPI GetTempFileNameWrapper( HRESULT hr = S_OK; UINT ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -526,7 +526,7 @@ DWORD WINAPI GetTempPathWrapper( HRESULT hr = S_OK; DWORD ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -567,7 +567,7 @@ DWORD WINAPI GetCurrentDirectoryWrapper( HRESULT hr = S_OK; DWORD ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -609,7 +609,7 @@ DWORD WINAPI GetEnvironmentVariableWrapper( HRESULT hr = S_OK; DWORD ret = 0; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -677,7 +677,7 @@ CopyFileExWrapper( HRESULT hr = S_OK; BOOL ret = FALSE; - DWORD lastError; + DWORD lastError = 0; EX_TRY { @@ -730,7 +730,7 @@ FindFirstFileExWrapper( HRESULT hr = S_OK; HANDLE ret = INVALID_HANDLE_VALUE; - DWORD lastError; + DWORD lastError = 0; EX_TRY { diff --git a/src/coreclr/utilcode/stacktrace.cpp b/src/coreclr/utilcode/stacktrace.cpp index 67126bcdc57..215e6624626 100644 --- a/src/coreclr/utilcode/stacktrace.cpp +++ b/src/coreclr/utilcode/stacktrace.cpp @@ -362,7 +362,7 @@ LPSTR FillSymbolSearchPath(CQuickBytes &qb) STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_CANNOT_TAKE_LOCK; SCAN_IGNORE_FAULT; // Faults from Wsz funcs are handled. - LPSTR retval; + LPSTR retval = NULL; HRESULT hr = S_OK; EX_TRY diff --git a/src/coreclr/vm/arm64/cgencpu.h b/src/coreclr/vm/arm64/cgencpu.h index 100f2454b94..0bddeaf11ed 100644 --- a/src/coreclr/vm/arm64/cgencpu.h +++ b/src/coreclr/vm/arm64/cgencpu.h @@ -256,6 +256,7 @@ inline TADDR GetMem(PCODE address, SIZE_T size, bool signExtend) } EX_CATCH { + mem = NULL; _ASSERTE(!"Memory read within jitted Code Failed, this should not happen!!!!"); } EX_END_CATCH(SwallowAllExceptions); diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index 5a3561c284d..0f431f0f9e5 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -719,7 +719,7 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti STATIC_CONTRACT_GC_TRIGGERS; STATIC_CONTRACT_MODE_COOPERATIVE; - PCODE codeEntryPoint; + PCODE codeEntryPoint = NULL; BEGIN_PRESERVE_LAST_ERROR; diff --git a/src/coreclr/vm/comsynchronizable.cpp b/src/coreclr/vm/comsynchronizable.cpp index 76b511a0e2c..8c64ca22fbe 100644 --- a/src/coreclr/vm/comsynchronizable.cpp +++ b/src/coreclr/vm/comsynchronizable.cpp @@ -536,7 +536,7 @@ extern "C" UINT64 QCALLTYPE ThreadNative_GetCurrentOSThreadId() // We special case the API for non-Windows to get the 64-bit value and zero-extend // the Windows value to return a single data type on all platforms. - UINT64 threadId; + UINT64 threadId = 0; BEGIN_QCALL; #ifndef TARGET_UNIX diff --git a/src/coreclr/vm/comutilnative.cpp b/src/coreclr/vm/comutilnative.cpp index 9e30b6090db..1814c3cffb5 100644 --- a/src/coreclr/vm/comutilnative.cpp +++ b/src/coreclr/vm/comutilnative.cpp @@ -1123,7 +1123,7 @@ FCIMPL1(INT64, GCInterface::GetTotalAllocatedBytes, CLR_BOOL precise) return current_high; } - INT64 allocated; + INT64 allocated = 0; HELPER_METHOD_FRAME_BEGIN_RET_0(); diff --git a/src/coreclr/vm/eventpipeinternal.cpp b/src/coreclr/vm/eventpipeinternal.cpp index e3debbf2766..5e9117cf845 100644 --- a/src/coreclr/vm/eventpipeinternal.cpp +++ b/src/coreclr/vm/eventpipeinternal.cpp @@ -259,7 +259,7 @@ extern "C" HANDLE QCALLTYPE EventPipeInternal_GetWaitHandle(UINT64 sessionID) { QCALL_CONTRACT; - HANDLE waitHandle; + HANDLE waitHandle = NULL; BEGIN_QCALL; waitHandle = EventPipeAdapter::GetWaitHandle(sessionID); diff --git a/src/coreclr/vm/gcenv.os.cpp b/src/coreclr/vm/gcenv.os.cpp index 181b22152ec..716078b87fc 100644 --- a/src/coreclr/vm/gcenv.os.cpp +++ b/src/coreclr/vm/gcenv.os.cpp @@ -1077,7 +1077,7 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n bool success = false; // Locate heap_number-th available processor - uint16_t procIndex; + uint16_t procIndex = 0; size_t cnt = heap_number; for (uint16_t i = 0; i < MAX_SUPPORTED_CPUS; i++) { diff --git a/src/coreclr/vm/interoplibinterface_comwrappers.cpp b/src/coreclr/vm/interoplibinterface_comwrappers.cpp index fd9bdd16659..88d4aa30bd5 100644 --- a/src/coreclr/vm/interoplibinterface_comwrappers.cpp +++ b/src/coreclr/vm/interoplibinterface_comwrappers.cpp @@ -1430,7 +1430,7 @@ extern "C" BOOL QCALLTYPE ComWrappers_TryGetOrCreateComInterfaceForObject( { QCALL_CONTRACT; - bool success; + bool success = false; BEGIN_QCALL; @@ -1465,7 +1465,7 @@ extern "C" BOOL QCALLTYPE ComWrappers_TryGetOrCreateObjectForComInstance( _ASSERTE(ext != NULL); - bool success; + bool success = false; BEGIN_QCALL; diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 752f2b23bf5..3aad7d7d633 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -2089,7 +2089,7 @@ unsigned CEEInfo::getClassGClayout (CORINFO_CLASS_HANDLE clsHnd, BYTE* gcPtrs) MODE_PREEMPTIVE; } CONTRACTL_END; - unsigned result; + unsigned result = 0; JIT_TO_EE_TRANSITION(); @@ -11963,7 +11963,7 @@ bool CEEJitInfo::doesFieldBelongToClass(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLA MODE_PREEMPTIVE; } CONTRACTL_END; - bool result; + bool result = false; JIT_TO_EE_TRANSITION(); diff --git a/src/coreclr/vm/marshalnative.cpp b/src/coreclr/vm/marshalnative.cpp index 4056aaced2e..6aa5cefb9f6 100644 --- a/src/coreclr/vm/marshalnative.cpp +++ b/src/coreclr/vm/marshalnative.cpp @@ -341,7 +341,7 @@ FCIMPL1(UINT32, MarshalNative::OffsetOfHelper, ReflectFieldObject *pFieldUNSAFE) return pField->GetOffset(); } - UINT32 externalOffset; + UINT32 externalOffset = 0; HELPER_METHOD_FRAME_BEGIN_RET_1(refField); { diff --git a/src/coreclr/vm/nativeoverlapped.cpp b/src/coreclr/vm/nativeoverlapped.cpp index c6c3bb61033..6c8f56a12ac 100644 --- a/src/coreclr/vm/nativeoverlapped.cpp +++ b/src/coreclr/vm/nativeoverlapped.cpp @@ -92,10 +92,9 @@ FCIMPL1(LPOVERLAPPED, AllocateNativeOverlapped, OverlappedDataObject* overlapped { FCALL_CONTRACT; - LPOVERLAPPED lpOverlapped; - - OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(overlappedUNSAFE); - OBJECTREF userObject = overlapped->m_userObject; + LPOVERLAPPED lpOverlapped = NULL; + OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(overlappedUNSAFE); + OBJECTREF userObject = overlapped->m_userObject; HELPER_METHOD_FRAME_BEGIN_RET_ATTRIB_2(Frame::FRAME_ATTR_NONE, overlapped, userObject); diff --git a/src/coreclr/vm/peimagelayout.cpp b/src/coreclr/vm/peimagelayout.cpp index ae2d2ca5f4b..4f89c7ce56f 100644 --- a/src/coreclr/vm/peimagelayout.cpp +++ b/src/coreclr/vm/peimagelayout.cpp @@ -24,7 +24,7 @@ extern "C" PEImageLayout* PEImageLayout::CreateFromByteArray(PEImage* pOwner, const BYTE* array, COUNT_T size) { STANDARD_VM_CONTRACT; - return new FlatImageLayout(pOwner, array, size); + return new FlatImageLayout(pOwner, array, size); } #ifndef TARGET_UNIX @@ -954,6 +954,7 @@ void* FlatImageLayout::LoadImageByMappingParts(SIZE_T* m_imageParts) const SIZE_T offset = (SIZE_T)m_pOwner->GetOffset(); int imagePartIndex = 0; PVOID pReserved = NULL; + PVOID reservedEnd = NULL; IMAGE_NT_HEADERS* ntHeader = FindNTHeaders(); if ((ntHeader->OptionalHeader.FileAlignment < GetOsPageSize()) && @@ -983,7 +984,7 @@ void* FlatImageLayout::LoadImageByMappingParts(SIZE_T* m_imageParts) const if (pReserved == NULL) goto FAILED; - PVOID reservedEnd = (char*)pReserved + reserveSize; + reservedEnd = (char*)pReserved + reserveSize; IMAGE_DOS_HEADER* loadedHeader = (IMAGE_DOS_HEADER*)((SIZE_T)pReserved + OffsetWithinPage(offset)); _ASSERTE(OffsetWithinPage(offset) == OffsetWithinPage((SIZE_T)loadedHeader)); diff --git a/src/coreclr/vm/reflectioninvocation.cpp b/src/coreclr/vm/reflectioninvocation.cpp index 2b403a32767..1f24faf245d 100644 --- a/src/coreclr/vm/reflectioninvocation.cpp +++ b/src/coreclr/vm/reflectioninvocation.cpp @@ -1058,6 +1058,11 @@ FCIMPL5(Object*, RuntimeMethodHandle::InvokeMethod, gc.retVal = GET_THROWABLE(); _ASSERTE(gc.retVal); +#ifdef _MSC_VER + // Workaround bogus MSVC warning about uninitialized local variables + *(BYTE*)&callDescrData.returnValue = 0; +#endif + fExceptionThrown = true; } EX_END_CATCH(SwallowAllExceptions); @@ -1068,7 +1073,6 @@ FCIMPL5(Object*, RuntimeMethodHandle::InvokeMethod, CallDescrWorkerWithHandler(&callDescrData); } - // Now that we are safely out of the catch block, we can create and raise the // TargetInvocationException. if (fExceptionThrown) diff --git a/src/coreclr/vm/runtimehandles.cpp b/src/coreclr/vm/runtimehandles.cpp index fdb3a19cfd0..51cce934ef4 100644 --- a/src/coreclr/vm/runtimehandles.cpp +++ b/src/coreclr/vm/runtimehandles.cpp @@ -1241,7 +1241,7 @@ FCIMPL2(FC_BOOL_RET, RuntimeTypeHandle::CanCastTo, ReflectClassBaseObject *pType FC_RETURN_BOOL((BOOL)r); } - BOOL iRetVal; + BOOL iRetVal = FALSE; HELPER_METHOD_FRAME_BEGIN_RET_2(refType, refTarget); { // We allow T to be cast to Nullable<T> diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index aac691f4208..c7e1653b043 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -2195,7 +2195,7 @@ HANDLE Thread::CreateUtilityThread(Thread::StackSizeBucket stackSizeBucket, LPTH default: _ASSERTE(!"Bad stack size bucket"); - break; + FALLTHROUGH; case StackSize_Large: stackSize = 1024 * 1024; break; @@ -2208,7 +2208,6 @@ HANDLE Thread::CreateUtilityThread(Thread::StackSizeBucket stackSizeBucket, LPTH SetThreadName(hThread, pName); - if (pThreadId) *pThreadId = threadId; diff --git a/src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp b/src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp index 789dd545e15..cf3571f4ed9 100644 --- a/src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp +++ b/src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp @@ -26,14 +26,14 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE XorBoolArray(SAFEARRAY* d, BOOL* VARIANT_BOOL* values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { *result ^= values[i] == VARIANT_TRUE ? TRUE : FALSE; } RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -58,7 +58,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE MeanDecimalArray(SAFEARRAY* d, D DECIMAL* values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { DECIMAL lhs = sum; @@ -71,7 +71,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE MeanDecimalArray(SAFEARRAY* d, D VarDecDiv(&sum, &numElements, result); RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -94,7 +94,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE SumCurrencyArray(SAFEARRAY* d, C CY* values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { CY lhs = sum; @@ -104,7 +104,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE SumCurrencyArray(SAFEARRAY* d, C *result = sum; RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -165,7 +165,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE ReverseStrings(SAFEARRAY* d) void** values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { if (elementType == VT_LPSTR) @@ -189,7 +189,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE ReverseStrings(SAFEARRAY* d) } RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -211,7 +211,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE VerifyInterfaceArray(SAFEARRAY* IUnknown** values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { values[i]->AddRef(); @@ -219,7 +219,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE VerifyInterfaceArray(SAFEARRAY* } RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -242,7 +242,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE MeanVariantIntArray(SAFEARRAY* d VARIANT* values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { if (values[i].vt != VT_I4) @@ -250,14 +250,14 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE MeanVariantIntArray(SAFEARRAY* d RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); return E_INVALIDARG; } - + *result += values[i].intVal; } *result /= upperBoundIndex - lowerBoundIndex + 1; RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } @@ -280,9 +280,9 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE DistanceBetweenDates(SAFEARRAY* DATE* values; RETURN_IF_FAILED(::SafeArrayAccessData(d, (void**)&values)); - + bool haveLastValue = false; - DATE lastValue; + DATE lastValue = {}; for(long i = lowerBoundIndex; i <= upperBoundIndex; i++) { @@ -296,7 +296,7 @@ extern "C" DLL_EXPORT HRESULT STDMETHODCALLTYPE DistanceBetweenDates(SAFEARRAY* } RETURN_IF_FAILED(::SafeArrayUnaccessData(d)); - + return S_OK; } |