Skip to content

Commit a5ec8aa

Browse files
Reenable CA 4701 (#66676)
* Reenable 4701 Co-authored-by: Jan Kotas <[email protected]>
1 parent 82239a2 commit a5ec8aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+152
-143
lines changed

eng/native/configurecompiler.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ if (MSVC)
600600
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
601601
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4505>) # unreferenced function with internal linkage has been removed
602602
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4611>) # interaction between 'function' and C++ object destruction is non-portable
603-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4701>) # potentially uninitialized local variable 'var' used
604603
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4702>) # unreachable code
605604
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4703>) # potentially uninitialized local pointer variable 'var' used
606605
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4706>) # assignment within conditional expression

src/coreclr/classlibnative/bcltype/arraynative.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ ArrayNative::AssignArrayEnum ArrayNative::CanAssignArrayType(const BASEARRAYREF
228228
TypeHandle srcTH = pSrcMT->GetArrayElementTypeHandle();
229229
TypeHandle destTH = pDestMT->GetArrayElementTypeHandle();
230230
_ASSERTE(srcTH != destTH); // Handled by fast path
231-
231+
232232
// Value class boxing
233233
if (srcTH.IsValueType() && !destTH.IsValueType())
234234
{
@@ -862,7 +862,7 @@ FCIMPL4(Object*, ArrayNative::CreateInstance, ReflectClassBaseObject* pElementTy
862862
HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(pElementType);
863863

864864
TypeHandle elementType(pElementType->GetType());
865-
865+
866866
CheckElementType(elementType);
867867

868868
CorElementType CorType = elementType.GetSignatureCorElementType();
@@ -956,7 +956,7 @@ FCIMPL2(Object*, ArrayNative::GetValue, ArrayBase* refThisUNSAFE, INT_PTR flatte
956956

957957
_ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents());
958958
void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize();
959-
OBJECTREF Obj;
959+
OBJECTREF Obj = NULL;
960960

961961
MethodTable* pElementTypeMT = arrayElementType.GetMethodTable();
962962
if (pElementTypeMT->IsValueType())
@@ -1146,7 +1146,7 @@ FCIMPL3_VVI(void*, ArrayNative::GetSpanDataFrom, FCALLRuntimeFieldHandle structF
11461146
} gc;
11471147
gc.refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField));
11481148
gc.refClass = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(FCALL_RTH_TO_REFLECTCLASS(targetTypeUnsafe));
1149-
void* data;
1149+
void* data = NULL;
11501150
HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
11511151

11521152
FieldDesc* pField = (FieldDesc*)gc.refField->GetField();

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4377,7 +4377,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
43774377
ClrDataModule* pubModule = NULL;
43784378
ClrDataMethodInstance* pubMethodInst = NULL;
43794379
ClrDataExceptionState* pubExState = NULL;
4380-
GcEvtArgs pubGcEvtArgs;
4380+
GcEvtArgs pubGcEvtArgs = {};
43814381
ULONG32 notifyType = 0;
43824382
DWORD catcherNativeOffset = 0;
43834383
TADDR nativeCodeLocation = NULL;
@@ -5491,7 +5491,7 @@ HRESULT
54915491
ClrDataAccess::Initialize(void)
54925492
{
54935493
HRESULT hr;
5494-
CLRDATA_ADDRESS base;
5494+
CLRDATA_ADDRESS base = { 0 };
54955495

54965496
//
54975497
// We do not currently support cross-platform
@@ -6458,7 +6458,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64586458
{
64596459
SUPPORTS_DAC_HOST_ONLY;
64606460
PEImage *mdImage = NULL;
6461-
PEImageLayout *layout;
6461+
PEImageLayout *layout = NULL;
64626462
IMAGE_DATA_DIRECTORY *pDir = NULL;
64636463
COUNT_T uniPathChars = 0;
64646464

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,7 @@ void DacDbiInterfaceImpl::GetMethodDescParams(
27962796
*pcGenericClassTypeParams = cGenericClassTypeParams;
27972797

27982798
TypeHandle thSpecificClass;
2799-
MethodDesc * pSpecificMethod;
2799+
MethodDesc * pSpecificMethod = NULL;
28002800

28012801
// Try to retrieve a more specific MethodDesc and TypeHandle via the generics type token.
28022802
// The generics token is not always guaranteed to be available.

src/coreclr/debug/daccess/enummem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags,
830830
// MethodTable
831831
ReleaseHolder<IXCLRDataValue> pDV(NULL);
832832
ReleaseHolder<IXCLRDataValue> pAssociatedValue(NULL);
833-
CLRDATA_ADDRESS address;
833+
CLRDATA_ADDRESS address = 0;
834834
PTR_Object pObjThis = NULL;
835835

836836
if (SUCCEEDED(pFrame->GetArgumentByIndex(0, &pDV, 0, NULL, NULL)) &&

src/coreclr/debug/dbgutil/dbgutil.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget,
6464

6565
// after the signature is a 20 byte image file header
6666
// we need to parse this to figure out the target architecture
67-
IMAGE_FILE_HEADER imageFileHeader;
67+
IMAGE_FILE_HEADER imageFileHeader = {};
6868
if (SUCCEEDED(hr))
6969
{
7070
hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer + 4, (BYTE*)&imageFileHeader, IMAGE_SIZEOF_FILE_HEADER);
7171
}
7272

73-
74-
7573
WORD optHeaderMagic = 0;
7674
DWORD peOptImageHeaderFilePointer = 0;
7775
if (SUCCEEDED(hr))

src/coreclr/debug/di/module.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,9 +3258,8 @@ HRESULT CordbILCode::GetLocalVarSig(SigParser *pLocalSigParser,
32583258
// A function will not have a local var sig if it has no locals!
32593259
if (m_localVarSigToken != mdSignatureNil)
32603260
{
3261-
PCCOR_SIGNATURE localSignature;
3262-
ULONG size;
3263-
uint32_t localCount;
3261+
PCCOR_SIGNATURE localSignature = NULL;
3262+
ULONG size = 0;
32643263

32653264
EX_TRY // // @dbgtodo exceptions - push this up
32663265
{
@@ -3286,6 +3285,7 @@ HRESULT CordbILCode::GetLocalVarSig(SigParser *pLocalSigParser,
32863285
_ASSERTE(data == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG);
32873286

32883287
// Snagg the count of locals in the sig.
3288+
uint32_t localCount;
32893289
IfFailRet(sigParser.GetData(&localCount));
32903290
LOG((LF_CORDB, LL_INFO100000, "CIC::GLVS localCount=0x%x\n", localCount));
32913291
if (pLocalSigParser != NULL)

src/coreclr/debug/di/process.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ HRESULT CordbRefEnum::Next(ULONG celt, COR_GC_REFERENCE refs[], ULONG *pceltFetc
27262726
{
27272727
CordbAppDomain *pDomain = process->LookupOrCreateAppDomain(dacRefs[i].vmDomain);
27282728

2729-
ICorDebugAppDomain *pAppDomain;
2729+
ICorDebugAppDomain *pAppDomain = NULL;
27302730
ICorDebugValue *pOutObject = NULL;
27312731
if (dacRefs[i].pObject & 1)
27322732
{
@@ -11440,9 +11440,6 @@ void CordbWin32EventThread::Win32EventLoop()
1144011440

1144111441
LOG((LF_CORDB, LL_INFO1000, "W32ET::W32EL: entered win32 event loop\n"));
1144211442

11443-
11444-
DEBUG_EVENT event;
11445-
1144611443
// Allow the timeout for WFDE to be adjustable. Default to 25 ms based off perf numbers (see issue VSWhidbey 132368).
1144711444
DWORD dwWFDETimeout = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgWFDETimeout);
1144811445

@@ -11468,7 +11465,7 @@ void CordbWin32EventThread::Win32EventLoop()
1146811465
rghWaitSet[0] = m_threadControlEvent;
1146911466

1147011467
DWORD dwWaitTimeout = INFINITE;
11471-
11468+
DEBUG_EVENT event = {};
1147211469
if (m_pProcess != NULL)
1147311470
{
1147411471
// Process is always built on Native debugging pipeline, so it needs to always be prepared to call WFDE

src/coreclr/debug/di/rsclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ HRESULT CordbClass::GetStaticFieldValue2(CordbModule * pModule,
335335
!pFieldData->m_fFldIsTLS);
336336

337337
TargetBuffer remoteValue(pRmtStaticValue, CordbValue::GetSizeForType(pType, fIsBoxed ? kBoxed : kUnboxed));
338-
ICorDebugValue * pValue;
338+
ICorDebugValue * pValue = NULL;
339339

340340
EX_TRY
341341
{

src/coreclr/debug/di/rsfunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,8 @@ HRESULT CordbFunction::GetSig(SigParser *pMethodSigParser,
10101010
// may change and the cached value will not match.
10111011
if (!m_fCachedMethodValuesValid)
10121012
{
1013-
PCCOR_SIGNATURE functionSignature;
1014-
ULONG size;
1013+
PCCOR_SIGNATURE functionSignature = NULL;
1014+
ULONG size = 0;
10151015
DWORD methodAttr = 0;
10161016
uint32_t argCount;
10171017

src/coreclr/debug/di/rsthread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6884,7 +6884,7 @@ CordbNativeFrame::GetLocalMemoryValue(CORDB_ADDRESS address,
68846884
_ASSERTE(m_nativeCode->GetFunction() != NULL);
68856885
HRESULT hr = S_OK;
68866886

6887-
ICorDebugValue *pValue;
6887+
ICorDebugValue *pValue = NULL;
68886888
EX_TRY
68896889
{
68906890
CordbValue::CreateValueByType(GetCurrentAppDomain(),

src/coreclr/debug/di/rstype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ HRESULT CordbType::GetTypeID(COR_TYPEID *pId)
23132313
hr = Init(FALSE);
23142314
IfFailThrow(hr);
23152315

2316-
VMPTR_TypeHandle vmTypeHandle;
2316+
VMPTR_TypeHandle vmTypeHandle = VMPTR_TypeHandle::NullPtr();
23172317

23182318
CorElementType et = GetElementType();
23192319
switch (et)

src/coreclr/debug/di/valuehome.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ void RegisterValueHome::SetEnregisteredValue(MemoryRange src, bool fIsSigned)
800800
{
801801
_ASSERTE(m_pRemoteRegAddr != NULL);
802802
// Get the thread's context so we can update it.
803-
DT_CONTEXT * cTemp;
803+
DT_CONTEXT * cTemp = NULL;
804804
const CordbNativeFrame * frame = m_pRemoteRegAddr->GetFrame();
805805

806806
// Can't set an enregistered value unless the frame the value was

src/coreclr/debug/ee/debugger.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,11 +4041,13 @@ GetSetFrameHelper::Init(MethodDesc *pMD)
40414041
mdSignature mdLocalSig = (decoderOldIL.GetLocalVarSigTok()) ? (decoderOldIL.GetLocalVarSigTok()):
40424042
(mdSignatureNil);
40434043

4044+
PCCOR_SIGNATURE pLocalSig = NULL;
4045+
ULONG cbLocalSigSize = 0;
4046+
40444047
PCCOR_SIGNATURE pCallSig;
40454048
DWORD cbCallSigSize;
40464049

40474050
pMD->GetSig(&pCallSig, &cbCallSigSize);
4048-
40494051
if (pCallSig != NULL)
40504052
{
40514053
// Yes, we do need to pass in the text because this might be generic function!
@@ -4079,18 +4081,15 @@ GetSetFrameHelper::Init(MethodDesc *pMD)
40794081
}
40804082

40814083
// allocation of pArgSig succeeded
4082-
ULONG cbSig;
4083-
PCCOR_SIGNATURE pLocalSig;
4084-
pLocalSig = NULL;
40854084
if (mdLocalSig != mdSignatureNil)
40864085
{
4087-
IfFailGo(pMD->GetModule()->GetMDImport()->GetSigFromToken(mdLocalSig, &cbSig, &pLocalSig));
4086+
IfFailGo(pMD->GetModule()->GetMDImport()->GetSigFromToken(mdLocalSig, &cbLocalSigSize, &pLocalSig));
40884087
}
40894088
if (pLocalSig != NULL)
40904089
{
40914090
SigTypeContext tmpContext(pMD);
40924091
pLocSig = new (interopsafe, nothrow) MetaSig(pLocalSig,
4093-
cbSig,
4092+
cbLocalSigSize,
40944093
pMD->GetModule(),
40954094
&tmpContext,
40964095
MetaSig::sigLocalVars);
@@ -10510,7 +10509,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1051010509
// If we haven't been either JITted or EnC'd yet, then
1051110510
// we'll put a patch in by offset, implicitly relative
1051210511
// to the first version of the code.
10513-
10512+
fSuccess = FALSE;
1051410513
pDebuggerBP = new (interopsafe, nothrow) DebuggerBreakpoint(pModule,
1051510514
pEvent->BreakpointData.funcMetadataToken,
1051610515
pEvent->vmAppDomain.GetRawPtr(),
@@ -11111,12 +11110,14 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1111111110
objectHandle = pAppDomain->CreatePinningHandle(objref);
1111211111
break;
1111311112
default:
11113+
objectHandle = NULL;
1111411114
pEvent->hr = E_INVALIDARG;
1111511115
}
11116-
}
11117-
if (SUCCEEDED(pEvent->hr))
11118-
{
11119-
pEvent->CreateHandleResult.vmObjectHandle.SetRawPtr(objectHandle);
11116+
11117+
if (SUCCEEDED(pEvent->hr))
11118+
{
11119+
pEvent->CreateHandleResult.vmObjectHandle.SetRawPtr(objectHandle);
11120+
}
1112011121
}
1112111122
}
1112211123

src/coreclr/debug/shim/debugshim.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ STDMETHODIMP CLRDebuggingImpl::OpenVirtualProcess(
9797
HMODULE hDac = NULL;
9898
LPWSTR pDacModulePath = NULL;
9999
LPWSTR pDbiModulePath = NULL;
100-
DWORD dbiTimestamp;
101-
DWORD dbiSizeOfImage;
100+
DWORD dbiTimestamp = 0;
101+
DWORD dbiSizeOfImage = 0;
102102
WCHAR dbiName[MAX_PATH_FNAME] = { 0 };
103103
DWORD dacTimestamp;
104104
DWORD dacSizeOfImage;
105105
WCHAR dacName[MAX_PATH_FNAME] = { 0 };
106-
CLR_DEBUGGING_VERSION version;
106+
CLR_DEBUGGING_VERSION version = { 0 };
107107
BOOL versionSupportedByCaller = FALSE;
108108

109109
// argument checking
@@ -541,7 +541,7 @@ HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget* pDataTarget,
541541
hr = CORDBG_E_NOT_CLR;
542542
}
543543

544-
CLR_DEBUG_RESOURCE debugResource;
544+
CLR_DEBUG_RESOURCE debugResource = {};
545545
if(SUCCEEDED(hr) && debugResourceSize != sizeof(debugResource))
546546
{
547547
hr = CORDBG_E_NOT_CLR;

src/coreclr/gc/gc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26993,7 +26993,7 @@ void gc_heap::check_loh_compact_mode (BOOL all_heaps_compacted_p)
2699326993
BOOL gc_heap::plan_loh()
2699426994
{
2699526995
#ifdef FEATURE_EVENT_TRACE
26996-
uint64_t start_time, end_time;
26996+
uint64_t start_time = 0, end_time;
2699726997
if (informational_event_enabled_p)
2699826998
{
2699926999
memset (loh_compact_info, 0, (sizeof (etw_loh_compact_info) * get_num_heaps()));
@@ -27161,7 +27161,7 @@ void gc_heap::compact_loh()
2716127161
assert (loh_compaction_requested() || heap_hard_limit || conserve_mem_setting);
2716227162

2716327163
#ifdef FEATURE_EVENT_TRACE
27164-
uint64_t start_time, end_time;
27164+
uint64_t start_time = 0, end_time;
2716527165
if (informational_event_enabled_p)
2716627166
{
2716727167
start_time = GetHighPrecisionTimeStamp();
@@ -27324,7 +27324,7 @@ void gc_heap::relocate_in_loh_compact()
2732427324
#ifdef FEATURE_EVENT_TRACE
2732527325
size_t total_refs = 0;
2732627326
size_t zero_refs = 0;
27327-
uint64_t start_time, end_time;
27327+
uint64_t start_time = 0, end_time;
2732827328
if (informational_event_enabled_p)
2732927329
{
2733027330
start_time = GetHighPrecisionTimeStamp();
@@ -30918,7 +30918,7 @@ void gc_heap::make_free_lists (int condemned_gen_number)
3091830918
//Promotion has to happen in sweep case.
3091930919
assert (settings.promotion);
3092030920

30921-
make_free_args args;
30921+
make_free_args args = {};
3092230922
int stop_gen_idx = get_stop_generation_index (condemned_gen_number);
3092330923
for (int i = condemned_gen_number; i >= stop_gen_idx; i--)
3092430924
{

src/coreclr/gc/windows/gcenv.windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n
11811181
bool success = false;
11821182

11831183
// Locate heap_number-th available processor
1184-
uint16_t procIndex;
1184+
uint16_t procIndex = 0;
11851185
size_t cnt = heap_number;
11861186
for (uint16_t i = 0; i < GCToOSInterface::GetTotalProcessorCount(); i++)
11871187
{

src/coreclr/ilasm/assembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ void Assembler::EmitLocals(BinStr* sig)
11611161
ARG_NAME_LIST *pAN, *pList= getArgNameList();
11621162
if(pList)
11631163
{
1164-
VarDescr* pVD;
1164+
VarDescr* pVD = NULL;
11651165
for(pAN=pList; pAN; pAN = pAN->pNext)
11661166
{
11671167
if(pAN->dwAttr == 0) pAN->dwAttr = m_pCurMethod->m_Locals.COUNT() +1;

src/coreclr/ilasm/grammar_after.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ char* NewStaticStrFromTokenW(_In_reads_(tokLen) char* curTok, size_t tokLen, _Ou
137137
unsigned GetDoubleAU(_In_ __nullterminated char* begNum, unsigned L, double** ppRes)
138138
{
139139
static char dbuff[128];
140-
char* pdummy;
140+
char* pdummy = NULL;
141141
if(L > 127) L = 127;
142142
memcpy(dbuff,begNum,L);
143143
dbuff[L] = 0;
@@ -148,7 +148,7 @@ unsigned GetDoubleAU(_In_ __nullterminated char* begNum, unsigned L, double** pp
148148
unsigned GetDoubleW(_In_ __nullterminated char* begNum, unsigned L, double** ppRes)
149149
{
150150
static char dbuff[256];
151-
char* pdummy;
151+
char* pdummy = NULL;
152152
if(L > 254) L = 254;
153153
memcpy(dbuff,begNum,L);
154154
dbuff[L] = 0;

0 commit comments

Comments
 (0)