Skip to content

Commit

Permalink
Reenable CA 4701 (dotnet#66676)
Browse files Browse the repository at this point in the history
* Reenable 4701

Co-authored-by: Jan Kotas <[email protected]>
  • Loading branch information
AaronRobinsonMSFT and jkotas authored Mar 17, 2022
1 parent 82239a2 commit a5ec8aa
Show file tree
Hide file tree
Showing 50 changed files with 152 additions and 143 deletions.
1 change: 0 additions & 1 deletion eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/classlibnative/bcltype/arraynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -5491,7 +5491,7 @@ HRESULT
ClrDataAccess::Initialize(void)
{
HRESULT hr;
CLRDATA_ADDRESS base;
CLRDATA_ADDRESS base = { 0 };

//
// We do not currently support cross-platform
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &&
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/debug/dbgutil/dbgutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/di/rsfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rstype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/valuehome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/debug/shim/debugshim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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--)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/windows/gcenv.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ilasm/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/ilasm/grammar_after.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit a5ec8aa

Please sign in to comment.