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

0 commit comments

Comments
 (0)