From 086f19f1b19ebdc83d398eaf094c21df741578ab Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 8 Apr 2024 15:34:36 -0700 Subject: [PATCH 01/10] Fix NULL conversion warnings found in Alpine x64 Source-Build --- src/coreclr/binder/assemblybindercommon.cpp | 2 +- src/coreclr/binder/customassemblybinder.cpp | 8 +- src/coreclr/binder/defaultassemblybinder.cpp | 6 +- .../classlibnative/bcltype/arraynative.cpp | 2 +- src/coreclr/debug/daccess/daccess.cpp | 18 +-- src/coreclr/debug/daccess/dacdbiimpl.cpp | 50 +++---- .../debug/daccess/dacdbiimplstackwalk.cpp | 6 +- src/coreclr/debug/daccess/dacfn.cpp | 2 +- src/coreclr/debug/daccess/dacimpl.h | 2 +- src/coreclr/debug/daccess/enummem.cpp | 10 +- src/coreclr/debug/daccess/request.cpp | 112 +++++++-------- src/coreclr/debug/daccess/task.cpp | 2 +- src/coreclr/debug/di/divalue.cpp | 18 +-- src/coreclr/debug/di/module.cpp | 14 +- src/coreclr/debug/di/process.cpp | 16 +-- src/coreclr/debug/di/rsclass.cpp | 8 +- src/coreclr/debug/di/rspriv.h | 8 +- src/coreclr/debug/di/rsthread.cpp | 20 +-- src/coreclr/debug/ee/amd64/walker.cpp | 6 +- src/coreclr/debug/ee/controller.cpp | 8 +- src/coreclr/debug/ee/debugger.cpp | 16 +-- src/coreclr/debug/ee/debugger.h | 10 +- src/coreclr/debug/ee/debugger.inl | 2 +- src/coreclr/debug/ee/frameinfo.cpp | 6 +- src/coreclr/debug/ee/funceval.cpp | 6 +- src/coreclr/debug/ee/functioninfo.cpp | 8 +- src/coreclr/debug/inc/dacdbistructures.h | 2 +- src/coreclr/debug/inc/dacdbistructures.inl | 14 +- src/coreclr/debug/inc/dbgappdomain.h | 4 +- src/coreclr/debug/inc/dbgipcevents.h | 2 +- src/coreclr/debug/shared/utils.cpp | 8 +- src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp | 6 +- src/coreclr/ilasm/asmparse.y | 6 +- src/coreclr/ilasm/assembler.cpp | 4 +- src/coreclr/ilasm/prebuilt/asmparse.cpp | 6 +- src/coreclr/ilasm/writer.cpp | 2 +- src/coreclr/ildasm/dasm.cpp | 6 +- src/coreclr/inc/clrconfig.h | 2 +- src/coreclr/inc/clrhost.h | 4 +- src/coreclr/inc/daccess.h | 62 ++++++++ src/coreclr/inc/holder.h | 6 +- src/coreclr/inc/pedecoder.inl | 6 +- src/coreclr/inc/profilepriv.inl | 2 +- src/coreclr/inc/regdisp.h | 4 +- src/coreclr/inc/sbuffer.inl | 2 +- src/coreclr/inc/stackframe.h | 6 +- src/coreclr/inc/stresslog.h | 2 +- src/coreclr/inc/utilcode.h | 2 +- src/coreclr/jit/emitarm.cpp | 2 +- src/coreclr/md/datasource/targettypes.cpp | 2 +- src/coreclr/md/enc/liteweightstgdbrw.cpp | 4 +- src/coreclr/md/enc/mdinternalrw.cpp | 2 +- src/coreclr/md/enc/stgtiggerstorage.cpp | 2 +- .../tools/StressLogAnalyzer/StressLogDump.cpp | 2 +- src/coreclr/unwinder/baseunwinder.cpp | 2 +- src/coreclr/utilcode/arraylist.cpp | 2 +- src/coreclr/utilcode/corimage.cpp | 2 +- src/coreclr/utilcode/loaderheap.cpp | 26 ++-- src/coreclr/utilcode/namespaceutil.cpp | 2 +- src/coreclr/utilcode/pedecoder.cpp | 10 +- src/coreclr/vm/amd64/cgenamd64.cpp | 4 +- src/coreclr/vm/amd64/cgencpu.h | 2 +- src/coreclr/vm/amd64/excepamd64.cpp | 2 +- src/coreclr/vm/amd64/gmscpu.h | 2 +- src/coreclr/vm/appdomain.hpp | 2 +- src/coreclr/vm/assemblynative.cpp | 6 +- src/coreclr/vm/baseassemblyspec.inl | 4 +- src/coreclr/vm/callcounting.cpp | 4 +- src/coreclr/vm/callhelpers.h | 4 +- src/coreclr/vm/ceeload.cpp | 12 +- src/coreclr/vm/ceeload.inl | 6 +- src/coreclr/vm/classhash.inl | 2 +- src/coreclr/vm/clrex.h | 2 +- src/coreclr/vm/clsload.hpp | 2 +- src/coreclr/vm/codeman.cpp | 22 +-- src/coreclr/vm/codeman.h | 6 +- src/coreclr/vm/codeversion.cpp | 16 +-- src/coreclr/vm/codeversion.h | 2 +- src/coreclr/vm/comcallablewrapper.cpp | 6 +- src/coreclr/vm/comcallablewrapper.h | 8 +- src/coreclr/vm/comconnectionpoints.h | 6 +- src/coreclr/vm/comdelegate.cpp | 14 +- src/coreclr/vm/contractimpl.h | 4 +- src/coreclr/vm/corhost.cpp | 4 +- src/coreclr/vm/crossloaderallocatorhash.h | 4 +- src/coreclr/vm/custommarshalerinfo.cpp | 4 +- src/coreclr/vm/dacenumerablehash.inl | 6 +- src/coreclr/vm/debugdebugger.cpp | 6 +- src/coreclr/vm/debuginfostore.cpp | 2 +- src/coreclr/vm/dllimport.cpp | 12 +- src/coreclr/vm/dllimportcallback.cpp | 2 +- src/coreclr/vm/domainassembly.cpp | 12 +- src/coreclr/vm/dynamicmethod.cpp | 2 +- src/coreclr/vm/eedbginterfaceimpl.cpp | 6 +- src/coreclr/vm/eetoprofinterfaceimpl.cpp | 4 +- src/coreclr/vm/eetoprofinterfaceimpl.h | 8 +- src/coreclr/vm/eetoprofinterfaceimpl.inl | 2 +- src/coreclr/vm/eetwain.cpp | 2 +- src/coreclr/vm/encee.cpp | 4 +- .../vm/eventing/eventpipe/ep-rt-coreclr.cpp | 4 +- src/coreclr/vm/eventpipeinternal.cpp | 2 +- src/coreclr/vm/eventtrace.cpp | 4 +- src/coreclr/vm/excep.cpp | 2 +- src/coreclr/vm/excep.h | 2 +- src/coreclr/vm/exceptionhandling.cpp | 20 +-- src/coreclr/vm/exceptionhandling.h | 6 +- src/coreclr/vm/exinfo.cpp | 2 +- src/coreclr/vm/exstate.cpp | 2 +- src/coreclr/vm/fptrstubs.cpp | 4 +- src/coreclr/vm/frames.cpp | 12 +- src/coreclr/vm/frames.h | 24 ++-- src/coreclr/vm/gchandleutilities.h | 6 +- src/coreclr/vm/genmeth.cpp | 2 +- src/coreclr/vm/hash.cpp | 2 +- src/coreclr/vm/ilstubresolver.cpp | 2 +- src/coreclr/vm/ilstubresolver.h | 4 +- src/coreclr/vm/interoputil.cpp | 6 +- src/coreclr/vm/invokeutil.cpp | 2 +- src/coreclr/vm/jithelpers.cpp | 22 +-- src/coreclr/vm/jitinterface.cpp | 12 +- src/coreclr/vm/jitinterface.h | 4 +- src/coreclr/vm/listlock.h | 2 +- src/coreclr/vm/loaderallocator.cpp | 4 +- src/coreclr/vm/marshalnative.cpp | 4 +- src/coreclr/vm/memberload.cpp | 6 +- src/coreclr/vm/method.cpp | 20 +-- src/coreclr/vm/method.hpp | 10 +- src/coreclr/vm/methodtable.cpp | 14 +- src/coreclr/vm/methodtable.h | 4 +- src/coreclr/vm/methodtablebuilder.h | 24 ++-- src/coreclr/vm/multicorejit.h | 6 +- src/coreclr/vm/multicorejitplayer.cpp | 2 +- src/coreclr/vm/nativelibrary.cpp | 6 +- src/coreclr/vm/nativelibrarynative.cpp | 2 +- src/coreclr/vm/object.h | 6 +- src/coreclr/vm/olevariant.cpp | 12 +- src/coreclr/vm/peassembly.inl | 2 +- src/coreclr/vm/peimagelayout.cpp | 2 +- src/coreclr/vm/peimagelayout.inl | 2 +- src/coreclr/vm/perfmap.cpp | 2 +- src/coreclr/vm/precode.cpp | 12 +- src/coreclr/vm/precode.h | 2 +- src/coreclr/vm/prestub.cpp | 82 +++++------ src/coreclr/vm/proftoeeinterfaceimpl.cpp | 132 +++++++++--------- src/coreclr/vm/readytoruninfo.cpp | 4 +- src/coreclr/vm/reflectioninvocation.cpp | 10 +- src/coreclr/vm/runtimecallablewrapper.h | 12 +- src/coreclr/vm/stackwalk.cpp | 13 +- src/coreclr/vm/stackwalk.h | 2 +- src/coreclr/vm/stackwalktypes.h | 2 +- src/coreclr/vm/stringliteralmap.cpp | 2 +- src/coreclr/vm/stubgen.cpp | 4 +- src/coreclr/vm/stubhelpers.cpp | 4 +- src/coreclr/vm/stubmgr.cpp | 20 +-- src/coreclr/vm/stubmgr.h | 2 +- src/coreclr/vm/syncblk.cpp | 2 +- src/coreclr/vm/threads.cpp | 6 +- src/coreclr/vm/threads.h | 6 +- src/coreclr/vm/threads.inl | 2 +- src/coreclr/vm/threadstatics.cpp | 4 +- src/coreclr/vm/threadstatics.h | 4 +- src/coreclr/vm/tieredcompilation.cpp | 8 +- src/coreclr/vm/typedesc.cpp | 6 +- src/coreclr/vm/typehandle.cpp | 4 +- src/coreclr/vm/util.cpp | 14 +- src/coreclr/vm/util.hpp | 4 +- src/coreclr/vm/virtualcallstub.cpp | 22 +-- src/coreclr/vm/wrappers.h | 18 +-- 168 files changed, 769 insertions(+), 710 deletions(-) diff --git a/src/coreclr/binder/assemblybindercommon.cpp b/src/coreclr/binder/assemblybindercommon.cpp index 55f9a0ae533614..c58b502ec417de 100644 --- a/src/coreclr/binder/assemblybindercommon.cpp +++ b/src/coreclr/binder/assemblybindercommon.cpp @@ -1297,7 +1297,7 @@ HRESULT AssemblyBinderCommon::CreateDefaultBinder(DefaultAssemblyBinder** ppDefa hr = pApplicationContext->Init(); if (SUCCEEDED(hr)) { - pBinder->SetManagedAssemblyLoadContext(NULL); + pBinder->SetManagedAssemblyLoadContext((TADDR)0); *ppDefaultBinder = pBinder.Extract(); } } diff --git a/src/coreclr/binder/customassemblybinder.cpp b/src/coreclr/binder/customassemblybinder.cpp index ac1cf61bcf6a2e..dd0014043ad224 100644 --- a/src/coreclr/binder/customassemblybinder.cpp +++ b/src/coreclr/binder/customassemblybinder.cpp @@ -242,13 +242,13 @@ void CustomAssemblyBinder::PrepareForLoadContextRelease(INT_PTR ptrManagedStrong CustomAssemblyBinder::CustomAssemblyBinder() { m_pDefaultBinder = NULL; - m_ptrManagedStrongAssemblyLoadContext = NULL; + m_ptrManagedStrongAssemblyLoadContext = 0; } void CustomAssemblyBinder::ReleaseLoadContext() { - VERIFY(GetManagedAssemblyLoadContext() != NULL); - VERIFY(m_ptrManagedStrongAssemblyLoadContext != NULL); + VERIFY(GetManagedAssemblyLoadContext() != 0); + VERIFY(m_ptrManagedStrongAssemblyLoadContext != 0); // This method is called to release the weak and strong handles on the managed AssemblyLoadContext // once the Unloading event has been fired @@ -256,7 +256,7 @@ void CustomAssemblyBinder::ReleaseLoadContext() DestroyLongWeakHandle(handle); handle = reinterpret_cast(m_ptrManagedStrongAssemblyLoadContext); DestroyHandle(handle); - SetManagedAssemblyLoadContext(NULL); + SetManagedAssemblyLoadContext(0); // The AssemblyLoaderAllocator is in a process of shutdown and should not be used // after this point. diff --git a/src/coreclr/binder/defaultassemblybinder.cpp b/src/coreclr/binder/defaultassemblybinder.cpp index d4ad4f3265ce8b..f0296f4a03b83b 100644 --- a/src/coreclr/binder/defaultassemblybinder.cpp +++ b/src/coreclr/binder/defaultassemblybinder.cpp @@ -63,7 +63,7 @@ HRESULT DefaultAssemblyBinder::BindUsingAssemblyName(BINDER_SPACE::AssemblyName // Attempt to resolve the assembly via managed ALC instance. This can either fail the bind or return reference to an existing // assembly that has been loaded INT_PTR pManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(); - if (pManagedAssemblyLoadContext == NULL) + if (pManagedAssemblyLoadContext == 0) { // For satellite assemblies, the managed ALC has additional resolution logic (defined by the runtime) which // should be run even if the managed default ALC has not yet been used. (For non-satellite assemblies, any @@ -78,11 +78,11 @@ HRESULT DefaultAssemblyBinder::BindUsingAssemblyName(BINDER_SPACE::AssemblyName CALL_MANAGED_METHOD_NORET(args) pManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(); - _ASSERTE(pManagedAssemblyLoadContext != NULL); + _ASSERTE(pManagedAssemblyLoadContext != 0); } } - if (pManagedAssemblyLoadContext != NULL) + if (pManagedAssemblyLoadContext != 0) { hr = AssemblyBinderCommon::BindUsingHostAssemblyResolver(pManagedAssemblyLoadContext, pAssemblyName, NULL, this, &pCoreCLRFoundAssembly); diff --git a/src/coreclr/classlibnative/bcltype/arraynative.cpp b/src/coreclr/classlibnative/bcltype/arraynative.cpp index 32bc52b96f1a1d..6b6bb6ff5d32f1 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.cpp +++ b/src/coreclr/classlibnative/bcltype/arraynative.cpp @@ -32,7 +32,7 @@ extern "C" PCODE QCALLTYPE Array_GetElementConstructorEntrypoint(QCall::TypeHand { QCALL_CONTRACT; - PCODE ctorEntrypoint = NULL; + PCODE ctorEntrypoint = (PCODE)0; BEGIN_QCALL; diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index d6b8d99d7c37e9..ca8c76bf5b81f7 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -4324,7 +4324,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification( GcEvtArgs pubGcEvtArgs = {}; ULONG32 notifyType = 0; DWORD catcherNativeOffset = 0; - TADDR nativeCodeLocation = NULL; + TADDR nativeCodeLocation = (TADDR)NULL; DAC_ENTER(); @@ -4706,7 +4706,7 @@ ClrDataAccess::SetAllCodeNotifications( BOOL changedTable; TADDR modulePtr = mod ? PTR_HOST_TO_TADDR(((ClrDataModule*)mod)->GetModule()) : - NULL; + (TADDR)NULL; if (jn.SetAllNotifications(modulePtr, (USHORT)flags, &changedTable)) { @@ -4822,7 +4822,7 @@ ClrDataAccess::GetCodeNotifications( } else { - TADDR modulePtr = NULL; + TADDR modulePtr = (TADDR)NULL; if (singleMod) { modulePtr = PTR_HOST_TO_TADDR(((ClrDataModule*)singleMod)-> @@ -4908,7 +4908,7 @@ ClrDataAccess::SetCodeNotifications( goto Exit; } - TADDR modulePtr = NULL; + TADDR modulePtr = (TADDR)NULL; if (singleMod) { modulePtr = @@ -5952,10 +5952,10 @@ ClrDataAccess::GetMethodVarInfo(MethodDesc* methodDesc, COUNT_T countNativeVarInfo; NewHolder nativeVars(NULL); TADDR nativeCodeStartAddr; - if (address != NULL) + if (address != (TADDR)NULL) { NativeCodeVersion requestedNativeCodeVersion = ExecutionManager::GetNativeCodeVersion(address); - if (requestedNativeCodeVersion.IsNull() || requestedNativeCodeVersion.GetNativeCode() == NULL) + if (requestedNativeCodeVersion.IsNull() || requestedNativeCodeVersion.GetNativeCode() == (PCODE)NULL) { return E_INVALIDARG; } @@ -6010,10 +6010,10 @@ ClrDataAccess::GetMethodNativeMap(MethodDesc* methodDesc, // Use the DebugInfoStore to get IL->Native maps. // It doesn't matter whether we're jitted, ngenned etc. TADDR nativeCodeStartAddr; - if (address != NULL) + if (address != (TADDR)NULL) { NativeCodeVersion requestedNativeCodeVersion = ExecutionManager::GetNativeCodeVersion(address); - if (requestedNativeCodeVersion.IsNull() || requestedNativeCodeVersion.GetNativeCode() == NULL) + if (requestedNativeCodeVersion.IsNull() || requestedNativeCodeVersion.GetNativeCode() == (PCODE)NULL) { return E_INVALIDARG; } @@ -6947,7 +6947,7 @@ ClrDataAccess::GetDacGlobalValues() { return CORDBG_E_MISSING_DEBUGGER_EXPORTS; } - if (m_dacGlobals.ThreadStore__s_pThreadStore == NULL) + if (m_dacGlobals.ThreadStore__s_pThreadStore == (TADDR)NULL) { return CORDBG_E_UNSUPPORTED; } diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index d1a0a1ada64d49..cadf4e3730b589 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -1240,7 +1240,7 @@ mdSignature DacDbiInterfaceImpl::GetILCodeAndSigHelper(Module * pModule, pIL->cbSize = header.GetCodeSize(); // Now we get the signature token - if (header.LocalVarSigTok != NULL) + if (header.LocalVarSigTok != mdTokenNil) { mdSig = header.GetLocalVarSigTok(); } @@ -1314,14 +1314,14 @@ void DacDbiInterfaceImpl::GetMethodRegionInfo(MethodDesc * pMethodDe } CONTRACTL_END; - IJitManager::MethodRegionInfo methodRegionInfo = {NULL, 0, NULL, 0}; + IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0}; PCODE functionAddress = pMethodDesc->GetNativeCode(); // get the start address of the hot region and initialize the jit manager pCodeInfo->m_rgCodeRegions[kHot].pAddress = CORDB_ADDRESS(PCODEToPINSTR(functionAddress)); // if the start address is NULL, the code isn't available yet, so just return - if (functionAddress != NULL) + if (functionAddress != (PCODE)NULL) { EECodeInfo codeInfo(functionAddress); _ASSERTE(codeInfo.IsValid()); @@ -1372,7 +1372,7 @@ void DacDbiInterfaceImpl::GetNativeCodeInfo(VMPTR_DomainAssembly vmDomai if(pMethodDesc != NULL) { GetMethodRegionInfo(pMethodDesc, pCodeInfo); - if (pCodeInfo->m_rgCodeRegions[kHot].pAddress != NULL) + if (pCodeInfo->m_rgCodeRegions[kHot].pAddress != (CORDB_ADDRESS)NULL) { pCodeInfo->isInstantiatedGeneric = pMethodDesc->HasClassOrMethodInstantiation(); LookupEnCVersions(pModule, @@ -1397,14 +1397,14 @@ void DacDbiInterfaceImpl::GetNativeCodeInfoForAddr(VMPTR_MethodDesc vmMe _ASSERTE(pCodeInfo != NULL); - if (hotCodeStartAddr == NULL) + if (hotCodeStartAddr == (CORDB_ADDRESS)NULL) { // if the start address is NULL, the code isn't available yet, so just return _ASSERTE(!pCodeInfo->IsValid()); return; } - IJitManager::MethodRegionInfo methodRegionInfo = {NULL, 0, NULL, 0}; + IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0}; TADDR codeAddr = CORDB_ADDRESS_TO_TADDR(hotCodeStartAddr); #ifdef TARGET_ARM @@ -1655,7 +1655,7 @@ void DacDbiInterfaceImpl::ComputeFieldData(PTR_FieldDesc pFD, if (pCurrentFieldData->OkToGetOrSetStaticAddress()) { - pCurrentFieldData->SetStaticAddress(NULL); + pCurrentFieldData->SetStaticAddress((TADDR)NULL); } } else @@ -3192,7 +3192,7 @@ CORDB_ADDRESS DacDbiInterfaceImpl::GetThreadStaticAddress(VMPTR_FieldDesc vmFiel Thread * pRuntimeThread = vmRuntimeThread.GetDacPtr(); PTR_FieldDesc pFieldDesc = vmField.GetDacPtr(); - TADDR fieldAddress = NULL; + TADDR fieldAddress = (TADDR)NULL; _ASSERTE(pRuntimeThread != NULL); @@ -3441,7 +3441,7 @@ HRESULT DacDbiInterfaceImpl::GetDelegateType(VMPTR_Object delegateObject, Delega PTR_Object pInvocationList = OBJECTREFToObject(pDelObj->GetInvocationList()); - if (invocationCount == NULL) + if (invocationCount == 0) { if (pInvocationList == NULL) { @@ -3449,7 +3449,7 @@ HRESULT DacDbiInterfaceImpl::GetDelegateType(VMPTR_Object delegateObject, Delega // Special case: This might fail in a VSD delegate (instance open virtual)... // TODO: There is the special signatures cases missing. TADDR targetMethodPtr = PCODEToPINSTR(pDelObj->GetMethodPtrAux()); - if (targetMethodPtr == NULL) + if (targetMethodPtr == (TADDR)NULL) { // Static extension methods, other closed static delegates, and instance delegates fall into this category. *delegateType = kClosedDelegate; @@ -3501,7 +3501,7 @@ HRESULT DacDbiInterfaceImpl::GetDelegateFunctionData( HRESULT hr = S_OK; PTR_DelegateObject pDelObj = dac_cast(delegateObject.GetDacPtr()); - TADDR targetMethodPtr = NULL; + TADDR targetMethodPtr = (TADDR)NULL; VMPTR_MethodDesc pMD; switch (delegateType) @@ -3552,7 +3552,7 @@ HRESULT DacDbiInterfaceImpl::GetDelegateTargetObject( } default: - ppTargetObj->SetDacTargetPtr(NULL); + ppTargetObj->SetDacTargetPtr((TADDR)NULL); break; } @@ -4388,7 +4388,7 @@ void DacDbiInterfaceImpl::GetModuleData(VMPTR_Module vmModule, ModuleInfo * pDat // Get PE BaseAddress and Size // For dynamic modules, these are 0. Else, - pData->pPEBaseAddress = NULL; + pData->pPEBaseAddress = (CORDB_ADDRESS)NULL; pData->nPESize = 0; if (!fIsDynamic) @@ -4765,7 +4765,7 @@ BOOL DacDbiInterfaceImpl::HasUnhandledException(VMPTR_Thread vmThread) // most managed exceptions are just a throwable bound to a // native exception. In that case this handle will be non-null OBJECTHANDLE ohException = pThread->GetThrowableAsHandle(); - if (ohException != NULL) + if (ohException != (OBJECTHANDLE)NULL) { // during the UEF we set the unhandled bit, if it is set the exception // was unhandled @@ -4854,7 +4854,7 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetCurrentException(VMPTR_Thread vmThrea // OBJECTHANDLEs are really just TADDRs. OBJECTHANDLE ohException = pThread->GetThrowableAsHandle(); // ohException can be NULL - if (ohException == NULL) + if (ohException == (OBJECTHANDLE)NULL) { if (pThread->IsLastThrownObjectUnhandled()) { @@ -4872,7 +4872,7 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetObjectForCCW(CORDB_ADDRESS ccwPtr) { DD_ENTER_MAY_THROW; - OBJECTHANDLE ohCCW = NULL; + OBJECTHANDLE ohCCW = (OBJECTHANDLE)NULL; #ifdef FEATURE_COMWRAPPERS if (DACTryGetComWrappersHandleFromCCW(ccwPtr, &ohCCW) != S_OK) @@ -4963,13 +4963,13 @@ CLR_DEBUGGING_PROCESS_FLAGS DacDbiInterfaceImpl::GetAttachStateFlags() // Non-null Target Address of hijack function. TADDR DacDbiInterfaceImpl::GetHijackAddress() { - TADDR addr = NULL; + TADDR addr = (TADDR)NULL; if (g_pDebugger != NULL) { // Get the start address of the redirect function for unhandled exceptions. addr = dac_cast(g_pDebugger->m_rgHijackFunction[Debugger::kUnhandledException].StartAddress()); } - if (addr == NULL) + if (addr == (TADDR)NULL) { ThrowHR(CORDBG_E_NOTREADY); } @@ -5209,8 +5209,8 @@ void DacDbiInterfaceImpl::Hijack( // space used by the OS exception dispatcher. We are using the latter approach here. // - CORDB_ADDRESS espOSContext = NULL; - CORDB_ADDRESS espOSRecord = NULL; + CORDB_ADDRESS espOSContext = (CORDB_ADDRESS)NULL; + CORDB_ADDRESS espOSRecord = (CORDB_ADDRESS)NULL; if (pThread != NULL && pThread->IsExceptionInProgress()) { espOSContext = (CORDB_ADDRESS)PTR_TO_TADDR(pThread->GetExceptionState()->GetContextRecord()); @@ -5360,10 +5360,10 @@ TargetBuffer DacDbiInterfaceImpl::GetVarArgSig(CORDB_ADDRESS VASigCookieAddr, DD_ENTER_MAY_THROW; _ASSERTE(pArgBase != NULL); - *pArgBase = NULL; + *pArgBase = (CORDB_ADDRESS)NULL; // First, read the VASigCookie pointer. - TADDR taVASigCookie = NULL; + TADDR taVASigCookie = (TADDR)NULL; SafeReadStructOrThrow(VASigCookieAddr, &taVASigCookie); // Now create a DAC copy of VASigCookie. @@ -5665,7 +5665,7 @@ CORDB_ADDRESS DacDbiInterfaceImpl::GetDebuggerControlBlockAddress() return CORDB_ADDRESS(dac_cast(g_pDebugger->m_pRCThread->GetDCB())); } - return NULL; + return (CORDB_ADDRESS)NULL; } // DacDbi API: Get the context for a particular thread of the target process @@ -6541,7 +6541,7 @@ HRESULT DacHeapWalker::Init(CORDB_ADDRESS start, CORDB_ADDRESS end) if (ctx == NULL) continue; - if ((CORDB_ADDRESS)ctx->alloc_ptr != NULL) + if ((CORDB_ADDRESS)ctx->alloc_ptr != (CORDB_ADDRESS)NULL) { mAllocInfo[j].Ptr = (CORDB_ADDRESS)ctx->alloc_ptr; mAllocInfo[j].Limit = (CORDB_ADDRESS)ctx->alloc_limit; @@ -6856,7 +6856,7 @@ HRESULT DacDbiInterfaceImpl::WalkHeap(HeapWalkHandle handle, { objects[i].address = addr; objects[i].type.token1 = mt; - objects[i].type.token2 = NULL; + objects[i].type.token2 = 0; objects[i].size = size; i++; } diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 0707a725369977..32b546f8f51f01 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -589,7 +589,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread } else { - frameData.stubFrame.funcMetadataToken = (pMD == NULL ? NULL : pMD->GetMemberDef()); + frameData.stubFrame.funcMetadataToken = (pMD == NULL ? mdTokenNil : pMD->GetMemberDef()); frameData.stubFrame.vmDomainAssembly.SetHostPtr(pDomainAssembly); frameData.stubFrame.vmMethodDesc.SetHostPtr(pMD); } @@ -832,7 +832,7 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter, } else { - pFrameData->v.exactGenericArgsToken = NULL; + pFrameData->v.exactGenericArgsToken = (GENERICS_TYPE_TOKEN)NULL; pFrameData->v.dwExactGenericArgsTokenIndex = (DWORD)ICorDebugInfo::MAX_ILNUM; } @@ -1249,7 +1249,7 @@ void DacDbiInterfaceImpl::UpdateContextFromRegDisp(REGDISPLAY * pRegDisp, PTR_CONTEXT DacDbiInterfaceImpl::RetrieveHijackedContext(REGDISPLAY * pRD) { - CORDB_ADDRESS ContextPointerAddr = NULL; + CORDB_ADDRESS ContextPointerAddr = (CORDB_ADDRESS)NULL; TADDR controlPC = PCODEToPINSTR(GetControlPC(pRD)); diff --git a/src/coreclr/debug/daccess/dacfn.cpp b/src/coreclr/debug/daccess/dacfn.cpp index c3131e2d571efe..e5185520948a3f 100644 --- a/src/coreclr/debug/daccess/dacfn.cpp +++ b/src/coreclr/debug/daccess/dacfn.cpp @@ -1525,7 +1525,7 @@ HRESULT DacReplacePatchesInHostMemory(MemoryRange range, PVOID pBuffer) { CORDB_ADDRESS patchAddress = (CORDB_ADDRESS)dac_cast(pPatch->address); - if (patchAddress != NULL) + if (patchAddress != (CORDB_ADDRESS)NULL) { PRD_TYPE opcode = pPatch->opcode; diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index e698eed4c1803b..751229f450a75a 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -519,7 +519,7 @@ struct ProcessModIter { m_nextDomain = false; - if (AppDomain::GetCurrentDomain() == nullptr) + if (AppDomain::GetCurrentDomain() == (PTR_AppDomain)nullptr) { return NULL; } diff --git a/src/coreclr/debug/daccess/enummem.cpp b/src/coreclr/debug/daccess/enummem.cpp index 7856a1ff0c096e..a3b62c55ac5256 100644 --- a/src/coreclr/debug/daccess/enummem.cpp +++ b/src/coreclr/debug/daccess/enummem.cpp @@ -574,12 +574,12 @@ HRESULT ClrDataAccess::DumpManagedExcepObject(CLRDataEnumMemoryFlags flags, OBJE // Pulls in sequence points. DebugInfoManager::EnumMemoryRegionsForMethodDebugInfo(flags, pMD); PCODE addr = pMD->GetNativeCode(); - if (addr != NULL) + if (addr != (PCODE)NULL) { EECodeInfo codeInfo(addr); if (codeInfo.IsValid()) { - IJitManager::MethodRegionInfo methodRegionInfo = { NULL, 0, NULL, 0 }; + IJitManager::MethodRegionInfo methodRegionInfo = { (TADDR)NULL, 0, (TADDR)NULL, 0 }; codeInfo.GetMethodRegionInfo(&methodRegionInfo); } } @@ -785,7 +785,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, { bool frameHadContext = false; status = pStackWalk->GetFrame(&pFrame); - PCODE addr = NULL; + PCODE addr = (PCODE)NULL; if (status == S_OK && pFrame != NULL) { // write out the code that ip pointed to @@ -917,7 +917,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, // This method has a generic type token which is required to figure out the exact instantiation // of the method. // We need to use the variable index of the generic type token in order to do the look up. - CLRDATA_ADDRESS address = NULL; + CLRDATA_ADDRESS address = (CLRDATA_ADDRESS)NULL; DWORD dwExactGenericArgsTokenIndex = 0; ReleaseHolder pDV(NULL); ReleaseHolder pAssociatedValue(NULL); @@ -955,7 +955,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, #if defined(FEATURE_EH_FUNCLETS) && defined(USE_GC_INFO_DECODER) - if (addr != NULL) + if (addr != (PCODE)NULL) { EECodeInfo codeInfo(addr); diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index dea3b8544ab93a..f01caee1d97079 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -67,13 +67,13 @@ typedef DPTR(InteropLib::ABI::ManagedObjectWrapperLayout) PTR_ManagedObjectWrapp TADDR DACGetMethodTableFromObjectPointer(TADDR objAddr, ICorDebugDataTarget * target) { ULONG32 returned = 0; - TADDR Value = NULL; + TADDR Value = (TADDR)NULL; HRESULT hr = target->ReadVirtual(objAddr, (PBYTE)&Value, sizeof(TADDR), &returned); if ((hr != S_OK) || (returned != sizeof(TADDR))) { - return NULL; + return (TADDR)NULL; } #if TARGET_64BIT @@ -88,7 +88,7 @@ TADDR DACGetMethodTableFromObjectPointer(TADDR objAddr, ICorDebugDataTarget * ta PTR_SyncBlock DACGetSyncBlockFromObjectPointer(TADDR objAddr, ICorDebugDataTarget * target) { ULONG32 returned = 0; - DWORD Value = NULL; + DWORD Value = 0; HRESULT hr = target->ReadVirtual(objAddr - sizeof(DWORD), (PBYTE)&Value, sizeof(DWORD), &returned); @@ -414,7 +414,7 @@ ClrDataAccess::GetMethodTableSlot(CLRDATA_ADDRESS mt, unsigned int slot, CLRDATA HRESULT ClrDataAccess::GetCodeHeapList(CLRDATA_ADDRESS jitManager, unsigned int count, struct DacpJitCodeHeapInfo codeHeaps[], unsigned int *pNeeded) { - if (jitManager == NULL) + if (jitManager == (CLRDATA_ADDRESS)NULL) return E_INVALIDARG; SOSDacEnter(); @@ -743,7 +743,7 @@ ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThreadData * threadData->allocContextPtr = TO_CDADDR(thread->m_alloc_context.alloc_ptr); threadData->allocContextLimit = TO_CDADDR(thread->m_alloc_context.alloc_limit); - threadData->fiberData = NULL; + threadData->fiberData = (CLRDATA_ADDRESS)NULL; threadData->pFrame = PTR_CDADDR(thread->m_pFrame); threadData->context = PTR_CDADDR(thread->m_pDomain); @@ -752,7 +752,7 @@ ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThreadData * #ifndef TARGET_UNIX threadData->teb = TO_CDADDR(thread->m_pTEB); #else - threadData->teb = NULL; + threadData->teb = (CLRDATA_ADDRESS)NULL; #endif threadData->lastThrownObjectHandle = TO_CDADDR(thread->m_LastThrownObjectHandle); @@ -868,7 +868,7 @@ HRESULT ClrDataAccess::GetMethodDescData( *pcNeededRevertedRejitData = 0; NativeCodeVersion requestedNativeCodeVersion, activeNativeCodeVersion; - if (ip != NULL) + if (ip != (CLRDATA_ADDRESS)NULL) { requestedNativeCodeVersion = ExecutionManager::GetNativeCodeVersion(CLRDATA_ADDRESS_TO_TADDR(ip)); } @@ -885,7 +885,7 @@ HRESULT ClrDataAccess::GetMethodDescData( methodDescData->requestedIP = ip; methodDescData->bIsDynamic = (pMD->IsLCGMethod()) ? TRUE : FALSE; methodDescData->wSlotNumber = pMD->GetSlot(); - if (!requestedNativeCodeVersion.IsNull() && requestedNativeCodeVersion.GetNativeCode() != NULL) + if (!requestedNativeCodeVersion.IsNull() && requestedNativeCodeVersion.GetNativeCode() != (PCODE)NULL) { methodDescData->bHasNativeCode = TRUE; methodDescData->NativeCodeAddr = TO_CDADDR(PCODEToPINSTR(requestedNativeCodeVersion.GetNativeCode())); @@ -895,7 +895,7 @@ HRESULT ClrDataAccess::GetMethodDescData( methodDescData->bHasNativeCode = FALSE; methodDescData->NativeCodeAddr = (CLRDATA_ADDRESS)-1; } - methodDescData->AddressOfNativeCodeSlot = pMD->HasNativeCodeSlot() ? TO_CDADDR(dac_cast(pMD->GetAddrOfNativeCodeSlot())) : NULL; + methodDescData->AddressOfNativeCodeSlot = pMD->HasNativeCodeSlot() ? TO_CDADDR(dac_cast(pMD->GetAddrOfNativeCodeSlot())) : (CLRDATA_ADDRESS)NULL; methodDescData->MDToken = pMD->GetMemberDef(); methodDescData->MethodDescPtr = methodDesc; methodDescData->MethodTablePtr = HOST_CDADDR(pMD->GetMethodTable()); @@ -929,7 +929,7 @@ HRESULT ClrDataAccess::GetMethodDescData( // Requested ReJitInfo _ASSERTE(methodDescData->rejitDataRequested.rejitID == 0); - if (ip != NULL && !requestedNativeCodeVersion.IsNull()) + if (ip != (CLRDATA_ADDRESS)NULL && !requestedNativeCodeVersion.IsNull()) { CopyNativeCodeVersionToReJitData( requestedNativeCodeVersion, @@ -1091,8 +1091,8 @@ HRESULT ClrDataAccess::GetTieredVersions( goto cleanup; } - TADDR r2rImageBase = NULL; - TADDR r2rImageEnd = NULL; + TADDR r2rImageBase = (TADDR)NULL; + TADDR r2rImageEnd = (TADDR)NULL; { PTR_Module pModule = (PTR_Module)pMD->GetModule(); if (pModule->IsReadyToRun()) @@ -1221,10 +1221,10 @@ ClrDataAccess::GetCodeHeaderData(CLRDATA_ADDRESS ip, struct DacpCodeHeaderData * { codeHeaderData->MethodDescPtr = HOST_CDADDR(methodDescI); codeHeaderData->JITType = TYPE_UNKNOWN; - codeHeaderData->GCInfo = NULL; - codeHeaderData->MethodStart = NULL; + codeHeaderData->GCInfo = (CLRDATA_ADDRESS)NULL; + codeHeaderData->MethodStart = (CLRDATA_ADDRESS)NULL; codeHeaderData->MethodSize = 0; - codeHeaderData->ColdRegionStart = NULL; + codeHeaderData->ColdRegionStart = (CLRDATA_ADDRESS)NULL; } } else @@ -1239,7 +1239,7 @@ ClrDataAccess::GetCodeHeaderData(CLRDATA_ADDRESS ip, struct DacpCodeHeaderData * _ASSERTE(FitsIn(methodSize)); codeHeaderData->MethodSize = static_cast(methodSize); - IJitManager::MethodRegionInfo methodRegionInfo = {NULL, 0, NULL, 0}; + IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0}; codeInfo.GetMethodRegionInfo(&methodRegionInfo); codeHeaderData->HotRegionSize = (DWORD) methodRegionInfo.hotSize; @@ -1261,7 +1261,7 @@ ClrDataAccess::GetMethodDescPtrFromFrame(CLRDATA_ADDRESS frameAddr, CLRDATA_ADDR Frame *pFrame = PTR_Frame(TO_TADDR(frameAddr)); CLRDATA_ADDRESS methodDescAddr = HOST_CDADDR(pFrame->GetFunction()); - if ((methodDescAddr == NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(methodDescAddr)))) + if ((methodDescAddr == (CLRDATA_ADDRESS)NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(methodDescAddr)))) { hr = E_INVALIDARG; } @@ -1292,7 +1292,7 @@ ClrDataAccess::GetMethodDescPtrFromIP(CLRDATA_ADDRESS ip, CLRDATA_ADDRESS * ppMD else { CLRDATA_ADDRESS pMD = HOST_CDADDR(codeInfo.GetMethodDesc()); - if ((pMD == NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(pMD)))) + if ((pMD == (CLRDATA_ADDRESS)NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(pMD)))) { hr = E_INVALIDARG; } @@ -1475,7 +1475,7 @@ ClrDataAccess::GetObjectClassName(CLRDATA_ADDRESS obj, unsigned int count, _Inou // scans of the gc heap. PTR_MethodTable mt = NULL; TADDR mtTADDR = DACGetMethodTableFromObjectPointer(CLRDATA_ADDRESS_TO_TADDR(obj), m_pTarget); - if (mtTADDR != NULL) + if (mtTADDR != (TADDR)NULL) mt = PTR_MethodTable(mtTADDR); else hr = E_INVALIDARG; @@ -1834,12 +1834,12 @@ ClrDataAccess::GetFieldDescData(CLRDATA_ADDRESS addr, struct DacpFieldDescData * } else { - FieldDescData->MTOfType = NULL; + FieldDescData->MTOfType = (CLRDATA_ADDRESS)NULL; } } EX_CATCH { - FieldDescData->MTOfType = NULL; + FieldDescData->MTOfType = (CLRDATA_ADDRESS)NULL; } EX_END_CATCH(SwallowAllExceptions) @@ -1864,7 +1864,7 @@ ClrDataAccess::GetFieldDescData(CLRDATA_ADDRESS addr, struct DacpFieldDescData * { // There is no encoded token of field type FieldDescData->TokenOfType = mdTypeDefNil; - if (FieldDescData->MTOfType == NULL) + if (FieldDescData->MTOfType == (CLRDATA_ADDRESS)NULL) { // If there is no encoded token (that is, it is primitive type) and no MethodTable for it, remember the // element_type from signature @@ -2100,7 +2100,7 @@ ClrDataAccess::GetPEFileBase(CLRDATA_ADDRESS addr, CLRDATA_ADDRESS *base) if (!pPEAssembly->IsDynamic()) *base = TO_CDADDR(pPEAssembly->GetIJWBase()); else - *base = NULL; + *base = (CLRDATA_ADDRESS)NULL; SOSDacLeave(); return hr; @@ -2112,7 +2112,7 @@ DWORD DACGetNumComponents(TADDR addr, ICorDebugDataTarget* target) // array components. addr+=sizeof(size_t); ULONG32 returned = 0; - DWORD Value = NULL; + DWORD Value = 0; HRESULT hr = target->ReadVirtual(addr, (PBYTE)&Value, sizeof(DWORD), &returned); if ((hr != S_OK) || (returned != sizeof(DWORD))) @@ -2132,7 +2132,7 @@ ClrDataAccess::GetObjectData(CLRDATA_ADDRESS addr, struct DacpObjectData *object ZeroMemory (objectData, sizeof(DacpObjectData)); TADDR mtTADDR = DACGetMethodTableFromObjectPointer(CLRDATA_ADDRESS_TO_TADDR(addr),m_pTarget); - if (mtTADDR==NULL) + if (mtTADDR==(TADDR)NULL) hr = E_INVALIDARG; BOOL bFree = FALSE; @@ -2261,7 +2261,7 @@ ClrDataAccess::GetAppDomainStoreData(struct DacpAppDomainStoreData *adsData) SOSDacEnter(); adsData->systemDomain = HOST_CDADDR(SystemDomain::System()); - adsData->sharedDomain = NULL; + adsData->sharedDomain = (CLRDATA_ADDRESS)NULL; // Get an accurate count of appdomains. adsData->DomainCount = 0; @@ -2332,7 +2332,7 @@ ClrDataAccess::GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData * HRESULT ClrDataAccess::GetFailedAssemblyData(CLRDATA_ADDRESS assembly, unsigned int *pContext, HRESULT *pResult) { - if (assembly == NULL || (pContext == NULL && pResult == NULL)) + if (assembly == (CLRDATA_ADDRESS)NULL || (pContext == NULL && pResult == NULL)) { return E_INVALIDARG; } @@ -2358,7 +2358,7 @@ HRESULT ClrDataAccess::GetFailedAssemblyLocation(CLRDATA_ADDRESS assembly, unsigned int count, _Inout_updates_z_(count) WCHAR *location, unsigned int *pNeeded) { - if (assembly == NULL || (location == NULL && pNeeded == NULL) || (location != NULL && count == 0)) + if (assembly == (CLRDATA_ADDRESS)NULL || (location == NULL && pNeeded == NULL) || (location != NULL && count == 0)) return E_INVALIDARG; SOSDacEnter(); @@ -2377,7 +2377,7 @@ ClrDataAccess::GetFailedAssemblyLocation(CLRDATA_ADDRESS assembly, unsigned int HRESULT ClrDataAccess::GetFailedAssemblyDisplayName(CLRDATA_ADDRESS assembly, unsigned int count, _Inout_updates_z_(count) WCHAR *name, unsigned int *pNeeded) { - if (assembly == NULL || (name == NULL && pNeeded == NULL) || (name != NULL && count == 0)) + if (assembly == (CLRDATA_ADDRESS)NULL || (name == NULL && pNeeded == NULL) || (name != NULL && count == 0)) return E_INVALIDARG; SOSDacEnter(); @@ -2407,7 +2407,7 @@ ClrDataAccess::GetFailedAssemblyDisplayName(CLRDATA_ADDRESS assembly, unsigned i HRESULT ClrDataAccess::GetAssemblyList(CLRDATA_ADDRESS addr, int count, CLRDATA_ADDRESS values[], int *pNeeded) { - if (addr == NULL) + if (addr == (CLRDATA_ADDRESS)NULL) return E_INVALIDARG; SOSDacEnter(); @@ -2459,7 +2459,7 @@ HRESULT ClrDataAccess::GetFailedAssemblyList(CLRDATA_ADDRESS appDomain, int count, CLRDATA_ADDRESS values[], unsigned int *pNeeded) { - if ((appDomain == NULL) || (values == NULL && pNeeded == NULL)) + if ((appDomain == (CLRDATA_ADDRESS)NULL) || (values == NULL && pNeeded == NULL)) { return E_INVALIDARG; } @@ -2554,7 +2554,7 @@ ClrDataAccess::GetAppDomainConfigFile(CLRDATA_ADDRESS appDomain, int count, HRESULT ClrDataAccess::GetAssemblyData(CLRDATA_ADDRESS cdBaseDomainPtr, CLRDATA_ADDRESS assembly, struct DacpAssemblyData *assemblyData) { - if (assembly == NULL && cdBaseDomainPtr == NULL) + if (assembly == (CLRDATA_ADDRESS)NULL && cdBaseDomainPtr == (CLRDATA_ADDRESS)NULL) { return E_INVALIDARG; } @@ -2568,7 +2568,7 @@ ClrDataAccess::GetAssemblyData(CLRDATA_ADDRESS cdBaseDomainPtr, CLRDATA_ADDRESS // If the specified BaseDomain is an AppDomain, get a pointer to it AppDomain * pDomain = NULL; - if (cdBaseDomainPtr != NULL) + if (cdBaseDomainPtr != (CLRDATA_ADDRESS)NULL) { assemblyData->BaseDomainPtr = cdBaseDomainPtr; PTR_BaseDomain baseDomain = PTR_BaseDomain(TO_TADDR(cdBaseDomainPtr)); @@ -2636,7 +2636,7 @@ ClrDataAccess::GetAssemblyName(CLRDATA_ADDRESS assembly, unsigned int count, _In HRESULT ClrDataAccess::GetAssemblyLocation(CLRDATA_ADDRESS assembly, int count, _Inout_updates_z_(count) WCHAR *location, unsigned int *pNeeded) { - if ((assembly == NULL) || (location == NULL && pNeeded == NULL) || (location != NULL && count == 0)) + if ((assembly == (CLRDATA_ADDRESS)NULL) || (location == NULL && pNeeded == NULL) || (location != NULL && count == 0)) { return E_INVALIDARG; } @@ -2721,7 +2721,7 @@ ClrDataAccess::GetGCHeapStaticData(struct DacpGcHeapDetails *detailsData) SOSDacEnter(); - detailsData->heapAddr = NULL; + detailsData->heapAddr = (CLRDATA_ADDRESS)NULL; detailsData->lowest_address = PTR_CDADDR(g_lowest_address); detailsData->highest_address = PTR_CDADDR(g_highest_address); @@ -2825,7 +2825,7 @@ ClrDataAccess::GetHeapSegmentData(CLRDATA_ADDRESS seg, struct DacpHeapSegmentDat heapSegment->mem = (CLRDATA_ADDRESS)(ULONG_PTR) pSegment->mem; heapSegment->next = (CLRDATA_ADDRESS)dac_cast(pSegment->next); heapSegment->flags = pSegment->flags; - heapSegment->gc_heap = NULL; + heapSegment->gc_heap = (CLRDATA_ADDRESS)NULL; heapSegment->background_allocated = (CLRDATA_ADDRESS)(ULONG_PTR)pSegment->background_allocated; if (seg == (CLRDATA_ADDRESS)*g_gcDacGlobals->ephemeral_heap_segment) @@ -3736,7 +3736,7 @@ ClrDataAccess::GetSyncBlockCleanupData(CLRDATA_ADDRESS syncBlock, struct DacpSyn ZeroMemory (syncBlockCData, sizeof(DacpSyncBlockCleanupData)); SyncBlock *pBlock = NULL; - if (syncBlock == NULL && SyncBlockCache::s_pSyncBlockCache->m_pCleanupBlockList) + if (syncBlock == (CLRDATA_ADDRESS)NULL && SyncBlockCache::s_pSyncBlockCache->m_pCleanupBlockList) { pBlock = (SyncBlock *) PTR_SyncBlock( PTR_HOST_TO_TADDR(SyncBlockCache::s_pSyncBlockCache->m_pCleanupBlockList) - offsetof(SyncBlock, m_Link)); @@ -4235,7 +4235,7 @@ BOOL ClrDataAccess::DACGetComWrappersCCWVTableQIAddress(CLRDATA_ADDRESS ccwPtr, HRESULT hr = S_OK; ULONG32 bytesRead = 0; TADDR ccw = CLRDATA_ADDRESS_TO_TADDR(ccwPtr); - *vTableAddress = NULL; + *vTableAddress = (TADDR)NULL; if (FAILED(m_pTarget->ReadVirtual(ccw, (PBYTE)vTableAddress, sizeof(TADDR), &bytesRead)) || bytesRead != sizeof(TADDR) || vTableAddress == NULL) @@ -4243,7 +4243,7 @@ BOOL ClrDataAccess::DACGetComWrappersCCWVTableQIAddress(CLRDATA_ADDRESS ccwPtr, return FALSE; } - *qiAddress = NULL; + *qiAddress = (TADDR)NULL; if (FAILED(m_pTarget->ReadVirtual(*vTableAddress, (PBYTE)qiAddress, sizeof(TADDR), &bytesRead)) || bytesRead != sizeof(TADDR) || qiAddress == NULL) @@ -4262,8 +4262,8 @@ BOOL ClrDataAccess::DACGetComWrappersCCWVTableQIAddress(CLRDATA_ADDRESS ccwPtr, BOOL ClrDataAccess::DACIsComWrappersCCW(CLRDATA_ADDRESS ccwPtr) { - TADDR vTableAddress = NULL; - TADDR qiAddress = NULL; + TADDR vTableAddress = (TADDR)NULL; + TADDR qiAddress = (TADDR)NULL; if (!DACGetComWrappersCCWVTableQIAddress(ccwPtr, &vTableAddress, &qiAddress)) { return FALSE; @@ -4277,7 +4277,7 @@ TADDR ClrDataAccess::DACGetManagedObjectWrapperFromCCW(CLRDATA_ADDRESS ccwPtr) { if (!DACIsComWrappersCCW(ccwPtr)) { - return NULL; + return (TADDR)NULL; } ULONG32 bytesRead = 0; @@ -4286,7 +4286,7 @@ TADDR ClrDataAccess::DACGetManagedObjectWrapperFromCCW(CLRDATA_ADDRESS ccwPtr) if (FAILED(m_pTarget->ReadVirtual(managedObjectWrapperPtrPtr, (PBYTE)&managedObjectWrapperPtr, sizeof(TADDR), &bytesRead)) || bytesRead != sizeof(TADDR)) { - return NULL; + return (TADDR)NULL; } return managedObjectWrapperPtr; @@ -4299,7 +4299,7 @@ HRESULT ClrDataAccess::DACTryGetComWrappersHandleFromCCW(CLRDATA_ADDRESS ccwPtr, ULONG32 bytesRead = 0; OBJECTHANDLE handle; - if (ccwPtr == 0 || objHandle == NULL) + if (ccwPtr == 0 || objHandle == 0) { hr = E_INVALIDARG; goto ErrExit; @@ -4315,7 +4315,7 @@ HRESULT ClrDataAccess::DACTryGetComWrappersHandleFromCCW(CLRDATA_ADDRESS ccwPtr, // Return ManagedObjectWrapper as an OBJECTHANDLE. (The OBJECTHANDLE is guaranteed to live at offset 0). managedObjectWrapperPtr = DACGetManagedObjectWrapperFromCCW(ccwPtr); - if (managedObjectWrapperPtr == NULL) + if (managedObjectWrapperPtr == (TADDR)NULL) { hr = E_FAIL; goto ErrExit; @@ -4382,7 +4382,7 @@ HRESULT ClrDataAccess::GetCCWData(CLRDATA_ADDRESS ccw, struct DacpCCWData *ccwDa ccwData->isExtendsCOMObject = pCCW->GetSimpleWrapper()->IsExtendsCOMObject(); ccwData->isAggregated = pCCW->GetSimpleWrapper()->IsAggregated(); - if (pCCW->GetObjectHandle() != NULL) + if (pCCW->GetObjectHandle() != (OBJECTHANDLE)NULL) ccwData->managedObject = PTR_CDADDR(ObjectFromHandle(pCCW->GetObjectHandle())); // count the number of COM vtables @@ -4535,7 +4535,7 @@ HRESULT ClrDataAccess::GetClrNotification(CLRDATA_ADDRESS arguments[], int count *pNeeded = MAX_CLR_NOTIFICATION_ARGS; - if (g_clrNotificationArguments[0] == NULL) + if (g_clrNotificationArguments[0] == (CLRDATA_ADDRESS)NULL) { hr = E_FAIL; } @@ -4645,7 +4645,7 @@ HRESULT ClrDataAccess::GetProfilerModifiedILInformation(CLRDATA_ADDRESS methodDe pILData->type = DacpProfilerILData::Unmodified; pILData->rejitID = 0; - pILData->il = NULL; + pILData->il = (CLRDATA_ADDRESS)NULL; PTR_MethodDesc pMD = PTR_MethodDesc(TO_TADDR(methodDesc)); CodeVersionManager* pCodeVersionManager = pMD->GetCodeVersionManager(); @@ -4658,7 +4658,7 @@ HRESULT ClrDataAccess::GetProfilerModifiedILInformation(CLRDATA_ADDRESS methodDe } TADDR pDynamicIL = pMD->GetModule()->GetDynamicIL(pMD->GetMemberDef()); - if (pDynamicIL != NULL) + if (pDynamicIL != (TADDR)NULL) { pILData->type = DacpProfilerILData::ILModified; pILData->il = (CLRDATA_ADDRESS)pDynamicIL; @@ -4701,7 +4701,7 @@ HRESULT ClrDataAccess::GetMethodsWithProfilerModifiedIL(CLRDATA_ADDRESS mod, CLR TADDR pDynamicIL = pModule->GetDynamicIL(pMD->GetMemberDef()); ILCodeVersion ilVersion = pCodeVersionManager->GetActiveILCodeVersion(pMD); - if (ilVersion.GetRejitState() != ILCodeVersion::kStateActive || !ilVersion.HasDefaultIL() || pDynamicIL != NULL) + if (ilVersion.GetRejitState() != ILCodeVersion::kStateActive || !ilVersion.HasDefaultIL() || pDynamicIL != (TADDR)NULL) { methodDescs[*pcMethodDescs] = PTR_CDADDR(pMD); ++(*pcMethodDescs); @@ -4824,7 +4824,7 @@ HRESULT ClrDataAccess::GetFinalizationFillPointers(unsigned int cFillPointers, C HRESULT ClrDataAccess::GetGenerationTableSvr(CLRDATA_ADDRESS heapAddr, unsigned int cGenerations, struct DacpGenerationData *pGenerationData, unsigned int *pNeeded) { - if (heapAddr == NULL || (cGenerations > 0 && pGenerationData == NULL)) + if (heapAddr == (CLRDATA_ADDRESS)NULL || (cGenerations > 0 && pGenerationData == NULL)) { return E_INVALIDARG; } @@ -4874,7 +4874,7 @@ HRESULT ClrDataAccess::GetGenerationTableSvr(CLRDATA_ADDRESS heapAddr, unsigned HRESULT ClrDataAccess::GetFinalizationFillPointersSvr(CLRDATA_ADDRESS heapAddr, unsigned int cFillPointers, CLRDATA_ADDRESS *pFinalizationFillPointers, unsigned int *pNeeded) { - if (heapAddr == NULL || (cFillPointers > 0 && pFinalizationFillPointers == NULL)) + if (heapAddr == (CLRDATA_ADDRESS)NULL || (cFillPointers > 0 && pFinalizationFillPointers == NULL)) { return E_INVALIDARG; } @@ -5052,7 +5052,7 @@ HRESULT ClrDataAccess::IsComWrappersCCW(CLRDATA_ADDRESS ccw, BOOL *isComWrappers if (isComWrappersCCW != NULL) { TADDR managedObjectWrapperPtr = DACGetManagedObjectWrapperFromCCW(ccw); - *isComWrappersCCW = managedObjectWrapperPtr != NULL; + *isComWrappersCCW = managedObjectWrapperPtr != (TADDR)NULL; hr = *isComWrappersCCW ? S_OK : S_FALSE; } @@ -5074,7 +5074,7 @@ HRESULT ClrDataAccess::GetComWrappersCCWData(CLRDATA_ADDRESS ccw, CLRDATA_ADDRES SOSDacEnter(); TADDR managedObjectWrapperPtr = DACGetManagedObjectWrapperFromCCW(ccw); - if (managedObjectWrapperPtr != NULL) + if (managedObjectWrapperPtr != (TADDR)NULL) { PTR_ManagedObjectWrapper pMOW(managedObjectWrapperPtr); @@ -5245,7 +5245,7 @@ HRESULT ClrDataAccess::IsTrackedType( SOSDacEnter(); TADDR mtTADDR = DACGetMethodTableFromObjectPointer(CLRDATA_ADDRESS_TO_TADDR(objAddr), m_pTarget); - if (mtTADDR==NULL) + if (mtTADDR==(TADDR)NULL) hr = E_INVALIDARG; BOOL bFree = FALSE; @@ -5280,7 +5280,7 @@ HRESULT ClrDataAccess::GetTaggedMemory( return E_INVALIDARG; } - *taggedMemory = NULL; + *taggedMemory = (TADDR)NULL; *taggedMemorySizeInBytes = 0; SOSDacEnter(); diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index b0215cdf780ef2..ebf15a5bdd94a2 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -5122,7 +5122,7 @@ EnumMethodDefinitions::CdStart(Module* mod, { HRESULT status; - *handle = NULL; + *handle = 0; if (!mod) { diff --git a/src/coreclr/debug/di/divalue.cpp b/src/coreclr/debug/di/divalue.cpp index 9645ee76526b37..285da47437ebc3 100644 --- a/src/coreclr/debug/di/divalue.cpp +++ b/src/coreclr/debug/di/divalue.cpp @@ -458,7 +458,7 @@ HRESULT CordbValue::InternalCreateHandle(CorDebugHandleType handleType, true, m_appdomain->GetADToken()); - CORDB_ADDRESS addr = GetValueHome() != NULL ? GetValueHome()->GetAddress() : NULL; + CORDB_ADDRESS addr = GetValueHome() != NULL ? GetValueHome()->GetAddress() : (CORDB_ADDRESS)NULL; event.CreateHandle.objectToken = CORDB_ADDRESS_TO_PTR(addr); event.CreateHandle.handleType = handleType; @@ -546,7 +546,7 @@ CordbGenericValue::CordbGenericValue(CordbAppDomain * pAppdomain, // Arguments: // input: pType - the type of the value CordbGenericValue::CordbGenericValue(CordbType * pType) - : CordbValue(NULL, pType, NULL, true), + : CordbValue(NULL, pType, (CORDB_ADDRESS)NULL, true), m_pValueHome(NULL) { // The only purpose of a literal value is to hold a RS literal value. @@ -776,7 +776,7 @@ CordbReferenceValue::CordbReferenceValue(CordbAppDomain * pAppdomai // Arguments: // input: pType - the type of the value CordbReferenceValue::CordbReferenceValue(CordbType * pType) - : CordbValue(NULL, pType, NULL, true, pType->GetAppDomain()->GetSweepableExitNeuterList()) + : CordbValue(NULL, pType, (CORDB_ADDRESS)NULL, true, pType->GetAppDomain()->GetSweepableExitNeuterList()) { memset(&m_info, 0, sizeof(m_info)); @@ -905,7 +905,7 @@ HRESULT CordbReferenceValue::GetAddress(CORDB_ADDRESS *pAddress) PUBLIC_REENTRANT_API_ENTRY(this); VALIDATE_POINTER_TO_OBJECT(pAddress, CORDB_ADDRESS *); - *pAddress = m_valueHome.m_pHome ? m_valueHome.m_pHome->GetAddress() : NULL; + *pAddress = m_valueHome.m_pHome ? m_valueHome.m_pHome->GetAddress() : (CORDB_ADDRESS)NULL; return (S_OK); } @@ -940,7 +940,7 @@ HRESULT CordbReferenceValue::GetValue(CORDB_ADDRESS *pAddress) // Copy out the value, which is simply the value the object reference. if (m_isLiteral) - *pAddress = NULL; + *pAddress = (CORDB_ADDRESS)NULL; else *pAddress = PTR_TO_CORDB_ADDRESS(m_info.objRef); @@ -2501,7 +2501,7 @@ HRESULT CordbObjectValue::IsExceptionObject() { CORDB_ADDRESS objAddr = m_valueHome.GetAddress(); - if (objAddr == NULL) + if (objAddr == (CORDB_ADDRESS)NULL) { // object is a literal hr = S_FALSE; @@ -2533,7 +2533,7 @@ HRESULT CordbObjectValue::IsRcw() { CORDB_ADDRESS objAddr = m_valueHome.GetAddress(); - if (objAddr == NULL) + if (objAddr == (CORDB_ADDRESS)NULL) { // object is a literal hr = S_FALSE; @@ -2565,7 +2565,7 @@ HRESULT CordbObjectValue::IsDelegate() { CORDB_ADDRESS objAddr = m_valueHome.GetAddress(); - if (objAddr == NULL) + if (objAddr == (CORDB_ADDRESS)NULL) { // object is a literal hr = S_FALSE; @@ -4104,7 +4104,7 @@ CordbHandleValue::CordbHandleValue( CordbAppDomain * pAppdomain, CordbType * pType, // The type of object that we create handle on CorDebugHandleType handleType) // strong or weak handle - : CordbValue(pAppdomain, pType, NULL, false, + : CordbValue(pAppdomain, pType, (CORDB_ADDRESS)NULL, false, pAppdomain->GetSweepableExitNeuterList() ) { diff --git a/src/coreclr/debug/di/module.cpp b/src/coreclr/debug/di/module.cpp index 1f4216908637ad..d184206c08e3e6 100644 --- a/src/coreclr/debug/di/module.cpp +++ b/src/coreclr/debug/di/module.cpp @@ -526,9 +526,9 @@ void CordbModule::RefreshMetaData() // So far we've only got a reader for in-memory-writable metadata (MDInternalRW implementation) // We could make a reader for MDInternalRO, but no need yet. This also ensures we don't encroach into common // scenario where we can map a file on disk. - TADDR remoteMDInternalRWAddr = NULL; + TADDR remoteMDInternalRWAddr = (TADDR)NULL; GetProcess()->GetDAC()->GetPEFileMDInternalRW(m_vmPEFile, &remoteMDInternalRWAddr); - if (remoteMDInternalRWAddr != NULL) + if (remoteMDInternalRWAddr != (TADDR)NULL) { // we should only be doing this once to initialize, we don't support reopen with this technique _ASSERTE(m_pIMImport == NULL); @@ -4125,7 +4125,7 @@ HRESULT CordbNativeCode::GetAddress(CORDB_ADDRESS * pStart) // Since we don't do code-pitching, the address points directly to the code. *pStart = (m_rgCodeRegions[kHot].pAddress); - if (*pStart == NULL) + if (*pStart == (CORDB_ADDRESS)NULL) { return CORDBG_E_CODE_NOT_AVAILABLE; } @@ -4661,7 +4661,7 @@ int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count) return -1; #elif defined(TARGET_AMD64) - BYTE rex = NULL; + BYTE rex = 0; BYTE prefix = *ip; BOOL fContainsPrefix = FALSE; @@ -4743,7 +4743,7 @@ int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count) BYTE rex_x = 0; BYTE rex_r = 0; - if (rex != NULL) + if (rex != 0) { rex_b = (rex & 0x1); // high bit to modrm r/m field or SIB base field or OPCODE reg field -- Hmm, when which? rex_x = (rex & 0x2) >> 1; // high bit to sib index field @@ -4757,7 +4757,7 @@ int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count) { BYTE modrm = *ip++; - _ASSERT(modrm != NULL); + _ASSERT(modrm != 0); BYTE mod = (modrm & 0xC0) >> 6; BYTE reg = (modrm & 0x38) >> 3; @@ -4788,7 +4788,7 @@ int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count) // Get values from the SIB byte // BYTE sib = *ip; - _ASSERT(sib != NULL); + _ASSERT(sib != 0); BYTE base = (sib & 0x07); base |= (rex_b << 3); diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index 13aa3ec623e4cf..f785c5e11d53b5 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -6608,7 +6608,7 @@ HRESULT CordbProcess::ReadMemory(CORDB_ADDRESS address, VALIDATE_POINTER_TO_OBJECT_ARRAY(buffer, BYTE, size, true, true); VALIDATE_POINTER_TO_OBJECT(buffer, SIZE_T *); - if (address == NULL) + if (address == (CORDB_ADDRESS)NULL) return E_INVALIDARG; // If no read parameter is supplied, we ignore it. This matches the semantics of kernel32!ReadProcessMemory. @@ -6706,8 +6706,8 @@ HRESULT CordbProcess::AdjustBuffer( CORDB_ADDRESS address, _ASSERTE(m_initialized); _ASSERTE(this->ThreadHoldsProcessLock()); - if ( address == NULL - || size == NULL + if ( address == (CORDB_ADDRESS)NULL + || size == 0 || buffer == NULL || (mode != AB_READ && mode != AB_WRITE) ) return E_INVALIDARG; @@ -7167,7 +7167,7 @@ HRESULT CordbProcess::WriteMemory(CORDB_ADDRESS address, DWORD size, _ASSERTE(m_runtimeOffsetsInitialized); - if (size == 0 || address == NULL) + if (size == 0 || address == (CORDB_ADDRESS)NULL) return E_INVALIDARG; VALIDATE_POINTER_TO_OBJECT_ARRAY(buffer, BYTE, size, true, true); @@ -7500,9 +7500,9 @@ void CordbProcess::GetEventBlock(BOOL * pfBlockExists) // This is not technically necessary for Mac debugging. The event channel doesn't rely on // knowing the target address of the DCB on the LS. - CORDB_ADDRESS pLeftSideDCB = NULL; + CORDB_ADDRESS pLeftSideDCB = (CORDB_ADDRESS)NULL; pLeftSideDCB = (GetDAC()->GetDebuggerControlBlockAddress()); - if (pLeftSideDCB == NULL) + if (pLeftSideDCB == (CORDB_ADDRESS)NULL) { *pfBlockExists = false; ThrowHR(CORDBG_E_DEBUGGING_NOT_POSSIBLE); @@ -9746,7 +9746,7 @@ bool CordbProcess::CopyManagedEventFromTarget( // Determine if the event is really a debug event, and for our instance. CORDB_ADDRESS ptrRemoteManagedEvent = IsEventDebuggerNotification(pRecord, m_clrInstanceId); - if (ptrRemoteManagedEvent == NULL) + if (ptrRemoteManagedEvent == (CORDB_ADDRESS)NULL) { return false; } @@ -14913,7 +14913,7 @@ HRESULT CordbProcess::GetReferenceValueFromGCHandle( EX_TRY { - if (gcHandle == NULL) + if (gcHandle == 0) { ThrowHR(CORDBG_E_BAD_REFERENCE_VALUE); } diff --git a/src/coreclr/debug/di/rsclass.cpp b/src/coreclr/debug/di/rsclass.cpp index 55f83b48a6d211..d030efc3c31f07 100644 --- a/src/coreclr/debug/di/rsclass.cpp +++ b/src/coreclr/debug/di/rsclass.cpp @@ -237,7 +237,7 @@ HRESULT CordbClass::GetStaticFieldValue2(CordbModule * pModule, return CORDBG_E_FIELD_NOT_STATIC; } - CORDB_ADDRESS pRmtStaticValue = NULL; + CORDB_ADDRESS pRmtStaticValue = (CORDB_ADDRESS)NULL; CordbProcess * pProcess = pModule->GetProcess(); if (!pFieldData->m_fFldIsTLS) @@ -300,7 +300,7 @@ HRESULT CordbClass::GetStaticFieldValue2(CordbModule * pModule, } } - if (pRmtStaticValue == NULL) + if (pRmtStaticValue == (CORDB_ADDRESS)NULL) { // type probably wasn't loaded yet. // The debugger may chose to func-eval the creation of an instance of this type and try again. @@ -812,7 +812,7 @@ BOOL CordbClass::GotUnallocatedStatic(DacDbiArrayList * pFieldList) while ((count < pFieldList->Count()) && !fGotUnallocatedStatic ) { if ((*pFieldList)[count].OkToGetOrSetStaticAddress() && - (*pFieldList)[count].GetStaticAddress() == NULL ) + (*pFieldList)[count].GetStaticAddress() == (CORDB_ADDRESS)NULL ) { // The address for a regular static field isn't available yet // How can this happen? Statics appear to get allocated during domain load. @@ -938,7 +938,7 @@ void CordbClass::InitEnCFieldInfo(EnCHangingFieldInfo * pEncField, { // the field is static, we don't need any additional data pEncField->Init(VMPTR_Object::NullPtr(), /* vmObject */ - NULL, /* offsetToVars */ + 0, /* offsetToVars */ fieldToken, ELEMENT_TYPE_MAX, classToken, diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index 63886b56bfa5a4..4b3fff25ce69b2 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -3475,7 +3475,7 @@ class CordbProcess : * are passed in, while going through the table we'll undo patches * in buffer at the same time */ - HRESULT RefreshPatchTable(CORDB_ADDRESS address = NULL, SIZE_T size = NULL, BYTE buffer[] = NULL); + HRESULT RefreshPatchTable(CORDB_ADDRESS address = 0, SIZE_T size = 0, BYTE buffer[] = NULL); // Find if a patch exists at a given address. HRESULT FindPatchByAddress(CORDB_ADDRESS address, bool *patchFound, bool *patchIsUnmanaged); @@ -5934,7 +5934,7 @@ class CordbNativeCode : public CordbCode, ULONG32 GetColdSize(); // Return true if the Code is split into hot + cold regions. - bool HasColdRegion() { return m_rgCodeRegions[kCold].pAddress != NULL; } + bool HasColdRegion() { return m_rgCodeRegions[kCold].pAddress != (CORDB_ADDRESS)NULL; } // Get the number of fixed arguments for this function (the "this" // but not varargs) @@ -8406,7 +8406,7 @@ class RegisterValueHome: public ValueHome // gets the remote address for the value or returns NULL if none exists virtual - CORDB_ADDRESS GetAddress() { return NULL; }; + CORDB_ADDRESS GetAddress() { return (CORDB_ADDRESS)NULL; }; // Gets a value and returns it in dest virtual @@ -8925,7 +8925,7 @@ class CordbGenericValue : public CordbValue, public ICorDebugGenericValue, publi FAIL_IF_NEUTERED(this); VALIDATE_POINTER_TO_OBJECT_OR_NULL(pAddress, CORDB_ADDRESS *); - *pAddress = m_pValueHome ? m_pValueHome->GetAddress() : NULL; + *pAddress = m_pValueHome ? m_pValueHome->GetAddress() : (CORDB_ADDRESS)NULL; return (S_OK); } diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 1f455dad376d14..f8c81ed692cb19 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -656,7 +656,7 @@ void CordbThread::RefreshHandle(HANDLE * phThread) hThread, GetCurrentProcess(), &m_hCachedThread, - NULL, + 0, FALSE, DUPLICATE_SAME_ACCESS); *phThread = m_hCachedThread; @@ -5335,11 +5335,11 @@ HRESULT CordbInternalFrame::GetStackRange(CORDB_ADDRESS *pStart, { if (pStart != NULL) { - *pStart = NULL; + *pStart = (CORDB_ADDRESS)NULL; } if (pEnd != NULL) { - *pEnd = NULL; + *pEnd = (CORDB_ADDRESS)NULL; } return E_NOTIMPL; } @@ -5956,11 +5956,11 @@ HRESULT CordbNativeFrame::GetStackRange(CORDB_ADDRESS *pStart, { if (pStart != NULL) { - *pStart = NULL; + *pStart = (CORDB_ADDRESS)NULL; } if (pEnd != NULL) { - *pEnd = NULL; + *pEnd = (CORDB_ADDRESS)NULL; } return E_NOTIMPL; } @@ -7304,7 +7304,7 @@ SIZE_T CordbNativeFrame::GetInspectionIP() bool CordbNativeFrame::IsFunclet() { #ifdef FEATURE_EH_FUNCLETS - return (m_misc.parentIP != NULL); + return (m_misc.parentIP != (SIZE_T)NULL); #else return false; #endif // FEATURE_EH_FUNCLETS @@ -7406,7 +7406,7 @@ CordbJITILFrame::CordbJITILFrame(CordbNativeFrame * pNativeFrame, m_fVarArgFnx(fVarArgFnx), m_allArgsCount(0), m_rgbSigParserBuf(NULL), - m_FirstArgAddr(NULL), + m_FirstArgAddr((CORDB_ADDRESS)NULL), m_rgNVI(NULL), m_genericArgs(), m_genericArgsLoaded(false), @@ -7533,7 +7533,7 @@ HRESULT CordbJITILFrame::Init() // The stackwalking code can't always successfully retrieve the generics type token. // For example, on 64-bit, the JIT only encodes the generics type token location if // a method has catch clause for a generic exception (e.g. "catch(MyException e)"). - if ((m_dwFrameParamsTokenIndex != (DWORD)ICorDebugInfo::MAX_ILNUM) && (m_frameParamsToken == NULL)) + if ((m_dwFrameParamsTokenIndex != (DWORD)ICorDebugInfo::MAX_ILNUM) && (m_frameParamsToken == (GENERICS_TYPE_TOKEN)NULL)) { // All variables are unavailable in the prolog and the epilog. // This includes the generics type token. Failing to get the token just means that @@ -9314,7 +9314,7 @@ HRESULT CordbEval::GatherArgInfo(ICorDebugValue *pValue, argData->fullArgType = buffer; argData->fullArgTypeNodeCount = fullArgTypeNodeCount; // Is it enregistered? - if ((addr == NULL) && (pVCObjVal->GetValueHome() != NULL)) + if ((addr == (CORDB_ADDRESS)NULL) && (pVCObjVal->GetValueHome() != NULL)) { pVCObjVal->GetValueHome()->CopyToIPCEType(&(argData->argHome)); } @@ -9332,7 +9332,7 @@ HRESULT CordbEval::GatherArgInfo(ICorDebugValue *pValue, CordbGenericValue *gv = (CordbGenericValue*)pValue; argData->argIsLiteral = gv->CopyLiteralData(argData->argLiteralData); // Is it enregistered? - if ((addr == NULL) && (gv->GetValueHome() != NULL)) + if ((addr == (CORDB_ADDRESS)NULL) && (gv->GetValueHome() != NULL)) { gv->GetValueHome()->CopyToIPCEType(&(argData->argHome)); } diff --git a/src/coreclr/debug/ee/amd64/walker.cpp b/src/coreclr/debug/ee/amd64/walker.cpp index 815366def5b0d6..ce9ea611754b04 100644 --- a/src/coreclr/debug/ee/amd64/walker.cpp +++ b/src/coreclr/debug/ee/amd64/walker.cpp @@ -29,7 +29,7 @@ void NativeWalker::Decode() m_skipIP = NULL; m_nextIP = NULL; - BYTE rex = NULL; + BYTE rex = 0; LOG((LF_CORDB, LL_INFO100000, "NW:Decode: m_ip 0x%p\n", m_ip)); @@ -117,7 +117,7 @@ void NativeWalker::Decode() BYTE rex_x = 0; BYTE rex_r = 0; - if (rex != NULL) + if (rex != 0) { rex_b = (rex & 0x1); // high bit to modrm r/m field or SIB base field or OPCODE reg field -- Hmm, when which? rex_x = (rex & 0x2) >> 1; // high bit to sib index field @@ -275,7 +275,7 @@ void NativeWalker::Decode() // the instruction uses r8-r15, add in the extra byte to the displacement // for the REX prefix which was used to specify the extended register - if (rex != NULL) + if (rex != 0) { displace++; } diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index 1c689b8eee5421..ea00d18a923e25 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -770,7 +770,7 @@ DebuggerControllerPatch *DebuggerPatchTable::GetNextPatch(DebuggerControllerPatc #ifdef _DEBUG void DebuggerPatchTable::CheckPatchTable() { - if (NULL != m_pcEntries) + if (0 != m_pcEntries) { LOG((LF_CORDB,LL_INFO1000, "DPT:CPT: %u\n", m_iEntries)); DebuggerControllerPatch *dcp; @@ -793,7 +793,7 @@ int DebuggerPatchTable::GetNumberOfPatches() { int total = 0; - if (NULL != m_pcEntries) + if (0 != m_pcEntries) { DebuggerControllerPatch *dcp; ULONG i = 0; @@ -2069,7 +2069,7 @@ BOOL DebuggerController::AddBindAndActivatePatchForMethodDesc(MethodDesc *fd, kind, fp, pAppDomain, - NULL, + 0, dji); if (DebuggerController::BindPatch(patch, fd, NULL)) @@ -7110,7 +7110,7 @@ TP_RESULT DebuggerStepper::TriggerPatch(DebuggerControllerPatch *patch, dji = g_pDebugger->GetJitInfoFromAddr((TADDR) traceManagerRetAddr); MethodDesc* mdNative = NULL; - PCODE pcodeNative = NULL; + PCODE pcodeNative = (PCODE)NULL; if (dji != NULL) { mdNative = dji->m_nativeCodeVersion.GetMethodDesc(); diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 79aa2d5f13fc48..7a5028e1fc2018 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -1353,7 +1353,7 @@ DebuggerEval::DebuggerEval(CONTEXT * pContext, DebuggerIPCE_FuncEvalInfo * pEval m_debuggerModule = g_pDebugger->LookupOrCreateModule(pEvalInfo->vmDomainAssembly); m_funcEvalKey = pEvalInfo->funcEvalKey; m_argCount = pEvalInfo->argCount; - m_targetCodeAddr = NULL; + m_targetCodeAddr = (TADDR)NULL; m_stringSize = pEvalInfo->stringSize; m_arrayRank = pEvalInfo->arrayRank; m_genericArgsCount = pEvalInfo->genericArgsCount; @@ -2238,7 +2238,7 @@ DebuggerLazyInit::DebuggerLazyInit() : m_exAttachEvent(NULL), m_exUnmanagedAttachEvent(NULL), m_garbageCollectionBlockerEvent(NULL), - m_DebuggerHandlingCtrlC(NULL) + m_DebuggerHandlingCtrlC(FALSE) { } @@ -2724,7 +2724,7 @@ DebuggerJitInfo *Debugger::GetJitInfoWorker(MethodDesc *fd, const BYTE *pbAddr, else { PCODE startAddr = g_pEEInterface->GetNativeCodeStartAddress((PCODE)pbAddr); - if (startAddr == NULL) + if (startAddr == (PCODE)NULL) { LOG((LF_CORDB,LL_INFO1000,"D::GJIW: Couldn't find a DJI by address 0x%p, " "so it might be a stub or thunk\n", pbAddr)); @@ -2748,7 +2748,7 @@ DebuggerJitInfo *Debugger::GetJitInfoWorker(MethodDesc *fd, const BYTE *pbAddr, #endif // LOGGING } - if (startAddr != NULL) + if (startAddr != (PCODE)NULL) { dji = dmi->FindOrCreateInitAndAddJitInfo(fd, startAddr); } @@ -3488,7 +3488,7 @@ HRESULT Debugger::SetIP( bool fCanSetIPOnly, Thread *thread,Module *module, BOOL exact; SIZE_T offsetNatTo; - PCODE pbDest = NULL; + PCODE pbDest = (PCODE)NULL; BYTE *pbBase = NULL; CONTEXT *pCtx = NULL; DWORD dwSize = 0; @@ -8546,8 +8546,8 @@ LONG Debugger::LastChanceManagedException(EXCEPTION_POINTERS * pExceptionInfo, // attach stuff out here and not bother with the flag. hr = SendException(thread, FALSE, - ((pContext != NULL) ? (SIZE_T)GetIP(pContext) : NULL), - ((pContext != NULL) ? (SIZE_T)GetSP(pContext) : NULL), + ((pContext != NULL) ? (SIZE_T)GetIP(pContext) : 0), + ((pContext != NULL) ? (SIZE_T)GetSP(pContext) : 0), continuable, !!jitAttachRequested, // If we are JIT attaching on an unhandled exceptioin, we force !!jitAttachRequested, // the exception to be uninterceptable. @@ -13984,7 +13984,7 @@ bool Debugger::GetILOffsetFromNative (MethodDesc *pFunc, const BYTE *pbAddr, } PCODE methodStartAddress = g_pEEInterface->GetNativeCodeStartAddress((PCODE)pbAddr); - if (methodStartAddress == NULL) + if (methodStartAddress == (PCODE)NULL) { return false; } diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h index 2b8573e31b3656..1e50dd8cc37a85 100644 --- a/src/coreclr/debug/ee/debugger.h +++ b/src/coreclr/debug/ee/debugger.h @@ -1237,8 +1237,8 @@ class CodeRegionInfo { public: CodeRegionInfo() : - m_addrOfHotCode(NULL), - m_addrOfColdCode(NULL), + m_addrOfHotCode((PCODE)0), + m_addrOfColdCode((PCODE)0), m_sizeOfHotCode(0), m_sizeOfColdCode(0) { @@ -1273,7 +1273,7 @@ class CodeRegionInfo { LIMITED_METHOD_CONTRACT; - if (m_addrOfHotCode != NULL) + if (m_addrOfHotCode != 0) { if (offset < m_sizeOfHotCode) { @@ -1289,7 +1289,7 @@ class CodeRegionInfo } else { - return NULL; + return (PCODE)0; } } @@ -1312,7 +1312,7 @@ class CodeRegionInfo } _ASSERTE(!"addressToOffset called with invalid address"); - return NULL; + return 0; } // Determines whether the address lies within the method diff --git a/src/coreclr/debug/ee/debugger.inl b/src/coreclr/debug/ee/debugger.inl index 8b7a973f48efff..a8a14caed17ae0 100644 --- a/src/coreclr/debug/ee/debugger.inl +++ b/src/coreclr/debug/ee/debugger.inl @@ -202,7 +202,7 @@ inline TADDR FuncEvalFrame::GetReturnAddressPtr() if (GetDebuggerEval()->m_evalDuringException) { - return NULL; + return (TADDR)0; } else { diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index 9193f90b6dc394..d7f9604b6ad78d 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -760,7 +760,7 @@ void FrameInfo::InitFromStubHelper( this->internal = false; this->managed = true; this->relOffset = 0; - this->ambientSP = NULL; + this->ambientSP = (TADDR)NULL; // Method associated w/a stub will never have a JitManager. @@ -1019,7 +1019,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // If we have a valid reg-display (non-null IP) then update it. // We may have an invalid reg-display if we have an exit frame on an inactive thread. REGDISPLAY * pNewRD = pCF->GetRegisterSet(); - if (GetControlPC(pNewRD) != NULL) + if (GetControlPC(pNewRD) != (PCODE)NULL) { LOG((LF_CORDB, LL_EVERYTHING, "DWSP. updating RD while tracking UM chain\n")); CopyREGDISPLAY(d->GetUMChainStartRD(), pNewRD); @@ -1538,7 +1538,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) #endif // FEATURE_EH_FUNCLETS d->info.frame = frame; - d->info.ambientSP = NULL; + d->info.ambientSP = (TADDR)NULL; // Record the appdomain that the thread was in when it // was running code for this frame. diff --git a/src/coreclr/debug/ee/funceval.cpp b/src/coreclr/debug/ee/funceval.cpp index a7e888452c7812..3011ed5f4731c8 100644 --- a/src/coreclr/debug/ee/funceval.cpp +++ b/src/coreclr/debug/ee/funceval.cpp @@ -1018,7 +1018,7 @@ static void GetFuncEvalArgValue(DebuggerEval *pDE, } else { - *pArgument = NULL; + *pArgument = (ARG_SLOT)NULL; } } } @@ -1051,7 +1051,7 @@ static void GetFuncEvalArgValue(DebuggerEval *pDE, } else { - *pArgument = NULL; + *pArgument = (ARG_SLOT)NULL; } } else @@ -1069,7 +1069,7 @@ static void GetFuncEvalArgValue(DebuggerEval *pDE, } else { - *pArgument = NULL; + *pArgument = (ARG_SLOT)NULL; } } else diff --git a/src/coreclr/debug/ee/functioninfo.cpp b/src/coreclr/debug/ee/functioninfo.cpp index fad9ac786ba714..9cb28204dd1e7a 100644 --- a/src/coreclr/debug/ee/functioninfo.cpp +++ b/src/coreclr/debug/ee/functioninfo.cpp @@ -253,7 +253,7 @@ DebuggerJitInfo::DebuggerJitInfo(DebuggerMethodInfo *minfo, NativeCodeVersion na m_encBreakpointsApplied(false), #endif //FEATURE_METADATA_UPDATER m_methodInfo(minfo), - m_addrOfCode(NULL), + m_addrOfCode(0), m_sizeOfCode(0), m_prevJitInfo(NULL), m_nextJitInfo(NULL), m_lastIL(0), m_sequenceMap(NULL), @@ -1572,10 +1572,10 @@ DebuggerJitInfo *DebuggerMethodInfo::FindOrCreateInitAndAddJitInfo(MethodDesc* f return NULL; } - if (startAddr == NULL) + if (startAddr == (PCODE)NULL) { startAddr = g_pEEInterface->GetFunctionAddress(fd); - if (startAddr == NULL) + if (startAddr == (PCODE)NULL) { //The only case this should happen is if we are trying to get the DJI for a method that has not been jitted yet. return NULL; @@ -2355,7 +2355,7 @@ PTR_DebuggerJitInfo DebuggerMethodInfo::GetLatestJitInfo(MethodDesc *mdesc) // This ensures that there is an entry in the DJI list for this particular MethodDesc. // in the case of generic code it may not be the first entry in the list. - FindOrCreateInitAndAddJitInfo(mdesc, NULL /* startAddr */); + FindOrCreateInitAndAddJitInfo(mdesc, (PCODE)NULL /* startAddr */); #endif // #ifndef DACCESS_COMPILE diff --git a/src/coreclr/debug/inc/dacdbistructures.h b/src/coreclr/debug/inc/dacdbistructures.h index ccb92dfd520948..e91cd9fb9bb44d 100644 --- a/src/coreclr/debug/inc/dacdbistructures.h +++ b/src/coreclr/debug/inc/dacdbistructures.h @@ -499,7 +499,7 @@ class MSLAYOUT NativeCodeFunctionData // method hasn't been jitted yet. // In all cases, we can check the hot region start address to determine whether the rest of the // the information is valid. - BOOL IsValid() { return (m_rgCodeRegions[kHot].pAddress != NULL); } + BOOL IsValid() { return (m_rgCodeRegions[kHot].pAddress != (CORDB_ADDRESS)NULL); } void Clear(); // data members diff --git a/src/coreclr/debug/inc/dacdbistructures.inl b/src/coreclr/debug/inc/dacdbistructures.inl index e31583faff589b..a408a2c1ffb8db 100644 --- a/src/coreclr/debug/inc/dacdbistructures.inl +++ b/src/coreclr/debug/inc/dacdbistructures.inl @@ -166,7 +166,7 @@ unsigned int DacDbiArrayList::Count() const inline TargetBuffer::TargetBuffer() { - this->pAddress = NULL; + this->pAddress = (CORDB_ADDRESS)NULL; this->cbSize = 0; } @@ -219,7 +219,7 @@ TargetBuffer TargetBuffer::SubBuffer(ULONG byteOffset, ULONG byteLength) const inline void TargetBuffer::Clear() { - pAddress = NULL; + pAddress = (CORDB_ADDRESS)NULL; cbSize = 0; } @@ -637,14 +637,14 @@ void FieldData::ClearFields() m_fldSignatureCache = NULL; m_fldSignatureCacheSize = 0; m_fldInstanceOffset = 0; - m_pFldStaticAddress = NULL; + m_pFldStaticAddress = (TADDR)NULL; } inline BOOL FieldData::OkToGetOrSetInstanceOffset() { return (!m_fFldIsStatic && !m_fFldIsRVA && !m_fFldIsTLS && - m_fFldStorageAvailable && (m_pFldStaticAddress == NULL)); + m_fFldStorageAvailable && (m_pFldStaticAddress == (TADDR)NULL)); } // If this is an instance field, store its offset @@ -655,7 +655,7 @@ void FieldData::SetInstanceOffset(SIZE_T offset) _ASSERTE(!m_fFldIsRVA); _ASSERTE(!m_fFldIsTLS); _ASSERTE(m_fFldStorageAvailable); - _ASSERTE(m_pFldStaticAddress == NULL); + _ASSERTE(m_pFldStaticAddress == (TADDR)NULL); m_fldInstanceOffset = offset; } @@ -685,7 +685,7 @@ SIZE_T FieldData::GetInstanceOffset() _ASSERTE(!m_fFldIsRVA); _ASSERTE(!m_fFldIsTLS); _ASSERTE(m_fFldStorageAvailable); - _ASSERTE(m_pFldStaticAddress == NULL); + _ASSERTE(m_pFldStaticAddress == (TADDR)NULL); return m_fldInstanceOffset; } @@ -695,7 +695,7 @@ TADDR FieldData::GetStaticAddress() { _ASSERTE(m_fFldIsStatic); _ASSERTE(!m_fFldIsTLS); - _ASSERTE(m_fFldStorageAvailable || (m_pFldStaticAddress == NULL)); + _ASSERTE(m_fFldStorageAvailable || (m_pFldStaticAddress == (TADDR)NULL)); _ASSERTE(m_fldInstanceOffset == 0); return m_pFldStaticAddress; } diff --git a/src/coreclr/debug/inc/dbgappdomain.h b/src/coreclr/debug/inc/dbgappdomain.h index 6ef343d01e72c9..de8a06b38c9e51 100644 --- a/src/coreclr/debug/inc/dbgappdomain.h +++ b/src/coreclr/debug/inc/dbgappdomain.h @@ -117,7 +117,7 @@ struct RemoteHANDLE { BOOL DuplicateToLocalProcess(HANDLE hProcess, HANDLE* pHandle) { return DuplicateHandle(hProcess, m_hLocal, GetCurrentProcess(), pHandle, - NULL, FALSE, DUPLICATE_SAME_ACCESS); + 0, FALSE, DUPLICATE_SAME_ACCESS); } void CloseInRemoteProcess(HANDLE hProcess) @@ -127,7 +127,7 @@ struct RemoteHANDLE { HANDLE hTmp; if (DuplicateHandle(hProcess, hHandle, GetCurrentProcess(), &hTmp, - NULL, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) + 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) { CloseHandle(hTmp); } diff --git a/src/coreclr/debug/inc/dbgipcevents.h b/src/coreclr/debug/inc/dbgipcevents.h index 1545aa28083704..350edce62e2f0a 100644 --- a/src/coreclr/debug/inc/dbgipcevents.h +++ b/src/coreclr/debug/inc/dbgipcevents.h @@ -780,7 +780,7 @@ class MSLAYOUT VMPTR_Base #endif // _PREFAST_ VMPTR_This dummy; - dummy.m_addr = NULL; + dummy.m_addr = (TADDR)0; return dummy; #ifdef _PREFAST_ diff --git a/src/coreclr/debug/shared/utils.cpp b/src/coreclr/debug/shared/utils.cpp index 73badc2e0575e5..b3fdc5bc3494ca 100644 --- a/src/coreclr/debug/shared/utils.cpp +++ b/src/coreclr/debug/shared/utils.cpp @@ -46,7 +46,7 @@ CORDB_ADDRESS IsEventDebuggerNotification( // If it's not even our exception code, then it's not ours. if (pRecord->ExceptionCode != CLRDBG_NOTIFICATION_EXCEPTION_CODE) { - return NULL; + return (CORDB_ADDRESS)NULL; } // @@ -57,7 +57,7 @@ CORDB_ADDRESS IsEventDebuggerNotification( // if (pRecord->NumberParameters != 3) { - return NULL; + return (CORDB_ADDRESS)NULL; } // 1st argument should always be the cookie. @@ -66,7 +66,7 @@ CORDB_ADDRESS IsEventDebuggerNotification( DWORD cookie = (DWORD) pRecord->ExceptionInformation[0]; if (cookie != CLRDBG_EXCEPTION_DATA_CHECKSUM) { - return NULL; + return (CORDB_ADDRESS)NULL; } // TODO: We don't do this check in case of non-windows debugging now, because we don't support @@ -79,7 +79,7 @@ CORDB_ADDRESS IsEventDebuggerNotification( CORDB_ADDRESS pTargetBase = GetExceptionInfoAsAddress(pRecord, 1); if (pTargetBase != pClrBaseAddress) { - return NULL; + return (CORDB_ADDRESS)NULL; } #endif diff --git a/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp b/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp index b6cc342c741d80..37611c4fb4466c 100644 --- a/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp +++ b/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp @@ -256,13 +256,13 @@ CeeFileGenWriter::CeeFileGenWriter() // ctor is protected m_dllCount = 0; m_dwManifestSize = 0; - m_dwManifestRVA = NULL; + m_dwManifestRVA = 0; m_dwStrongNameSize = 0; - m_dwStrongNameRVA = NULL; + m_dwStrongNameRVA = 0; m_dwVTableSize = 0; - m_dwVTableRVA = NULL; + m_dwVTableRVA = 0; m_iDataDlls = NULL; diff --git a/src/coreclr/ilasm/asmparse.y b/src/coreclr/ilasm/asmparse.y index c9861d58d79740..06b90d2a38d3fe 100644 --- a/src/coreclr/ilasm/asmparse.y +++ b/src/coreclr/ilasm/asmparse.y @@ -693,7 +693,7 @@ memberRef : methodSpec methodRef { $$ = $2; PASM->SetMemberRefFixup($$,iOpcodeLen); } | FIELD_ type dottedName { $2->insertInt8(IMAGE_CEE_CS_CALLCONV_FIELD); - $$ = PASM->MakeMemberRef(NULL, $3, $2); + $$ = PASM->MakeMemberRef(mdTokenNil, $3, $2); PASM->SetMemberRefFixup($$,iOpcodeLen); } | FIELD_ TYPEDEF_F { $$ = $2->m_tkTypeSpec; PASM->SetMemberRefFixup($$,iOpcodeLen); } @@ -916,13 +916,13 @@ methodDecl : _EMITBYTE int32 { PASM->EmitByte($2) | _VTENTRY int32 ':' int32 { PASM->m_pCurMethod->m_wVTEntry = (WORD)$2; PASM->m_pCurMethod->m_wVTSlot = (WORD)$4; } | _OVERRIDE typeSpec DCOLON methodName - { PASM->AddMethodImpl($2,$4,NULL,NULL,NULL,NULL); } + { PASM->AddMethodImpl($2,$4,NULL,mdTokenNil,NULL,NULL); } | _OVERRIDE METHOD_ callConv type typeSpec DCOLON methodName genArity '(' sigArgs0 ')' { PASM->AddMethodImpl($5,$7, ($8==0 ? parser->MakeSig($3,$4,$10) : parser->MakeSig($3| IMAGE_CEE_CS_CALLCONV_GENERIC,$4,$10,$8)) - ,NULL,NULL,NULL); + ,mdTokenNil,NULL,NULL); PASM->ResetArgNameList(); } | scopeBlock diff --git a/src/coreclr/ilasm/assembler.cpp b/src/coreclr/ilasm/assembler.cpp index 1a8cef9abcaff2..abcad50694d4ae 100644 --- a/src/coreclr/ilasm/assembler.cpp +++ b/src/coreclr/ilasm/assembler.cpp @@ -523,7 +523,7 @@ void Assembler::AddClass() m_pCurClass->m_Attr = attr; m_pCurClass->m_crExtends = (m_pCurClass->m_cl == m_tkSysObject)? mdTypeRefNil : crExtends; - if ((m_pCurClass->m_dwNumInterfaces = m_nImplList) != NULL) + if ((m_pCurClass->m_dwNumInterfaces = m_nImplList) != 0) { if(bIsEnum) report->error("Enum implementing interface(s)\n"); if((m_pCurClass->m_crImplements = new mdTypeRef[m_nImplList+1]) != NULL) @@ -2431,7 +2431,7 @@ HRESULT Assembler::SavePdbFile() if (FAILED(hr = (m_pPortablePdbWriter->GetEmitter() == NULL ? E_FAIL : S_OK))) goto exit; if (FAILED(hr = m_pCeeFileGen->GetEntryPoint(m_pCeeFile, &entryPoint))) goto exit; if (FAILED(hr = m_pPortablePdbWriter->BuildPdbStream(m_pEmitter, entryPoint))) goto exit; - if (FAILED(hr = m_pPortablePdbWriter->GetEmitter()->Save(m_wzPdbFileName, NULL))) goto exit; + if (FAILED(hr = m_pPortablePdbWriter->GetEmitter()->Save(m_wzPdbFileName, 0))) goto exit; exit: return hr; diff --git a/src/coreclr/ilasm/prebuilt/asmparse.cpp b/src/coreclr/ilasm/prebuilt/asmparse.cpp index 08f686f290187e..5ecdea67565944 100644 --- a/src/coreclr/ilasm/prebuilt/asmparse.cpp +++ b/src/coreclr/ilasm/prebuilt/asmparse.cpp @@ -2809,7 +2809,7 @@ case 231: case 232: #line 695 "asmparse.y" { yypvt[-1].binstr->insertInt8(IMAGE_CEE_CS_CALLCONV_FIELD); - yyval.token = PASM->MakeMemberRef(NULL, yypvt[-0].string, yypvt[-1].binstr); + yyval.token = PASM->MakeMemberRef(mdTokenNil, yypvt[-0].string, yypvt[-1].binstr); PASM->SetMemberRefFixup(yyval.token,iOpcodeLen); } break; case 233: #line 698 "asmparse.y" @@ -3162,13 +3162,13 @@ case 354: PASM->m_pCurMethod->m_wVTSlot = (WORD)yypvt[-0].int32; } break; case 355: #line 919 "asmparse.y" -{ PASM->AddMethodImpl(yypvt[-2].token,yypvt[-0].string,NULL,NULL,NULL,NULL); } break; +{ PASM->AddMethodImpl(yypvt[-2].token,yypvt[-0].string,NULL,mdTokenNil,NULL,NULL); } break; case 356: #line 922 "asmparse.y" { PASM->AddMethodImpl(yypvt[-6].token,yypvt[-4].string, (yypvt[-3].int32==0 ? parser->MakeSig(yypvt[-8].int32,yypvt[-7].binstr,yypvt[-1].binstr) : parser->MakeSig(yypvt[-8].int32| IMAGE_CEE_CS_CALLCONV_GENERIC,yypvt[-7].binstr,yypvt[-1].binstr,yypvt[-3].int32)) - ,NULL,NULL,NULL); + ,mdTokenNil,NULL,NULL); PASM->ResetArgNameList(); } break; case 358: diff --git a/src/coreclr/ilasm/writer.cpp b/src/coreclr/ilasm/writer.cpp index 6f96b0bd632f11..6405461a9d396f 100644 --- a/src/coreclr/ilasm/writer.cpp +++ b/src/coreclr/ilasm/writer.cpp @@ -530,7 +530,7 @@ DWORD Assembler::EmitExportStub(DWORD dwVTFSlotRVA) else { report->error("Unmanaged exports are not implemented for unknown platform"); - return NULL; + return 0; } // Addr must be aligned, not the stub! if (FAILED(m_pCeeFileGen->GetSectionDataLen (m_pILSection, &PEFileOffset))) return 0; diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index da3aa514c0dca2..2a45e368f816e8 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -899,7 +899,7 @@ void DumpMscorlib(void* GUICookie) // Retrieve the type def properties as well, so that we can check a few more things about // the System.Object type // - if (SUCCEEDED(g_pPubImport->GetTypeDefProps(tkObjectTypeDef, NULL, NULL, 0, &dwClassAttrs, &tkExtends))) + if (SUCCEEDED(g_pPubImport->GetTypeDefProps(tkObjectTypeDef, NULL, 0, NULL, &dwClassAttrs, &tkExtends))) { bool bExtends = g_pPubImport->IsValidToken(tkExtends); bool isClass = ((dwClassAttrs & tdClassSemanticsMask) == tdClass); @@ -3538,7 +3538,7 @@ BOOL DumpMethod(mdToken FuncToken, const char *pszClassName, DWORD dwEntryPointT pComSig = NULL; } - if (cComSig == NULL) + if (cComSig == 0) { sprintf_s(szString, SZSTRING_SIZE, "%sERROR: method '%s' has no signature", g_szAsmCodeIndent, pszMemberName); printError(GUICookie, ERRORMSG(szString)); @@ -4010,7 +4010,7 @@ BOOL DumpField(mdToken FuncToken, const char *pszClassName,void *GUICookie, BOOL { pComSig = NULL; } - if (cComSig == NULL) + if (cComSig == 0) { char sz[2048]; sprintf_s(sz,2048,"%sERROR: field '%s' has no signature",g_szAsmCodeIndent,pszMemberName); diff --git a/src/coreclr/inc/clrconfig.h b/src/coreclr/inc/clrconfig.h index f3e22d7ded16a4..549f372f4e7a97 100644 --- a/src/coreclr/inc/clrconfig.h +++ b/src/coreclr/inc/clrconfig.h @@ -147,6 +147,6 @@ inline CLRConfig::LookupOptions operator&(CLRConfig::LookupOptions lhs, CLRConfi return static_cast(static_cast(lhs) & static_cast(rhs)); } -typedef Wrapper CLRConfigStringHolder; +typedef Wrapper CLRConfigStringHolder; #endif //__CLRConfig_h__ diff --git a/src/coreclr/inc/clrhost.h b/src/coreclr/inc/clrhost.h index 393e6996fe7d01..9b8b41f291c0d7 100644 --- a/src/coreclr/inc/clrhost.h +++ b/src/coreclr/inc/clrhost.h @@ -86,11 +86,11 @@ DWORD ClrSleepEx(DWORD dwMilliseconds, BOOL bAlertable); // be used. This guarantees that the locks will be vacated when the scope is popped, // either on exception or on return. -typedef Holder CRITSEC_Holder; +typedef Holder CRITSEC_Holder; // Use this holder to manage CRITSEC_COOKIE allocation to ensure it will be released if anything goes wrong FORCEINLINE void VoidClrDeleteCriticalSection(CRITSEC_COOKIE cs) { if (cs != NULL) ClrDeleteCriticalSection(cs); } -typedef Wrapper, VoidClrDeleteCriticalSection, NULL> CRITSEC_AllocationHolder; +typedef Wrapper, VoidClrDeleteCriticalSection, 0> CRITSEC_AllocationHolder; #ifndef DACCESS_COMPILE // Suspend/resume APIs that fail-fast on errors diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index ef6af6f2be0342..8581dcae888feb 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -865,6 +865,10 @@ class __TPtrBase { m_addr = addr; } + __TPtrBase(std::nullptr_t) + { + m_addr = 0; + } bool operator!() const { @@ -884,6 +888,14 @@ class __TPtrBase { return m_addr != addr; } + bool operator==(std::nullptr_t) const + { + return m_addr == 0; + } + bool operator!=(std::nullptr_t) const + { + return m_addr != 0; + } bool operator<(TADDR addr) const { return m_addr < addr; @@ -931,6 +943,7 @@ class __DPtrBase : public __TPtrBase // All protected - this type should not be used directly - use one of the derived types instead. __DPtrBase< type, DPtrType >(void) : __TPtrBase() {} __DPtrBase< type, DPtrType >(TADDR addr) : __TPtrBase(addr) {} + __DPtrBase< type, DPtrType >(std::nullptr_t) : __TPtrBase(nullptr) {} explicit __DPtrBase< type, DPtrType >(__TPtrBase addr) { @@ -952,6 +965,11 @@ class __DPtrBase : public __TPtrBase m_addr = addr; return DPtrType(m_addr); } + DPtrType& operator=(std::nullptr_t) + { + m_addr = 0; + return DPtrType(m_addr); + } type& operator*(void) const { @@ -966,6 +984,10 @@ class __DPtrBase : public __TPtrBase { return m_addr == addr; } + bool operator==(std::nullptr_t) const + { + return m_addr == 0; + } bool operator!=(const DPtrType& ptr) const { return !operator==(ptr); @@ -974,6 +996,10 @@ class __DPtrBase : public __TPtrBase { return m_addr != addr; } + bool operator!=(std::nullptr_t) const + { + return m_addr != 0; + } bool operator<(const DPtrType& ptr) const { return m_addr < ptr.GetAddr(); @@ -1182,6 +1208,7 @@ class __DPtr : public __DPtrBase > // constructors - all chain to __DPtrBase constructors __DPtr< type >(void) : __DPtrBase >() {} __DPtr< type >(TADDR addr) : __DPtrBase >(addr) {} + __DPtr< type >(std::nullptr_t) : __DPtrBase >(nullptr) {} // construct const from non-const typedef typename std::remove_const::type mutable_type; @@ -1220,6 +1247,7 @@ class __ArrayDPtr : public __DPtrBase > // constructors - all chain to __DPtrBase constructors __ArrayDPtr< type >(void) : __DPtrBase >() {} __ArrayDPtr< type >(TADDR addr) : __DPtrBase >(addr) {} + __ArrayDPtr< type >(std::nullptr_t) : __DPtrBase >(nullptr) {} // construct const from non-const typedef typename std::remove_const::type mutable_type; @@ -1247,6 +1275,7 @@ class __SPtr : public __TPtrBase __SPtr< type >(void) : __TPtrBase() {} __SPtr< type >(TADDR addr) : __TPtrBase(addr) {} + __SPtr< type >(std::nullptr_t) : __TPtrBase(nullptr) {} explicit __SPtr< type >(__TPtrBase addr) { m_addr = addr.GetAddr(); @@ -1266,6 +1295,11 @@ class __SPtr : public __TPtrBase m_addr = addr; return *this; } + __SPtr< type >& operator=(std::nullptr_t) + { + m_addr = 0; + return *this; + } operator type*() const { @@ -1339,6 +1373,7 @@ class __VPtr : public __TPtrBase __VPtr< type >(void) : __TPtrBase() {} __VPtr< type >(TADDR addr) : __TPtrBase(addr) {} + __VPtr< type >(std::nullptr_t) : __TPtrBase(nullptr) {} explicit __VPtr< type >(__TPtrBase addr) { m_addr = addr.GetAddr(); @@ -1358,6 +1393,11 @@ class __VPtr : public __TPtrBase m_addr = addr; return *this; } + __VPtr< type >& operator=(std::nullptr_t) + { + m_addr = 0; + return *this; + } operator type*() const { @@ -1376,6 +1416,10 @@ class __VPtr : public __TPtrBase { return m_addr == addr; } + bool operator==(std::nullptr_t) const + { + return m_addr == 0; + } bool operator!=(const __VPtr< type >& ptr) const { return !operator==(ptr); @@ -1384,6 +1428,10 @@ class __VPtr : public __TPtrBase { return m_addr != addr; } + bool operator!=(std::nullptr_t) const + { + return m_addr != 0; + } bool IsValid(void) const { @@ -1736,6 +1784,7 @@ class __VoidPtr : public __TPtrBase public: __VoidPtr(void) : __TPtrBase() {} __VoidPtr(TADDR addr) : __TPtrBase(addr) {} + __VoidPtr(std::nullptr_t) : __TPtrBase(nullptr) {} // Note, unlike __DPtr, this ctor form is not explicit. We allow implicit // conversions from any pointer type (just like for void*). @@ -1771,6 +1820,11 @@ class __VoidPtr : public __TPtrBase m_addr = addr; return *this; } + __VoidPtr& operator=(std::nullptr_t) + { + m_addr = 0; + return *this; + } // note, no marshalling operators (type* conversion, operator ->, operator*) // A void* can't be marshalled because we don't know how much to copy @@ -1785,6 +1839,10 @@ class __VoidPtr : public __TPtrBase { return m_addr == addr; } + bool operator==(std::nullptr_t) const + { + return m_addr == 0; + } bool operator!=(const __TPtrBase& ptr) const { return !operator==(ptr); @@ -1793,6 +1851,10 @@ class __VoidPtr : public __TPtrBase { return m_addr != addr; } + bool operator!=(std::nullptr_t) const + { + return m_addr != 0; + } bool operator<(const __TPtrBase& ptr) const { return m_addr < ptr.GetAddr(); diff --git a/src/coreclr/inc/holder.h b/src/coreclr/inc/holder.h index 984260308d04a2..360be1d19ea3f6 100644 --- a/src/coreclr/inc/holder.h +++ b/src/coreclr/inc/holder.h @@ -817,9 +817,9 @@ class Wrapper : public BaseWrapper, #endif template -class SpecializedWrapper : public Wrapper<_TYPE*, DoNothing<_TYPE*>, _RELEASEF, NULL> +class SpecializedWrapper : public Wrapper<_TYPE*, DoNothing<_TYPE*>, _RELEASEF, 0> { - using BaseT = Wrapper<_TYPE*, DoNothing<_TYPE*>, _RELEASEF, NULL>; + using BaseT = Wrapper<_TYPE*, DoNothing<_TYPE*>, _RELEASEF, 0>; public: FORCEINLINE SpecializedWrapper() : BaseT(NULL, FALSE) { @@ -1146,7 +1146,7 @@ typedef Wrapper MapViewHolder; // A holder for HMODULE. FORCEINLINE void HolderFreeLibrary(HMODULE h) { FreeLibrary(h); } -typedef Wrapper, HolderFreeLibrary, NULL> HModuleHolder; +typedef Wrapper, HolderFreeLibrary, 0> HModuleHolder; template FORCEINLINE void DoLocalFree(T* pMem) diff --git a/src/coreclr/inc/pedecoder.inl b/src/coreclr/inc/pedecoder.inl index 9b3c9c47238d15..4e8d9c1b645a94 100644 --- a/src/coreclr/inc/pedecoder.inl +++ b/src/coreclr/inc/pedecoder.inl @@ -200,9 +200,9 @@ inline void PEDecoder::Reset() GC_NOTRIGGER; } CONTRACTL_END; - m_base=NULL; - m_flags=NULL; - m_size=NULL; + m_base=(TADDR)0; + m_flags=0; + m_size=0; m_pNTHeaders=NULL; m_pCorHeader=NULL; m_pReadyToRunHeader=NULL; diff --git a/src/coreclr/inc/profilepriv.inl b/src/coreclr/inc/profilepriv.inl index df5d91a20a8a74..5b50e4e8e13b76 100644 --- a/src/coreclr/inc/profilepriv.inl +++ b/src/coreclr/inc/profilepriv.inl @@ -290,7 +290,7 @@ inline void EEFunctionIDMapperHelper(ProfilerInfo *pProfilerInfo, FunctionID fun inline UINT_PTR ProfControlBlock::EEFunctionIDMapper(FunctionID funcId, BOOL *pbHookFunction) { LIMITED_METHOD_CONTRACT; - UINT_PTR ptr = NULL; + UINT_PTR ptr = 0; DoOneProfilerIteration(&mainProfilerInfo, ProfilerCallbackType::Active, &EEFunctionIDMapperHelper, diff --git a/src/coreclr/inc/regdisp.h b/src/coreclr/inc/regdisp.h index ec47b9019dbc02..47a67237fb8f97 100644 --- a/src/coreclr/inc/regdisp.h +++ b/src/coreclr/inc/regdisp.h @@ -261,12 +261,12 @@ struct REGDISPLAY : public REGDISPLAY_BASE { inline TADDR GetRegdisplayFP(REGDISPLAY *display) { LIMITED_METHOD_CONTRACT; - return NULL; + return 0; } inline TADDR GetRegdisplayFPAddress(REGDISPLAY *display) { LIMITED_METHOD_CONTRACT; - return NULL; + return 0; } // This function tells us if the given stack pointer is in one of the frames of the functions called by the given frame diff --git a/src/coreclr/inc/sbuffer.inl b/src/coreclr/inc/sbuffer.inl index a613f847f49f7e..402cda72f47363 100644 --- a/src/coreclr/inc/sbuffer.inl +++ b/src/coreclr/inc/sbuffer.inl @@ -19,7 +19,7 @@ inline SBuffer::SBuffer(PreallocFlag flag, void *buffer, COUNT_T size) : m_size(0), - m_allocation(NULL), + m_allocation(0), m_flags(0), m_buffer(NULL) { diff --git a/src/coreclr/inc/stackframe.h b/src/coreclr/inc/stackframe.h index 12b047a6b4d750..3c33d0e1e9fb35 100644 --- a/src/coreclr/inc/stackframe.h +++ b/src/coreclr/inc/stackframe.h @@ -10,7 +10,7 @@ struct StackFrame { const static UINT_PTR maxVal = (UINT_PTR)(INT_PTR)-1; - StackFrame() : SP(NULL) + StackFrame() : SP(0) { } @@ -21,7 +21,7 @@ struct StackFrame void Clear() { - SP = NULL; + SP = 0; } void SetMaxVal() @@ -31,7 +31,7 @@ struct StackFrame bool IsNull() { - return (SP == NULL); + return (SP == 0); } bool IsMaxVal() diff --git a/src/coreclr/inc/stresslog.h b/src/coreclr/inc/stresslog.h index 04d31177c0abe3..8e89a06a838dcf 100644 --- a/src/coreclr/inc/stresslog.h +++ b/src/coreclr/inc/stresslog.h @@ -539,7 +539,7 @@ typedef USHORT }; #ifndef STRESS_LOG_ANALYZER -typedef Holder> StressLogLockHolder; +typedef Holder> StressLogLockHolder; #endif //!STRESS_LOG_ANALYZER #if defined(DACCESS_COMPILE) diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index 55713550aedc4b..ed15764b970e74 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -1742,7 +1742,7 @@ class CHashTable HASHFIND *psSrch) // Search object. { WRAPPER_NO_CONTRACT; - if (m_piBuckets == 0) + if (m_piBuckets == nullptr) return (0); psSrch->iBucket = 1; psSrch->iNext = m_piBuckets[0]; diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 5a20f8a1f940ad..81331547b4a924 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -3995,7 +3995,7 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO } int doff = Compiler::eeGetJitDataOffs(fldHnd); - ssize_t addr = NULL; + ssize_t addr = 0; if (doff >= 0) { diff --git a/src/coreclr/md/datasource/targettypes.cpp b/src/coreclr/md/datasource/targettypes.cpp index 76cdcb2d1b44f4..cbabc171f7f6e8 100644 --- a/src/coreclr/md/datasource/targettypes.cpp +++ b/src/coreclr/md/datasource/targettypes.cpp @@ -78,7 +78,7 @@ m_cbRec(0) HRESULT Target_CMiniTableDef::ReadFrom(DataTargetReader & reader) { HRESULT hr = S_OK; - CORDB_ADDRESS pColDefs = NULL; + CORDB_ADDRESS pColDefs = 0; IfFailRet(reader.ReadPointer(&pColDefs)); IfFailRet(reader.Read8(&m_cCols)); IfFailRet(reader.Read8(&m_iKey)); diff --git a/src/coreclr/md/enc/liteweightstgdbrw.cpp b/src/coreclr/md/enc/liteweightstgdbrw.cpp index 686ae97728f188..3b2e2db604297b 100644 --- a/src/coreclr/md/enc/liteweightstgdbrw.cpp +++ b/src/coreclr/md/enc/liteweightstgdbrw.cpp @@ -568,7 +568,7 @@ HRESULT CLiteWeightStgdbRW::GetSaveSize(// S_OK or error. IfFailGo(GetPoolSaveSize(BLOB_POOL_STREAM, MDPoolBlobs, &cbSize)); cbTotal += cbSize; #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB - IfFailGo(GetPoolSaveSize(PDB_STREAM, NULL, &cbSize)); + IfFailGo(GetPoolSaveSize(PDB_STREAM, 0, &cbSize)); cbTotal += cbSize; #endif @@ -816,7 +816,7 @@ HRESULT CLiteWeightStgdbRW::SaveToStorage( IfFailGo(SavePool(GUID_POOL_STREAM, pStorage, MDPoolGuids)); IfFailGo(SavePool(BLOB_POOL_STREAM, pStorage, MDPoolBlobs)); #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB - IfFailGo(SavePool(PDB_STREAM, pStorage, NULL)); + IfFailGo(SavePool(PDB_STREAM, pStorage, 0)); #endif // Write the header to disk. diff --git a/src/coreclr/md/enc/mdinternalrw.cpp b/src/coreclr/md/enc/mdinternalrw.cpp index 487d256f8de0f9..a461c0ad382a21 100644 --- a/src/coreclr/md/enc/mdinternalrw.cpp +++ b/src/coreclr/md/enc/mdinternalrw.cpp @@ -69,7 +69,7 @@ HRESULT TranslateSigHelper( // S_OK or error. pbSigBlob, // signature from the imported scope NULL, // Internal OID mapping structure. pqkSigEmit, // [OUT] translated signature - NULL, // start from first byte of the signature + 0, // start from first byte of the signature NULL, // don't care how many bytes consumed pcbSig); // [OUT] total number of bytes write to pqkSigEmit diff --git a/src/coreclr/md/enc/stgtiggerstorage.cpp b/src/coreclr/md/enc/stgtiggerstorage.cpp index 4c9869eb8caa23..3e6afd6da2b045 100644 --- a/src/coreclr/md/enc/stgtiggerstorage.cpp +++ b/src/coreclr/md/enc/stgtiggerstorage.cpp @@ -725,7 +725,7 @@ TiggerStorage::FindStream( PSTORAGESTREAM p = m_pStreamList; SIZE_T pStartMD = (SIZE_T)(m_pStgIO->m_pData); - SIZE_T pEndMD = NULL; + SIZE_T pEndMD = 0; if (!ClrSafeInt::addition(pStartMD, m_pStgIO->m_cbData, pEndMD)) { diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp index eadc27e2557c2d..6a1802507255b6 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp @@ -381,7 +381,7 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD do { StressLogChunk * inProcChunkPtr = new StressLogChunk; - hr = memCallBack->ReadVirtual (outProcChunkPtr, inProcChunkPtr, sizeof (*inProcChunkPtr), NULL); + hr = memCallBack->ReadVirtual (outProcChunkPtr, inProcChunkPtr, sizeof (*inProcChunkPtr), 0); if (hr != S_OK || !inProcChunkPtr->IsValid ()) { if (hr != S_OK) diff --git a/src/coreclr/unwinder/baseunwinder.cpp b/src/coreclr/unwinder/baseunwinder.cpp index e059b936c34094..b00c2aa114835e 100644 --- a/src/coreclr/unwinder/baseunwinder.cpp +++ b/src/coreclr/unwinder/baseunwinder.cpp @@ -28,7 +28,7 @@ HRESULT OOPStackUnwinder::GetModuleBase( DWORD64 address, _Out_ PDWORD64 pdwBase) { GetRuntimeStackWalkInfo(address, reinterpret_cast(pdwBase), NULL); - return ((*pdwBase == NULL) ? E_FAIL : S_OK); + return ((*pdwBase == 0) ? E_FAIL : S_OK); } //--------------------------------------------------------------------------------------- diff --git a/src/coreclr/utilcode/arraylist.cpp b/src/coreclr/utilcode/arraylist.cpp index c6e538fd38dabf..ecdf1e31448834 100644 --- a/src/coreclr/utilcode/arraylist.cpp +++ b/src/coreclr/utilcode/arraylist.cpp @@ -35,7 +35,7 @@ void ArrayListBase::Clear() delete [] block; block = next; } - m_firstBlock.m_next = 0; + m_firstBlock.m_next = nullptr; m_count = 0; } diff --git a/src/coreclr/utilcode/corimage.cpp b/src/coreclr/utilcode/corimage.cpp index 1838eb9e9d1ac7..7eb3adb7a07bc3 100644 --- a/src/coreclr/utilcode/corimage.cpp +++ b/src/coreclr/utilcode/corimage.cpp @@ -255,5 +255,5 @@ EXTERN_C DWORD Cor_RtlImageRvaToOffset(PTR_IMAGE_NT_HEADERS NtHeaders, return ((Rva - VAL32(NtSection->VirtualAddress)) + VAL32(NtSection->PointerToRawData)); else - return NULL; + return 0; } diff --git a/src/coreclr/utilcode/loaderheap.cpp b/src/coreclr/utilcode/loaderheap.cpp index 985df665be6f4f..95cd7d16e17631 100644 --- a/src/coreclr/utilcode/loaderheap.cpp +++ b/src/coreclr/utilcode/loaderheap.cpp @@ -76,9 +76,9 @@ void RangeList::InitBlock(RangeListBlock *b) Range *r = b->ranges; Range *rEnd = r + RANGE_COUNT; while (r < rEnd) - r++->id = NULL; + r++->id = (TADDR)NULL; - b->next = NULL; + b->next = nullptr; } BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) @@ -92,7 +92,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) } CONTRACTL_END - _ASSERTE(id != NULL); + _ASSERTE(id != (TADDR)NULL); RangeListBlock *b = m_firstEmptyBlock; Range *r = b->ranges + m_firstEmptyRange; @@ -102,7 +102,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) { while (r < rEnd) { - if (r->id == NULL) + if (r->id == (TADDR)NULL) { r->start = (TADDR)start; r->end = (TADDR)end; @@ -123,7 +123,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) // new one. // - if (b->next == NULL) + if (b->next == nullptr) { RangeListBlock *newBlock = new (nothrow) RangeListBlock; @@ -136,7 +136,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) InitBlock(newBlock); - newBlock->next = NULL; + newBlock->next = nullptr; b->next = newBlock; } @@ -177,7 +177,7 @@ void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end) while (r < rEnd) { - if (r->id != NULL) + if (r->id != (TADDR)NULL) { if (start != NULL) { @@ -188,12 +188,12 @@ void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end) CONSISTENCY_CHECK_MSGF(r->end >= (TADDR)start && r->end <= (TADDR)end, ("r: %p start: %p end: %p", r, start, end)); - r->id = NULL; + r->id = (TADDR)NULL; } } else if (r->id == (TADDR)id) { - r->id = NULL; + r->id = (TADDR)NULL; } } @@ -204,7 +204,7 @@ void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end) // If there are no more blocks, we're done. // - if (b->next == NULL) + if (b->next == nullptr) { m_firstEmptyRange = 0; m_firstEmptyBlock = &m_starterBlock; @@ -249,7 +249,7 @@ BOOL RangeList::IsInRangeWorker(TADDR address, TADDR *pID /* = NULL */) { while (r < rEnd) { - if (r->id != NULL && + if (r->id != (TADDR)NULL && address >= r->start && address < r->end) { @@ -266,7 +266,7 @@ BOOL RangeList::IsInRangeWorker(TADDR address, TADDR *pID /* = NULL */) // If there are no more blocks, we're done. // - if (b->next == NULL) + if (b->next == nullptr) return FALSE; // @@ -326,7 +326,7 @@ RangeList::RangeListBlock::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) for (i=0; iranges[i]); - if (range->id == NULL || range->start == NULL || range->end == NULL || + if (range->id == (TADDR)NULL || range->start == (TADDR)NULL || range->end == (TADDR)NULL || // just looking at the lower 4bytes is good enough on WIN64 range->start == BADFOOD || range->end == BADFOOD) { diff --git a/src/coreclr/utilcode/namespaceutil.cpp b/src/coreclr/utilcode/namespaceutil.cpp index 4596776fbb87d2..4ad2751798a1b2 100644 --- a/src/coreclr/utilcode/namespaceutil.cpp +++ b/src/coreclr/utilcode/namespaceutil.cpp @@ -529,7 +529,7 @@ bool ns::MakeAssemblyQualifiedName( // tr int iCopyMax = 0; _ASSERTE(pBuffer); - *pBuffer = NULL; + *pBuffer = W('\0'); if (szTypeName && *szTypeName != W('\0')) { diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index ee92bfaeedbfd4..d8f2ff2fe98acb 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -573,7 +573,7 @@ CHECK PEDecoder::CheckOffset(COUNT_T fileOffset, IsNullOK ok) const } CONTRACT_CHECK_END; - if (fileOffset == NULL) + if (fileOffset == 0) CHECK_MSG(ok == NULL_OK, "Null pointer illegal"); else { @@ -842,7 +842,7 @@ TADDR PEDecoder::GetRvaData(RVA rva, IsNullOK ok /*= NULL_NOT_OK*/) const CONTRACT_END; if ((rva == 0)&&(ok == NULL_NOT_OK)) - RETURN NULL; + RETURN (TADDR)NULL; RVA offset; if (IsMapped()) @@ -869,7 +869,7 @@ RVA PEDecoder::GetDataRva(const TADDR data) const } CONTRACT_END; - if (data == NULL) + if (data == (TADDR)NULL) RETURN 0; COUNT_T offset = (COUNT_T) (data - m_base); @@ -917,7 +917,7 @@ TADDR PEDecoder::GetOffsetData(COUNT_T fileOffset, IsNullOK ok /*= NULL_NOT_OK*/ CONTRACT_END; if ((fileOffset == 0)&&(ok == NULL_NOT_OK)) - RETURN NULL; + RETURN (TADDR)NULL; RETURN GetRvaData(OffsetToRva(fileOffset)); } @@ -1085,7 +1085,7 @@ CHECK PEDecoder::CheckCorHeader() const COUNT_T ctMD = (COUNT_T)VAL32(pDirMD->Size); TADDR pcMD = (TADDR)GetDirectoryData(pDirMD); - if(pcMD != NULL) + if(pcMD != (TADDR)NULL) { // Storage signature checks CHECK(ctMD >= sizeof(STORAGESIGNATURE)); diff --git a/src/coreclr/vm/amd64/cgenamd64.cpp b/src/coreclr/vm/amd64/cgenamd64.cpp index 8e136612c8c80d..91982948b8b7e2 100644 --- a/src/coreclr/vm/amd64/cgenamd64.cpp +++ b/src/coreclr/vm/amd64/cgenamd64.cpp @@ -418,7 +418,7 @@ BOOL GetAnyThunkTarget (CONTEXT *pctx, TADDR *pTarget, TADDR *pTargetMethodDesc) { TADDR pThunk = GetIP(pctx); - *pTargetMethodDesc = NULL; + *pTargetMethodDesc = (TADDR)NULL; // // Check for something generated by emitJump. @@ -652,7 +652,7 @@ INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMe (BYTE *)hiAddr, pLoaderAllocator, /* throwOnOutOfMemoryWithinRange */ false); - if (jumpStubAddr == NULL) + if (jumpStubAddr == (PCODE)NULL) { if (!throwOnOutOfMemoryWithinRange) return 0; diff --git a/src/coreclr/vm/amd64/cgencpu.h b/src/coreclr/vm/amd64/cgencpu.h index 5c6b3cf3c4b237..08fb63d44e82c2 100644 --- a/src/coreclr/vm/amd64/cgencpu.h +++ b/src/coreclr/vm/amd64/cgencpu.h @@ -504,7 +504,7 @@ inline PCODE decodeBackToBackJump(PCODE pCode) if (isJumpRel64(pCode)) return decodeJump64(pCode); else - return NULL; + return (PCODE)0; } extern "C" void setFPReturn(int fpSize, INT64 retVal); diff --git a/src/coreclr/vm/amd64/excepamd64.cpp b/src/coreclr/vm/amd64/excepamd64.cpp index d155ceecc5a35c..282a84c7d788db 100644 --- a/src/coreclr/vm/amd64/excepamd64.cpp +++ b/src/coreclr/vm/amd64/excepamd64.cpp @@ -200,7 +200,7 @@ RtlVirtualUnwind_Worker ( BOOL InEpilogue = FALSE; BOOL HasManagedBreakpoint = FALSE; BOOL HasUnmanagedBreakpoint = FALSE; - UCHAR TempOpcode = NULL; + UCHAR TempOpcode = 0; PUCHAR NextByte; ULONG CurrentOffset; ULONG FrameRegister; diff --git a/src/coreclr/vm/amd64/gmscpu.h b/src/coreclr/vm/amd64/gmscpu.h index 4154fd995d1c2c..411f1cf0c71b88 100644 --- a/src/coreclr/vm/amd64/gmscpu.h +++ b/src/coreclr/vm/amd64/gmscpu.h @@ -34,7 +34,7 @@ struct MachState INDEBUG(memset((void*)this, 0xCC, sizeof(MachState));) } - bool isValid() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(dac_cast(_pRetAddr) != INVALID_POINTER_CC); return(_pRetAddr != 0); } + bool isValid() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(dac_cast(_pRetAddr) != INVALID_POINTER_CC); return(_pRetAddr != nullptr); } TADDR* pRetAddr() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(isValid()); return(_pRetAddr); } TADDR GetRetAddr() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(isValid()); return *_pRetAddr; } #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index 1c400154c7601d..d63a5e0b865f40 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1534,7 +1534,7 @@ class AppDomain : public BaseDomain virtual PTR_AppDomain AsAppDomain() { LIMITED_METHOD_CONTRACT; return dac_cast(this); } OBJECTREF GetRawExposedObject() { LIMITED_METHOD_CONTRACT; return NULL; } - OBJECTHANDLE GetRawExposedObjectHandleForDebugger() { LIMITED_METHOD_DAC_CONTRACT; return NULL; } + OBJECTHANDLE GetRawExposedObjectHandleForDebugger() { LIMITED_METHOD_DAC_CONTRACT; return (OBJECTHANDLE)NULL; } #ifndef DACCESS_COMPILE PTR_NativeImage GetNativeImage(LPCUTF8 compositeFileName); diff --git a/src/coreclr/vm/assemblynative.cpp b/src/coreclr/vm/assemblynative.cpp index bf549e77346b25..b7fdcd6a21bff6 100644 --- a/src/coreclr/vm/assemblynative.cpp +++ b/src/coreclr/vm/assemblynative.cpp @@ -280,7 +280,7 @@ extern "C" void QCALLTYPE AssemblyNative_LoadFromStream(INT_PTR ptrNativeAssembl { #ifdef DEBUGGING_SUPPORTED // If we were given symbols, save a copy of them. - if (ptrSymbolArray != NULL) + if (ptrSymbolArray != 0) { PBYTE pSymbolArray = reinterpret_cast(ptrSymbolArray); pLoadedAssembly->GetModule()->SetSymbolBytes(pSymbolArray, (DWORD)cbSymbolArrayLength); @@ -1197,7 +1197,7 @@ extern "C" INT_PTR QCALLTYPE AssemblyNative_InitializeAssemblyLoadContext(INT_PT { QCALL_CONTRACT; - INT_PTR ptrNativeAssemblyBinder = NULL; + INT_PTR ptrNativeAssemblyBinder = 0; BEGIN_QCALL; @@ -1287,7 +1287,7 @@ extern "C" INT_PTR QCALLTYPE AssemblyNative_GetLoadContextForAssembly(QCall::Ass { QCALL_CONTRACT; - INT_PTR ptrManagedAssemblyLoadContext = NULL; + INT_PTR ptrManagedAssemblyLoadContext = 0; BEGIN_QCALL; diff --git a/src/coreclr/vm/baseassemblyspec.inl b/src/coreclr/vm/baseassemblyspec.inl index 125e31a592a9ea..31833695de6ce1 100644 --- a/src/coreclr/vm/baseassemblyspec.inl +++ b/src/coreclr/vm/baseassemblyspec.inl @@ -356,7 +356,7 @@ inline HRESULT BaseAssemblySpec::Init(mdToken tkAssemblyRef, NULL, // [OUT] Count of bytes in the public key or token. NULL, // [OUT] Hash Algorithm NULL, // [OUT] Buffer to fill with name. - NULL, // [IN] Size of buffer in wide chars. + 0, // [IN] Size of buffer in wide chars. &cchName, // [OUT] Actual # of wide chars in name. &sContext, // [OUT] Assembly MetaData. NULL)); // [OUT] Flags. @@ -380,7 +380,7 @@ inline HRESULT BaseAssemblySpec::Init(mdToken tkAssemblyRef, NULL, // [OUT] Pointer to the public key or token. NULL, // [OUT] Count of bytes in the public key or token. NULL, // [OUT] Buffer to fill with name. - NULL, // [IN] Size of buffer in wide chars. + 0, // [IN] Size of buffer in wide chars. &cchName, // [OUT] Actual # of wide chars in name. &sContext, // [OUT] Assembly MetaData. NULL, // [OUT] Hash blob. diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index a6577fd42de34d..af48f0a79b7c0c 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -758,7 +758,7 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti STATIC_CONTRACT_GC_TRIGGERS; STATIC_CONTRACT_MODE_COOPERATIVE; - PCODE codeEntryPoint = NULL; + PCODE codeEntryPoint = 0; BEGIN_PRESERVE_LAST_ERROR; @@ -925,7 +925,7 @@ void CallCountingManager::CompleteCallCounting() if (!activeCodeVersion.IsNull()) { PCODE activeNativeCode = activeCodeVersion.GetNativeCode(); - if (activeNativeCode != NULL) + if (activeNativeCode != 0) { methodDesc->SetCodeEntryPoint(activeNativeCode); break; diff --git a/src/coreclr/vm/callhelpers.h b/src/coreclr/vm/callhelpers.h index 77373075728e2e..f6dd105263b2f2 100644 --- a/src/coreclr/vm/callhelpers.h +++ b/src/coreclr/vm/callhelpers.h @@ -554,9 +554,9 @@ enum DispatchCallSimpleFlags DWORD __dwDispatchCallSimpleFlags = 0; \ #define PREPARE_NONVIRTUAL_CALLSITE(id) \ - static PCODE s_pAddr##id = NULL; \ + static PCODE s_pAddr##id = 0; \ PCODE __pSlot = VolatileLoad(&s_pAddr##id); \ - if ( __pSlot == NULL ) \ + if ( __pSlot == 0 ) \ { \ MethodDesc *pMeth = CoreLibBinder::GetMethod(id); \ _ASSERTE(pMeth); \ diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 0696635e90273a..5cb624d3d7b36b 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -2580,7 +2580,7 @@ TADDR Module::GetIL(DWORD target) SUPPORTS_DAC; if (target == 0) - return NULL; + return (TADDR)NULL; return m_pPEAssembly->GetIL(target); } @@ -3911,7 +3911,7 @@ void Module::FixupVTables() FillMemory(uMThunkMarshInfoWriterHolder.GetRW(), sizeof(UMThunkMarshInfo), 0); uMThunkMarshInfoWriterHolder.GetRW()->LoadTimeInit(pMD); - uMEntryThunkWriterHolder.GetRW()->LoadTimeInit(pUMEntryThunk, NULL, NULL, pUMThunkMarshInfo, pMD); + uMEntryThunkWriterHolder.GetRW()->LoadTimeInit(pUMEntryThunk, (PCODE)0, NULL, pUMThunkMarshInfo, pMD); SetTargetForVTableEntry(hInstThis, (BYTE **)&pPointers[iMethod], (BYTE *)pUMEntryThunk->GetCode()); @@ -4187,14 +4187,14 @@ BOOL Module::FixupNativeEntry(READYTORUN_IMPORT_SECTION* pSection, SIZE_T fixupI // Ensure that the compiler won't fetch the value twice SIZE_T fixup = VolatileLoadWithoutBarrier(fixupCell); - if (fixup == NULL) + if (fixup == 0) { PTR_DWORD pSignatures = dac_cast(GetReadyToRunImage()->GetRvaData(pSection->Signatures)); if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell, mayUsePrecompiledNDirectMethods)) return FALSE; - _ASSERTE(*fixupCell != NULL); + _ASSERTE(*fixupCell != 0); } return TRUE; @@ -4611,7 +4611,7 @@ TADDR ReflectionModule::GetIL(RVA il) // virtual #else // DACCESS_COMPILE SUPPORTS_DAC; DacNotImpl(); - return NULL; + return (TADDR)NULL; #endif // DACCESS_COMPILE } @@ -4905,7 +4905,7 @@ VASigCookie *Module::GetVASigCookieWorker(Module* pDefiningModule, Module* pLoad // Now, fill in the new cookie (assuming we had enough memory to create one.) pCookie->pModule = pDefiningModule; - pCookie->pNDirectILStub = NULL; + pCookie->pNDirectILStub = 0; pCookie->sizeOfArgs = sizeOfArgs; pCookie->signature = vaSignature; pCookie->pLoaderModule = pLoaderModule; diff --git a/src/coreclr/vm/ceeload.inl b/src/coreclr/vm/ceeload.inl index 18d7557d6e85bd..5b749aa901a7b8 100644 --- a/src/coreclr/vm/ceeload.inl +++ b/src/coreclr/vm/ceeload.inl @@ -76,7 +76,7 @@ TYPE LookupMap::GetElement(DWORD rid, TADDR* pFlags) SUPPORTS_DAC; PTR_TADDR pElement = GetElementPtr(rid); - return (pElement != NULL) ? GetValueAt(pElement, pFlags, supportedFlags) : NULL; + return (pElement != NULL) ? GetValueAt(pElement, pFlags, supportedFlags) : (TYPE)(TADDR)0; } // Stores an association in a map that has been previously grown to @@ -117,7 +117,7 @@ BOOL LookupMap::TrySetElement(DWORD rid, TYPE value, TADDR flags) _ASSERTE(oldValue == NULL || (oldValue == value && oldFlags == flags)); #endif // Avoid unnecessary writes - do not overwrite existing value - if (*pElement == NULL) + if (*pElement == 0) { SetValueAt(pElement, value, flags); } @@ -149,7 +149,7 @@ void LookupMap::AddElement(ModuleBase * pModule, DWORD rid, TYPE value, TA _ASSERTE(oldValue == NULL || (oldValue == value && oldFlags == flags)); #endif // Avoid unnecessary writes - do not overwrite existing value - if (*pElement == NULL) + if (*pElement == 0) { SetValueAt(pElement, value, flags); } diff --git a/src/coreclr/vm/classhash.inl b/src/coreclr/vm/classhash.inl index 554c0c2005c463..ff1c25d93a93c2 100644 --- a/src/coreclr/vm/classhash.inl +++ b/src/coreclr/vm/classhash.inl @@ -34,7 +34,7 @@ inline PTR_VOID EEClassHashTable::CompressClassDef(mdToken cl) case mdtExportedType: return (PTR_VOID)(EECLASSHASH_MDEXPORT_DISCR | (((ULONG_PTR)cl & 0x00ffffff) << 1) | EECLASSHASH_TYPEHANDLE_DISCR); default: _ASSERTE(!"Can't get here."); - return 0; + return nullptr; } } diff --git a/src/coreclr/vm/clrex.h b/src/coreclr/vm/clrex.h index 3a17cd2e720823..fa0b64e9da6868 100644 --- a/src/coreclr/vm/clrex.h +++ b/src/coreclr/vm/clrex.h @@ -934,7 +934,7 @@ LONG CLRNoCatchHandler(EXCEPTION_POINTERS* pExceptionInfo, PVOID pv); // --------------------------------------------------------------------------- inline CLRException::CLRException() - : m_throwableHandle(NULL) + : m_throwableHandle((OBJECTHANDLE)NULL) { LIMITED_METHOD_CONTRACT; } diff --git a/src/coreclr/vm/clsload.hpp b/src/coreclr/vm/clsload.hpp index 251a76a8f78e4d..fb79f0dfc810e2 100644 --- a/src/coreclr/vm/clsload.hpp +++ b/src/coreclr/vm/clsload.hpp @@ -134,7 +134,7 @@ class NameHandle NameHandle() { LIMITED_METHOD_CONTRACT; - memset((void*) this, NULL, sizeof(*this)); + memset((void*) this, 0, sizeof(*this)); } NameHandle(LPCUTF8 nameSpace, LPCUTF8 name) : diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index 228c65f0041299..3bb10ac6c6bb64 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -3300,7 +3300,7 @@ unsigned EEJitManager::InitializeEHEnumeration(const METHODTOKEN& MethodToken, E EE_ILEXCEPTION * EHInfo = GetCodeHeader(MethodToken)->GetEHInfo(); pEnumState->iCurrentPos = 0; // since the EH info is not compressed, the clause number is used to do the enumeration - pEnumState->pExceptionClauseArray = NULL; + pEnumState->pExceptionClauseArray = 0; if (!EHInfo) return 0; @@ -4005,7 +4005,7 @@ TADDR EEJitManager::FindMethodCode(RangeSection * pRangeSection, PCODE currentPC if ((currentPC < pHp->startAddress) || (currentPC > pHp->endAddress)) { - return NULL; + return 0; } TADDR base = pHp->mapBase; @@ -4052,7 +4052,7 @@ TADDR EEJitManager::FindMethodCode(RangeSection * pRangeSection, PCODE currentPC // previous DWORD, unless we are already on the first DWORD if (startPos < NIBBLES_PER_DWORD) - return NULL; + return 0; startPos = ((startPos >> LOG2_NIBBLES_PER_DWORD) << LOG2_NIBBLES_PER_DWORD) - 1; @@ -4066,7 +4066,7 @@ TADDR EEJitManager::FindMethodCode(RangeSection * pRangeSection, PCODE currentPC // This helps to catch degenerate error cases. This relies on the fact that // startPos cannot ever be bigger than MAX_UINT if (((INT_PTR)startPos) < 0) - return NULL; + return 0; // Find the nibble with the header in the DWORD @@ -4077,7 +4077,7 @@ TADDR EEJitManager::FindMethodCode(RangeSection * pRangeSection, PCODE currentPC } if (startPos == 0 && tmp == 0) - return NULL; + return 0; return base + POSOFF2ADDR(startPos, tmp & NIBBLE_MASK); } @@ -4217,12 +4217,12 @@ void GetUnmanagedStackWalkInfo(IN ULONG64 ControlPc, if (pModuleBase) { - *pModuleBase = NULL; + *pModuleBase = 0; } if (pFuncEntry) { - *pFuncEntry = NULL; + *pFuncEntry = 0; } PEDecoder peDecoder(DacGlobalBase()); @@ -4246,7 +4246,7 @@ void GetUnmanagedStackWalkInfo(IN ULONG64 ControlPc, COUNT_T cbSize = 0; TADDR pExceptionDir = peDecoder.GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_EXCEPTION, &cbSize); - if (pExceptionDir != NULL) + if (pExceptionDir != 0) { // Do a binary search on the static function table of mscorwks.dll. HRESULT hr = E_FAIL; @@ -4320,9 +4320,9 @@ extern "C" void GetRuntimeStackWalkInfo(IN ULONG64 ControlPc, BEGIN_PRESERVE_LAST_ERROR; if (pModuleBase) - *pModuleBase = NULL; + *pModuleBase = 0; if (pFuncEntry) - *pFuncEntry = NULL; + *pFuncEntry = 0; EECodeInfo codeInfo((PCODE)ControlPc); if (!codeInfo.IsValid()) @@ -4467,7 +4467,7 @@ PCODE ExecutionManager::GetCodeStartAddress(PCODE currentPC) EECodeInfo codeInfo(currentPC); if (!codeInfo.IsValid()) - return NULL; + return (PCODE)NULL; return PINSTRToPCODE(codeInfo.GetStartAddress()); } diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 3319d3e0c30033..7d874c6ba7e693 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -2210,9 +2210,9 @@ class ExecutionManager #endif } - static const element_t Null() { LIMITED_METHOD_CONTRACT; JumpStubEntry e; e.m_target = NULL; e.m_jumpStub = NULL; return e; } - static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.m_target == NULL; } - static const element_t Deleted() { LIMITED_METHOD_CONTRACT; JumpStubEntry e; e.m_target = (PCODE)-1; e.m_jumpStub = NULL; return e; } + static const element_t Null() { LIMITED_METHOD_CONTRACT; JumpStubEntry e; e.m_target = 0; e.m_jumpStub = 0; return e; } + static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.m_target == 0; } + static const element_t Deleted() { LIMITED_METHOD_CONTRACT; JumpStubEntry e; e.m_target = (PCODE)-1; e.m_jumpStub = 0; return e; } static bool IsDeleted(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.m_target == (PCODE)-1; } }; typedef SHash JumpStubTable; diff --git a/src/coreclr/vm/codeversion.cpp b/src/coreclr/vm/codeversion.cpp index 741fe0390bb51c..1e38f1647208a1 100644 --- a/src/coreclr/vm/codeversion.cpp +++ b/src/coreclr/vm/codeversion.cpp @@ -60,7 +60,7 @@ NativeCodeVersionNode::NativeCodeVersionNode( PatchpointInfo* patchpointInfo, unsigned ilOffset) : - m_pNativeCode(NULL), + m_pNativeCode((PCODE)NULL), m_pMethodDesc(pMethodDesc), m_parentId(parentId), m_pNextMethodDescSibling(NULL), @@ -303,7 +303,7 @@ void NativeCodeVersion::SetActiveChildFlag(BOOL isActive) { if (isActive && !CodeVersionManager::InitialNativeCodeVersionMayNotBeTheDefaultNativeCodeVersion() && - GetMethodDesc()->GetNativeCode() == NULL) + GetMethodDesc()->GetNativeCode() == (PCODE)NULL) { CodeVersionManager::SetInitialNativeCodeVersionMayNotBeTheDefaultNativeCodeVersion(); } @@ -1690,7 +1690,7 @@ PCODE CodeVersionManager::PublishVersionableCodeIfNecessary( // CodeVersionManager is set (not a typical case, may be possible with profilers). So, if the flag is not set and the // default native code version does not have native code, then it must be the active code version. pCode = pMethodDesc->GetNativeCode(); - if (pCode == NULL && !CodeVersionManager::InitialNativeCodeVersionMayNotBeTheDefaultNativeCodeVersion()) + if (pCode == (PCODE)NULL && !CodeVersionManager::InitialNativeCodeVersionMayNotBeTheDefaultNativeCodeVersion()) { activeVersion = NativeCodeVersion(pMethodDesc); break; @@ -1699,7 +1699,7 @@ PCODE CodeVersionManager::PublishVersionableCodeIfNecessary( if (!pMethodDesc->IsPointingToPrestub()) { *doFullBackpatchRef = true; - return NULL; + return (PCODE)NULL; } LockHolder codeVersioningLockHolder; @@ -1713,7 +1713,7 @@ PCODE CodeVersionManager::PublishVersionableCodeIfNecessary( _ASSERTE(hr == E_OUTOFMEMORY); ReportCodePublishError(pMethodDesc, hr); *doBackpatchRef = false; - return pCode != NULL ? pCode : pMethodDesc->PrepareInitialCode(callerGCMode); + return pCode != (PCODE)NULL ? pCode : pMethodDesc->PrepareInitialCode(callerGCMode); } while (false); while (true) @@ -1724,7 +1724,7 @@ PCODE CodeVersionManager::PublishVersionableCodeIfNecessary( bool profilerMayHaveActivatedNonDefaultCodeVersion = false; // Compile the code if needed - if (pCode == NULL) + if (pCode == (PCODE)NULL) { PrepareCodeConfigBuffer configBuffer(activeVersion); PrepareCodeConfig *config = configBuffer.GetConfig(); @@ -1919,12 +1919,12 @@ HRESULT CodeVersionManager::PublishNativeCodeVersion(MethodDesc* pMethod, Native _ASSERTE(pMethod->IsVersionable()); HRESULT hr = S_OK; - PCODE pCode = nativeCodeVersion.IsNull() ? NULL : nativeCodeVersion.GetNativeCode(); + PCODE pCode = nativeCodeVersion.IsNull() ? (PCODE)NULL : nativeCodeVersion.GetNativeCode(); if (pMethod->IsVersionable()) { EX_TRY { - if (pCode == NULL) + if (pCode == (PCODE)NULL) { pMethod->ResetCodeEntryPoint(); } diff --git a/src/coreclr/vm/codeversion.h b/src/coreclr/vm/codeversion.h index 7b536fb071a62d..a6fabc38c99a08 100644 --- a/src/coreclr/vm/codeversion.h +++ b/src/coreclr/vm/codeversion.h @@ -68,7 +68,7 @@ class NativeCodeVersion #endif #ifndef DACCESS_COMPILE - BOOL SetNativeCodeInterlocked(PCODE pCode, PCODE pExpected = NULL); + BOOL SetNativeCodeInterlocked(PCODE pCode, PCODE pExpected = 0); #endif // NOTE: Don't change existing values to avoid breaking changes in event tracing diff --git a/src/coreclr/vm/comcallablewrapper.cpp b/src/coreclr/vm/comcallablewrapper.cpp index 8bad0356112e05..b80c2442c9097a 100644 --- a/src/coreclr/vm/comcallablewrapper.cpp +++ b/src/coreclr/vm/comcallablewrapper.cpp @@ -553,11 +553,11 @@ FORCEINLINE void CPListDoNothing(CPArray*) LIMITED_METHOD_CONTRACT; } -class CPListHolder : public Wrapper +class CPListHolder : public Wrapper { public: CPListHolder(CPArray* p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -565,7 +565,7 @@ class CPListHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; diff --git a/src/coreclr/vm/comcallablewrapper.h b/src/coreclr/vm/comcallablewrapper.h index 71b79ca0029934..f032204e54cef3 100644 --- a/src/coreclr/vm/comcallablewrapper.h +++ b/src/coreclr/vm/comcallablewrapper.h @@ -343,7 +343,7 @@ inline void ComCallWrapperTemplateRelease(ComCallWrapperTemplate *value) } } -typedef Wrapper, ComCallWrapperTemplateRelease, NULL> ComCallWrapperTemplateHolder; +typedef Wrapper, ComCallWrapperTemplateRelease, 0> ComCallWrapperTemplateHolder; //-------------------------------------------------------------------------------- @@ -1041,11 +1041,11 @@ FORCEINLINE void CCWRelease(ComCallWrapper* p) p->Release(); } -class CCWHolder : public Wrapper +class CCWHolder : public Wrapper { public: CCWHolder(ComCallWrapper* p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -1054,7 +1054,7 @@ class CCWHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; // diff --git a/src/coreclr/vm/comconnectionpoints.h b/src/coreclr/vm/comconnectionpoints.h index c8d3386347222b..f4b90a16d36c4b 100644 --- a/src/coreclr/vm/comconnectionpoints.h +++ b/src/coreclr/vm/comconnectionpoints.h @@ -82,11 +82,11 @@ FORCEINLINE void ConnectionCookieRelease(ConnectionCookie* p) } // Connection cookie holder used to ensure the cookies are deleted when required. -class ConnectionCookieHolder : public Wrapper +class ConnectionCookieHolder : public Wrapper { public: ConnectionCookieHolder(ConnectionCookie* p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -94,7 +94,7 @@ class ConnectionCookieHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index ef4021039a66b8..77664d54f96ac8 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -1172,7 +1172,7 @@ void COMDelegate::BindToMethod(DELEGATEREF *pRefThis, } else { - PCODE pTargetCode = NULL; + PCODE pTargetCode = (PCODE)NULL; // For virtual methods we can (and should) virtualize the call now (so we don't have to insert a thunk to do so at runtime). // @@ -1283,7 +1283,7 @@ LPVOID COMDelegate::ConvertToCallback(OBJECTREF pDelegateObj) _ASSERTE(objhnd != NULL); // This target should not ever be used. We are storing it in the thunk for better diagnostics of "call on collected delegate" crashes. - PCODE pManagedTargetForDiagnostics = (pDelegate->GetMethodPtrAux() != NULL) ? pDelegate->GetMethodPtrAux() : pDelegate->GetMethodPtr(); + PCODE pManagedTargetForDiagnostics = (pDelegate->GetMethodPtrAux() != (PCODE)NULL) ? pDelegate->GetMethodPtrAux() : pDelegate->GetMethodPtr(); ExecutableWriterHolder uMEntryThunkWriterHolder(pUMEntryThunk, sizeof(UMEntryThunk)); @@ -1380,14 +1380,14 @@ OBJECTREF COMDelegate::ConvertToDelegate(LPVOID pCallback, MethodTable* pMT) // PCODE pMarshalStub = pClass->m_pMarshalStub; - if (pMarshalStub == NULL) + if (pMarshalStub == (PCODE)NULL) { GCX_PREEMP(); pMarshalStub = GetStubForInteropMethod(pMD); // Save this new stub on the DelegateEEClass. - InterlockedCompareExchangeT(&pClass->m_pMarshalStub, pMarshalStub, NULL); + InterlockedCompareExchangeT(&pClass->m_pMarshalStub, pMarshalStub, (PCODE)NULL); pMarshalStub = pClass->m_pMarshalStub; } @@ -1595,7 +1595,7 @@ FCIMPL3(void, COMDelegate::DelegateConstruct, Object* refThisUNSAFE, Object* tar // via reflection you can pass in just about any value for the method. // we can do some basic verification up front to prevent EE exceptions. - if (method == NULL) + if (method == (PCODE)NULL) COMPlusThrowArgumentNull(W("method")); _ASSERTE(gc.refThis); @@ -1798,7 +1798,7 @@ MethodDesc *COMDelegate::GetMethodDesc(OBJECTREF orDelegate) // Next, check for an open delegate PCODE code = thisDel->GetMethodPtrAux(); - if (code != NULL) + if (code != (PCODE)NULL) { // Note that MethodTable::GetMethodDescForSlotAddress is significantly faster than Entry2MethodDesc pMethodHandle = MethodTable::GetMethodDescForSlotAddress(code); @@ -1936,7 +1936,7 @@ PCODE COMDelegate::GetInvokeMethodStub(EEImplMethodDesc* pMD) } CONTRACT_END; - PCODE ret = NULL; + PCODE ret = (PCODE)NULL; MethodTable * pDelMT = pMD->GetMethodTable(); DelegateEEClass* pClass = (DelegateEEClass*) pDelMT->GetClass(); diff --git a/src/coreclr/vm/contractimpl.h b/src/coreclr/vm/contractimpl.h index 3f76abfd91f19e..786139745dfde9 100644 --- a/src/coreclr/vm/contractimpl.h +++ b/src/coreclr/vm/contractimpl.h @@ -47,11 +47,11 @@ struct DispatchSlot //------------------------------------------------------------------------ inline BOOL IsNull() - { LIMITED_METHOD_CONTRACT; return (m_slot == NULL); } + { LIMITED_METHOD_CONTRACT; return (m_slot == 0); } //------------------------------------------------------------------------ inline void SetNull() - { LIMITED_METHOD_CONTRACT; m_slot = NULL; } + { LIMITED_METHOD_CONTRACT; m_slot = 0; } //------------------------------------------------------------------------ inline PCODE GetTarget() diff --git a/src/coreclr/vm/corhost.cpp b/src/coreclr/vm/corhost.cpp index b85331e00ce8d2..c0e4091af38a86 100644 --- a/src/coreclr/vm/corhost.cpp +++ b/src/coreclr/vm/corhost.cpp @@ -691,9 +691,9 @@ HRESULT CorHost2::CreateDelegate( EMPTY_STRING_TO_NULL(wszClassName); EMPTY_STRING_TO_NULL(wszMethodName); - if (fnPtr == NULL) + if (fnPtr == 0) return E_POINTER; - *fnPtr = NULL; + *fnPtr = 0; if(wszAssemblyName == NULL) return E_INVALIDARG; diff --git a/src/coreclr/vm/crossloaderallocatorhash.h b/src/coreclr/vm/crossloaderallocatorhash.h index d23ddc0db225d9..735f20382b80ae 100644 --- a/src/coreclr/vm/crossloaderallocatorhash.h +++ b/src/coreclr/vm/crossloaderallocatorhash.h @@ -21,8 +21,8 @@ class NoRemoveDefaultCrossLoaderAllocatorHashTraits static const bool s_supports_remove = false; // CrossLoaderAllocatorHash requires that a particular null value exist, which represents an empty value slot - static bool IsNullValue(const TValue &value) { return value == NULL; } - static TValue NullValue() { return NULL; } + static bool IsNullValue(const TValue &value) { return value == (TValue)NULL; } + static TValue NullValue() { return (TValue)NULL; } static BOOL KeyEquals(const TKey &k1, const TKey &k2) { return k1 == k2; } static BOOL ValueEquals(const TValue &v1, const TValue &v2) { return v1 == v2; } diff --git a/src/coreclr/vm/custommarshalerinfo.cpp b/src/coreclr/vm/custommarshalerinfo.cpp index 81c4122512e65a..d7955a95ade177 100644 --- a/src/coreclr/vm/custommarshalerinfo.cpp +++ b/src/coreclr/vm/custommarshalerinfo.cpp @@ -25,7 +25,7 @@ CustomMarshalerInfo::CustomMarshalerInfo(LoaderAllocator *pLoaderAllocator, Type : m_NativeSize(0) , m_hndManagedType(hndManagedType) , m_pLoaderAllocator(pLoaderAllocator) -, m_hndCustomMarshaler(NULL) +, m_hndCustomMarshaler(0) , m_pMarshalNativeToManagedMD(NULL) , m_pMarshalManagedToNativeMD(NULL) , m_pCleanUpNativeDataMD(NULL) @@ -139,7 +139,7 @@ CustomMarshalerInfo::~CustomMarshalerInfo() // been collected already. m_pLoaderAllocator->FreeHandle(m_hndCustomMarshaler); } - m_hndCustomMarshaler = NULL; + m_hndCustomMarshaler = 0; } diff --git a/src/coreclr/vm/dacenumerablehash.inl b/src/coreclr/vm/dacenumerablehash.inl index 93d63116e0f42a..eb8bd5df6a9c5d 100644 --- a/src/coreclr/vm/dacenumerablehash.inl +++ b/src/coreclr/vm/dacenumerablehash.inl @@ -540,7 +540,7 @@ void DacEnumerableHashTable::BaseInitIterator(BaseIterator * LIMITED_METHOD_DAC_CONTRACT; pIterator->m_pTable = dac_cast)>(this); - pIterator->m_pEntry = NULL; + pIterator->m_pEntry = (TADDR)0; //+2 to skip "length" and "next" slots pIterator->m_dwBucket = SKIP_SPECIAL_SLOTS; } @@ -564,7 +564,7 @@ DPTR(VALUE) DacEnumerableHashTable::BaseIterator::Next() while (m_dwBucket < cBuckets + SKIP_SPECIAL_SLOTS) { - if (m_pEntry == NULL) + if (m_pEntry == (TADDR)0) { // This is our first lookup for a particular bucket, return the first // entry in that bucket. @@ -583,7 +583,7 @@ DPTR(VALUE) DacEnumerableHashTable::BaseIterator::Next() // Otherwise we found the end of a bucket chain. Increment the current bucket and, if there are // buckets left to scan go back around again. - m_pEntry = NULL; + m_pEntry = (TADDR)0; m_dwBucket++; } diff --git a/src/coreclr/vm/debugdebugger.cpp b/src/coreclr/vm/debugdebugger.cpp index a6bdd075afc484..0ba4363cb50be1 100644 --- a/src/coreclr/vm/debugdebugger.cpp +++ b/src/coreclr/vm/debugdebugger.cpp @@ -765,7 +765,7 @@ extern MethodDesc* QCALLTYPE StackFrame_GetMethodDescFromNativeIP(LPVOID ip) } FORCEINLINE void HolderDestroyStrongHandle(OBJECTHANDLE h) { if (h != NULL) DestroyStrongHandle(h); } -typedef Wrapper, HolderDestroyStrongHandle, NULL> StrongHandleHolder; +typedef Wrapper, HolderDestroyStrongHandle, 0> StrongHandleHolder; // receives a custom notification object from the target and sends it to the RS via // code:Debugger::SendCustomDebuggerNotification @@ -977,7 +977,7 @@ StackWalkAction DebugStackTrace::GetStackFramesCallback(CrawlFrame* pCf, VOID* d } else { - ip = NULL; + ip = (PCODE)NULL; dwNativeOffset = 0; } @@ -1162,7 +1162,7 @@ void DebugStackTrace::DebugStackTraceElement::InitPass2() #ifdef DEBUGGING_SUPPORTED // Calculate the IL offset using the debugging services - if ((this->ip != NULL) && g_pDebugInterface) + if ((this->ip != (PCODE)NULL) && g_pDebugInterface) { // To get the source line number of the actual code that threw an exception, the dwOffset needs to be // adjusted in certain cases when calculating the IL offset. diff --git a/src/coreclr/vm/debuginfostore.cpp b/src/coreclr/vm/debuginfostore.cpp index 41978c952dbe29..84269d8b7b0a51 100644 --- a/src/coreclr/vm/debuginfostore.cpp +++ b/src/coreclr/vm/debuginfostore.cpp @@ -1036,7 +1036,7 @@ void DebugInfoManager::EnumMemoryRegionsForMethodDebugInfo(CLRDataEnumMemoryFlag CONTRACTL_END; PCODE addrCode = pMD->GetNativeCode(); - if (addrCode == NULL) + if (addrCode == (PCODE)NULL) { return; } diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 208db4b2ea2d1f..830fbe5a6e1d83 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5610,7 +5610,7 @@ PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, { STANDARD_VM_CONTRACT; - PCODE pStub = NULL; + PCODE pStub = (PCODE)NULL; CONSISTENCY_CHECK(*ppStubMD == NULL); @@ -5620,7 +5620,7 @@ PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, *ppStubMD = NDirect::GetILStubMethodDesc(pNMD, &sigInfo, dwStubFlags); if (SF_IsForNumParamBytes(dwStubFlags)) - return NULL; + return (PCODE)NULL; if (*ppStubMD) { @@ -5667,7 +5667,7 @@ PCODE JitILStub(MethodDesc* pStubMD) PCODE pCode = pStubMD->GetNativeCode(); - if (pCode == NULL) + if (pCode == (PCODE)NULL) { /////////////////////////////// // @@ -5720,7 +5720,7 @@ PCODE GetStubForInteropMethod(MethodDesc* pMD, DWORD dwStubFlags) } CONTRACT_END; - PCODE pStub = NULL; + PCODE pStub = (PCODE)NULL; MethodDesc* pStubMD = NULL; if (pMD->IsNDirect()) @@ -6022,7 +6022,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) } CONTRACT_END; - PCODE pTempILStub = NULL; + PCODE pTempILStub = (PCODE)NULL; INSTALL_MANAGED_EXCEPTION_DISPATCHER; // this function is called by CLR to native assembly stubs which are called by @@ -6125,7 +6125,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) InterlockedCompareExchangeT(&pVASigCookie->pNDirectILStub, pTempILStub, - NULL); + (PCODE)NULL); UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; diff --git a/src/coreclr/vm/dllimportcallback.cpp b/src/coreclr/vm/dllimportcallback.cpp index 4eeab74f68d8cd..b9befb2d4c5efd 100644 --- a/src/coreclr/vm/dllimportcallback.cpp +++ b/src/coreclr/vm/dllimportcallback.cpp @@ -166,7 +166,7 @@ UMEntryThunk *UMEntryThunkCache::GetUMEntryThunk(MethodDesc *pMD) marshInfoWriterHolder.GetRW()->LoadTimeInit(pMD); ExecutableWriterHolder thunkWriterHolder(pThunk, sizeof(UMEntryThunk)); - thunkWriterHolder.GetRW()->LoadTimeInit(pThunk, NULL, NULL, pMarshInfo, pMD); + thunkWriterHolder.GetRW()->LoadTimeInit(pThunk, (PCODE)NULL, NULL, pMarshInfo, pMD); // add it to the cache CacheElement element; diff --git a/src/coreclr/vm/domainassembly.cpp b/src/coreclr/vm/domainassembly.cpp index 823348d32f2363..f81b67b6b584b7 100644 --- a/src/coreclr/vm/domainassembly.cpp +++ b/src/coreclr/vm/domainassembly.cpp @@ -37,8 +37,8 @@ DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoader m_pLoaderAllocator(pLoaderAllocator), m_level(FILE_LOAD_CREATE), m_loading(TRUE), - m_hExposedModuleObject(NULL), - m_hExposedAssemblyObject(NULL), + m_hExposedModuleObject((LOADERHANDLE)NULL), + m_hExposedAssemblyObject((LOADERHANDLE)NULL), m_pError(NULL), m_bDisableActivationCheck(FALSE), m_fHostAssemblyPublished(FALSE), @@ -332,12 +332,12 @@ OBJECTREF DomainAssembly::GetExposedModuleObject() LoaderAllocator * pLoaderAllocator = GetLoaderAllocator(); - if (m_hExposedModuleObject == NULL) + if (m_hExposedModuleObject == (LOADERHANDLE)NULL) { // Atomically create a handle LOADERHANDLE handle = pLoaderAllocator->AllocateHandle(NULL); - InterlockedCompareExchangeT(&m_hExposedModuleObject, handle, static_cast(NULL)); + InterlockedCompareExchangeT(&m_hExposedModuleObject, handle, static_cast(0)); } if (pLoaderAllocator->GetHandleValue(m_hExposedModuleObject) == NULL) @@ -648,13 +648,13 @@ OBJECTREF DomainAssembly::GetExposedAssemblyObject() return NULL; } - if (m_hExposedAssemblyObject == NULL) + if (m_hExposedAssemblyObject == (LOADERHANDLE)NULL) { // Atomically create a handle LOADERHANDLE handle = pLoaderAllocator->AllocateHandle(NULL); - InterlockedCompareExchangeT(&m_hExposedAssemblyObject, handle, static_cast(NULL)); + InterlockedCompareExchangeT(&m_hExposedAssemblyObject, handle, static_cast(0)); } if (pLoaderAllocator->GetHandleValue(m_hExposedAssemblyObject) == NULL) diff --git a/src/coreclr/vm/dynamicmethod.cpp b/src/coreclr/vm/dynamicmethod.cpp index beeb0cd64b2a86..12c5d6f0386f74 100644 --- a/src/coreclr/vm/dynamicmethod.cpp +++ b/src/coreclr/vm/dynamicmethod.cpp @@ -898,7 +898,7 @@ void DynamicMethodDesc::Destroy() delete[] pszMethodName; } - if (pSig != NULL) + if (pSig != (PCODE)NULL) { delete[] (BYTE*)pSig; } diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp index 08adac7213348b..4634a3a3cc5a3e 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.cpp +++ b/src/coreclr/vm/eedbginterfaceimpl.cpp @@ -546,11 +546,11 @@ void EEDbgInterfaceImpl::GetMethodRegionInfo(const PCODE pStart, } CONTRACTL_END; - IJitManager::MethodRegionInfo methodRegionInfo = {NULL, 0, NULL, 0}; + IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0}; EECodeInfo codeInfo(pStart); - if (codeInfo.IsValid() != NULL) + if (codeInfo.IsValid() != (TADDR)NULL) { codeInfo.GetMethodRegionInfo(&methodRegionInfo); } @@ -611,7 +611,7 @@ size_t EEDbgInterfaceImpl::GetFunctionSize(MethodDesc *pFD) PCODE methodStart = pFD->GetNativeCode(); - if (methodStart == NULL) + if (methodStart == (PCODE)NULL) return 0; EECodeInfo codeInfo(methodStart); diff --git a/src/coreclr/vm/eetoprofinterfaceimpl.cpp b/src/coreclr/vm/eetoprofinterfaceimpl.cpp index 81614183fb5d8a..c57c3b897afdd2 100644 --- a/src/coreclr/vm/eetoprofinterfaceimpl.cpp +++ b/src/coreclr/vm/eetoprofinterfaceimpl.cpp @@ -1092,7 +1092,7 @@ UINT_PTR EEToProfInterfaceImpl::EEFunctionIDMapper(FunctionID funcId, BOOL * pbH // which means either m_pProfilersFuncIDMapper or m_pProfilersFuncIDMapper2 should not be NULL; _ASSERTE((m_pProfilersFuncIDMapper != NULL) || (m_pProfilersFuncIDMapper2 != NULL)); - UINT_PTR clientId = NULL; + UINT_PTR clientId = 0; if (m_pProfilersFuncIDMapper2 != NULL) { @@ -5762,7 +5762,7 @@ HRESULT EEToProfInterfaceImpl::HandleCreated(UINT_PTR handleId, ObjectID initial // switch to preemptive (as we normally do in callbacks) and must not trigger, // as this would really tick off some of our callers (as well as invalidating // initialObjectId). - if (initialObjectId != NULL) + if (initialObjectId != 0) { MODE_COOPERATIVE; } diff --git a/src/coreclr/vm/eetoprofinterfaceimpl.h b/src/coreclr/vm/eetoprofinterfaceimpl.h index 995daad9a02edb..6c14c4150d43ad 100644 --- a/src/coreclr/vm/eetoprofinterfaceimpl.h +++ b/src/coreclr/vm/eetoprofinterfaceimpl.h @@ -657,16 +657,16 @@ class EEToProfInterfaceImpl { LIMITED_METHOD_CONTRACT; FunctionIDAndClientID functionIDAndClientID; - functionIDAndClientID.functionID = NULL; - functionIDAndClientID.clientID = NULL; + functionIDAndClientID.functionID = 0; + functionIDAndClientID.clientID = 0; return functionIDAndClientID; } static bool IsNull(const FunctionIDAndClientID &functionIDAndClientID) { LIMITED_METHOD_CONTRACT; - _ASSERTE((functionIDAndClientID.functionID != NULL) || (functionIDAndClientID.clientID == NULL)); - return functionIDAndClientID.functionID == NULL; + _ASSERTE((functionIDAndClientID.functionID != 0) || (functionIDAndClientID.clientID == 0)); + return functionIDAndClientID.functionID == 0; } }; diff --git a/src/coreclr/vm/eetoprofinterfaceimpl.inl b/src/coreclr/vm/eetoprofinterfaceimpl.inl index 1ed73db1f583ac..2791f9a7b2aa25 100644 --- a/src/coreclr/vm/eetoprofinterfaceimpl.inl +++ b/src/coreclr/vm/eetoprofinterfaceimpl.inl @@ -222,7 +222,7 @@ inline UINT_PTR EEToProfInterfaceImpl::LookupClientIDFromCache(FunctionID functi } else { - return NULL; + return 0; } } diff --git a/src/coreclr/vm/eetwain.cpp b/src/coreclr/vm/eetwain.cpp index 4cdfc0852a6a3e..3f28d4b7431530 100644 --- a/src/coreclr/vm/eetwain.cpp +++ b/src/coreclr/vm/eetwain.cpp @@ -2010,7 +2010,7 @@ void * EECodeManager::GetGSCookieAddr(PREGDISPLAY pContext, // Detect the end of GS cookie scope by comparing its address with SP // gcInfoDecoder.GetGSCookieValidRangeEnd() is not accurate. It does not // account for GS cookie going out of scope inside epilog or multiple epilogs. - return (LPVOID) ((ptr >= pContext->SP) ? ptr : NULL); + return (ptr >= pContext->SP) ? (LPVOID)ptr : nullptr; } } return NULL; diff --git a/src/coreclr/vm/encee.cpp b/src/coreclr/vm/encee.cpp index 9b6c487c11a326..7dec6bc2045896 100644 --- a/src/coreclr/vm/encee.cpp +++ b/src/coreclr/vm/encee.cpp @@ -535,7 +535,7 @@ PCODE EditAndContinueModule::JitUpdatedFunction( MethodDesc *pMD, LOG((LF_ENC, LL_INFO100, "EnCModule::JitUpdatedFunction for %s::%s\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); - PCODE jittedCode = NULL; + PCODE jittedCode = (PCODE)NULL; GCX_COOP(); @@ -648,7 +648,7 @@ HRESULT EditAndContinueModule::ResumeInUpdatedFunction( // JIT-compile the updated version of the method PCODE jittedCode = JitUpdatedFunction(pMD, pOrigContext); - if ( jittedCode == NULL ) + if ( jittedCode == (PCODE)NULL ) return CORDBG_E_ENC_JIT_CANT_UPDATE; GCX_COOP(); diff --git a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp index 8542b2d0a904cd..b9443711b4aacf 100644 --- a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp +++ b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp @@ -49,14 +49,14 @@ stack_walk_callback ( // Get the IP. UINT_PTR control_pc = (UINT_PTR)frame->GetRegisterSet ()->ControlPC; - if (control_pc == NULL) { + if (control_pc == 0) { if (ep_stack_contents_get_length (stack_contents) == 0) { // This happens for pinvoke stubs on the top of the stack. return SWA_CONTINUE; } } - EP_ASSERT (control_pc != NULL); + EP_ASSERT (control_pc != 0); // Add the IP to the captured stack. ep_stack_contents_append (stack_contents, control_pc, frame->GetFunction ()); diff --git a/src/coreclr/vm/eventpipeinternal.cpp b/src/coreclr/vm/eventpipeinternal.cpp index 57cf10ff30a11f..bd35deaaeb6066 100644 --- a/src/coreclr/vm/eventpipeinternal.cpp +++ b/src/coreclr/vm/eventpipeinternal.cpp @@ -146,7 +146,7 @@ extern "C" void QCALLTYPE EventPipeInternal_DeleteProvider(INT_PTR provHandle) QCALL_CONTRACT; BEGIN_QCALL; - if (provHandle != NULL) + if (provHandle != 0) { EventPipeProvider *pProvider = reinterpret_cast(provHandle); EventPipeAdapter::DeleteProvider(pProvider); diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 1bac59f998fdca..a248614a313d35 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -643,7 +643,7 @@ class LoggedTypesFromModuleTraits : public NoRemoveSHashTraits< DefaultSHashTrai static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; - return (e.th.AsTAddr() == NULL); + return (e.th.AsTAddr() == 0); } static const element_t Null() @@ -4211,7 +4211,7 @@ static void GetCodeViewInfo(Module * pModule, CV_INFO_PDB70 * pCvInfoIL, CV_INFO // Some compilers set PointerToRawData but not AddressOfRawData as they put the // data at the end of the file in an unmapped part of the file - RVA rvaOfRawData = (rgDebugEntries[i].AddressOfRawData != NULL) ? + RVA rvaOfRawData = (rgDebugEntries[i].AddressOfRawData != 0) ? rgDebugEntries[i].AddressOfRawData : pLayout->OffsetToRva(rgDebugEntries[i].PointerToRawData); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 7437a7988adaeb..dcc5442c40a8f7 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -5787,7 +5787,7 @@ LPVOID COMPlusCheckForAbort(UINT_PTR uTryCatchResumeAddress) // Reverse COM interop IL stubs map all exceptions to HRESULTs and must not propagate Thread.Abort // to their unmanaged callers. - if (uTryCatchResumeAddress != NULL) + if (uTryCatchResumeAddress != (UINT_PTR)NULL) { MethodDesc * pMDResumeMethod = ExecutionManager::GetCodeMethodDesc((PCODE)uTryCatchResumeAddress); if (pMDResumeMethod->IsILStub()) diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h index b84f0ef93e340d..8e8ddacabe6b72 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -503,7 +503,7 @@ extern "C" BOOL ExceptionIsOfRightType(TypeHandle clauseType, TypeHandle thrownT // Specify NULL for uTryCatchResumeAddress when not checking for a InducedThreadRedirectAtEndOfCatch -EXTERN_C LPVOID COMPlusCheckForAbort(UINT_PTR uTryCatchResumeAddress = NULL); +EXTERN_C LPVOID COMPlusCheckForAbort(UINT_PTR uTryCatchResumeAddress = 0); BOOL IsThreadHijackedForThreadStop(Thread* pThread, EXCEPTION_RECORD* pExceptionRecord); void AdjustContextForThreadStop(Thread* pThread, T_CONTEXT* pContext); diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index d206fb419fd751..8760a618fcda99 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -1667,7 +1667,7 @@ void ExceptionTracker::InitializeCrawlFrame(CrawlFrame* pcfThisFrame, Thread* pT pcfThisFrame->isFrameless = false; pcfThisFrame->pFunc = NULL; - *puMethodStartPC = NULL; + *puMethodStartPC = 0; } pcfThisFrame->pThread = pThread; @@ -1962,7 +1962,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // then we do this for all P/Invokes except ones in IL stubs. // IL stubs link the frame in for the whole stub, so if an exception is thrown during marshalling, // the ICF will be on the frame chain and inactive. - if (returnAddress != NULL && !ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub()) + if (returnAddress != (TADDR)NULL && !ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub()) #else // If we aren't setting up the frame for each P/Invoke (instead setting up once per method), // then ReadyToRun code is the only code using the per-P/Invoke logic. @@ -2156,7 +2156,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // If we are unwinding and the exception was not caught in managed code and we have reached the // topmost frame we saw in the first pass, then reset thread abort state if this is the last managed // code personality routine on the stack. - if ((fIsFirstPass == false) && (this->GetTopmostStackFrameFromFirstPass() == sf) && (GetCatchToCallPC() == NULL)) + if ((fIsFirstPass == false) && (this->GetTopmostStackFrameFromFirstPass() == sf) && (GetCatchToCallPC() == 0)) { ExceptionTracker::ResetThreadAbortStatus(pThread, &cfThisFrame, sf); } @@ -2443,7 +2443,7 @@ CLRUnwindStatus ExceptionTracker::ProcessExplicitFrame( // // Update stack trace // - m_StackTraceInfo.AppendElement(CanAllocateMemory(), NULL, sf.SP, pMD, pcfThisFrame); + m_StackTraceInfo.AppendElement(CanAllocateMemory(), 0, sf.SP, pMD, pcfThisFrame); m_StackTraceInfo.SaveStackTrace(CanAllocateMemory(), m_hThrowable, bReplaceStack, bSkipLastElement); // @@ -2690,7 +2690,7 @@ CLRUnwindStatus ExceptionTracker::ProcessManagedCallFrame( if (!fIgnoreThisFrame) { BOOL fFoundHandler = FALSE; - DWORD_PTR dwHandlerStartPC = NULL; + DWORD_PTR dwHandlerStartPC = 0; BOOL bReplaceStack = FALSE; BOOL bSkipLastElement = FALSE; @@ -3006,7 +3006,7 @@ CLRUnwindStatus ExceptionTracker::ProcessManagedCallFrame( // reset all the information we have saved when we find the handler. m_ExceptionFlags.ResetUnwindingToFindResumeFrame(); - m_uCatchToCallPC = NULL; + m_uCatchToCallPC = 0; m_pClauseForCatchToken = NULL; m_sfResumeStackFrame.Clear(); @@ -4564,7 +4564,7 @@ VOID UnwindManagedExceptionPass2(PAL_SEHException& ex, CONTEXT* unwindStartConte CONTEXT contextStorage; DISPATCHER_CONTEXT dispatcherContext; EECodeInfo codeInfo; - UINT_PTR establisherFrame = NULL; + UINT_PTR establisherFrame = 0; PVOID handlerData; // Indicate that we are performing second pass. @@ -4747,7 +4747,7 @@ VOID DECLSPEC_NORETURN UnwindManagedExceptionPass1(PAL_SEHException& ex, CONTEXT DISPATCHER_CONTEXT dispatcherContext; EECodeInfo codeInfo; UINT_PTR controlPc; - UINT_PTR establisherFrame = NULL; + UINT_PTR establisherFrame = 0; PVOID handlerData; #ifdef FEATURE_HIJACK @@ -8239,7 +8239,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk bool canAllocateMemory = !(pExInfo->m_exception == CLRException::GetPreallocatedOutOfMemoryException()) && !(pExInfo->m_exception == CLRException::GetPreallocatedStackOverflowException()); - pExInfo->m_StackTraceInfo.AppendElement(canAllocateMemory, NULL, GetRegdisplaySP(pExInfo->m_frameIter.m_crawl.GetRegisterSet()), pMD, &pExInfo->m_frameIter.m_crawl); + pExInfo->m_StackTraceInfo.AppendElement(canAllocateMemory, 0, GetRegdisplaySP(pExInfo->m_frameIter.m_crawl.GetRegisterSet()), pMD, &pExInfo->m_frameIter.m_crawl); pExInfo->m_StackTraceInfo.SaveStackTrace(canAllocateMemory, pExInfo->m_hThrowable, /*bReplaceStack*/FALSE, /*bSkipLastElement*/FALSE); #if defined(DEBUGGING_SUPPORTED) @@ -8509,7 +8509,7 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla bool canAllocateMemory = !(pTopExInfo->m_exception == CLRException::GetPreallocatedOutOfMemoryException()) && !(pTopExInfo->m_exception == CLRException::GetPreallocatedStackOverflowException()); - pTopExInfo->m_StackTraceInfo.AppendElement(canAllocateMemory, NULL, GetRegdisplaySP(pTopExInfo->m_frameIter.m_crawl.GetRegisterSet()), pMD, &pTopExInfo->m_frameIter.m_crawl); + pTopExInfo->m_StackTraceInfo.AppendElement(canAllocateMemory, 0, GetRegdisplaySP(pTopExInfo->m_frameIter.m_crawl.GetRegisterSet()), pMD, &pTopExInfo->m_frameIter.m_crawl); pTopExInfo->m_StackTraceInfo.SaveStackTrace(canAllocateMemory, pTopExInfo->m_hThrowable, /*bReplaceStack*/FALSE, /*bSkipLastElement*/FALSE); #if defined(DEBUGGING_SUPPORTED) diff --git a/src/coreclr/vm/exceptionhandling.h b/src/coreclr/vm/exceptionhandling.h index 7be99adfd2021f..5ac4337759d466 100644 --- a/src/coreclr/vm/exceptionhandling.h +++ b/src/coreclr/vm/exceptionhandling.h @@ -132,7 +132,7 @@ struct ExceptionTrackerBase ExceptionTrackerBase(PTR_EXCEPTION_RECORD pExceptionRecord, PTR_CONTEXT pExceptionContext, PTR_ExceptionTrackerBase pPrevNestedInfo) : m_pPrevNestedInfo(pPrevNestedInfo), - m_hThrowable(NULL), + m_hThrowable(0), m_ptrs({pExceptionRecord, pExceptionContext}), m_fDeliveredFirstChanceNotification(FALSE), m_ExceptionCode((pExceptionRecord != PTR_NULL) ? pExceptionRecord->ExceptionCode : 0) @@ -164,7 +164,7 @@ struct ExceptionTrackerBase } CONTRACTL_END; - if (NULL != m_hThrowable) + if (0 != m_hThrowable) { return ObjectFromHandle(m_hThrowable); } @@ -265,7 +265,7 @@ class ExceptionTracker : public ExceptionTrackerBase PTR_CONTEXT pContextRecord) : ExceptionTrackerBase(pExceptionRecord, pContextRecord, PTR_NULL), m_pThread(GetThread()), - m_uCatchToCallPC(NULL), + m_uCatchToCallPC(0), m_pSkipToParentFunctionMD(NULL), // these members were added for resume frame processing m_pClauseForCatchToken(NULL) diff --git a/src/coreclr/vm/exinfo.cpp b/src/coreclr/vm/exinfo.cpp index 8731a20ba585b2..424af106e94423 100644 --- a/src/coreclr/vm/exinfo.cpp +++ b/src/coreclr/vm/exinfo.cpp @@ -317,7 +317,7 @@ ExInfo::ExInfo(Thread *pThread, EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pEx m_kind(exceptionKind), m_passNumber(1), m_idxCurClause(0xffffffff), - m_notifyDebuggerSP(NULL), + m_notifyDebuggerSP(0), m_pFrame(pThread->GetFrame()), m_ClauseForCatch({}), #ifdef HOST_UNIX diff --git a/src/coreclr/vm/exstate.cpp b/src/coreclr/vm/exstate.cpp index b9b1ddc05fd5bb..a1dac744e91af4 100644 --- a/src/coreclr/vm/exstate.cpp +++ b/src/coreclr/vm/exstate.cpp @@ -23,7 +23,7 @@ OBJECTHANDLE ThreadExceptionState::GetThrowableAsHandle() return m_pCurrentTracker->m_hThrowable; } - return NULL; + return (OBJECTHANDLE)NULL; #else // FEATURE_EH_FUNCLETS return m_currentExInfo.m_hThrowable; #endif // FEATURE_EH_FUNCLETS diff --git a/src/coreclr/vm/fptrstubs.cpp b/src/coreclr/vm/fptrstubs.cpp index 05c4fedf22d742..051f00cfb6e795 100644 --- a/src/coreclr/vm/fptrstubs.cpp +++ b/src/coreclr/vm/fptrstubs.cpp @@ -79,7 +79,7 @@ PCODE FuncPtrStubs::GetFuncPtrStub(MethodDesc * pMD, PrecodeType type) return pPrecode->GetEntryPoint(); } - PCODE target = NULL; + PCODE target = (PCODE)NULL; bool setTargetAfterAddingToHashTable = false; if (type != GetDefaultType(pMD) && @@ -123,7 +123,7 @@ PCODE FuncPtrStubs::GetFuncPtrStub(MethodDesc * pMD, PrecodeType type) AllocMemTracker amt; Precode* pNewPrecode = Precode::Allocate(type, pMD, pMD->GetLoaderAllocator(), &amt); - if (target != NULL) + if (target != (PCODE)NULL) { pNewPrecode->SetTargetInterlocked(target); } diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index cfd8eb11a7a9cc..b4fbf4a7fb4f0e 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -592,7 +592,7 @@ StubDispatchFrame::StubDispatchFrame(TransitionBlock * pTransitionBlock) m_representativeSlot = 0; m_pZapModule = NULL; - m_pIndirection = NULL; + m_pIndirection = (TADDR)NULL; m_pGCRefMap = NULL; } @@ -668,7 +668,7 @@ PTR_BYTE StubDispatchFrame::GetGCRefMap() if (pGCRefMap == NULL) { - if (m_pIndirection != NULL) + if (m_pIndirection != (TADDR)NULL) { if (m_pZapModule == NULL) { @@ -688,7 +688,7 @@ PTR_BYTE StubDispatchFrame::GetGCRefMap() else { // Clear the indirection to avoid retrying - m_pIndirection = NULL; + m_pIndirection = (TADDR)NULL; } #endif } @@ -770,7 +770,7 @@ ExternalMethodFrame::ExternalMethodFrame(TransitionBlock * pTransitionBlock) { LIMITED_METHOD_CONTRACT; - m_pIndirection = NULL; + m_pIndirection = (TADDR)NULL; m_pZapModule = NULL; m_pGCRefMap = NULL; @@ -798,7 +798,7 @@ PTR_BYTE ExternalMethodFrame::GetGCRefMap() if (pGCRefMap == NULL) { - if (m_pIndirection != NULL) + if (m_pIndirection != (TADDR)NULL) { pGCRefMap = FindGCRefMap(m_pZapModule, m_pIndirection); #ifndef DACCESS_COMPILE @@ -1995,7 +1995,7 @@ VOID InlinedCallFrame::Init() m_Datum = NULL; m_pCallSiteSP = NULL; - m_pCallerReturnAddress = NULL; + m_pCallerReturnAddress = (TADDR)NULL; } diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index ea7eb1e1941360..512ce37520a709 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -464,7 +464,7 @@ class Frame : public FrameBase virtual TADDR GetReturnAddressPtr() { LIMITED_METHOD_DAC_CONTRACT; - return NULL; + return 0; } // ASAN doesn't like us messing with the return address. @@ -472,7 +472,7 @@ class Frame : public FrameBase { WRAPPER_NO_CONTRACT; TADDR ptr = GetReturnAddressPtr(); - return (ptr != NULL) ? *PTR_PCODE(ptr) : NULL; + return (ptr != 0) ? *PTR_PCODE(ptr) : 0; } #ifndef DACCESS_COMPILE @@ -604,13 +604,13 @@ class Frame : public FrameBase { LIMITED_METHOD_CONTRACT; if (ip) - *ip = NULL; + *ip = 0; if (returnIP) - *returnIP = NULL; + *returnIP = 0; if (returnSP) - *returnSP = NULL; + *returnSP = 0; } // Return where the frame will execute next - the result is filled @@ -1258,7 +1258,7 @@ class HelperMethodFrame : public Frame return unwoundState.GetRetAddr(); #else // !DACCESS_COMPILE _ASSERTE(!"HMF's should always be initialized in the non-DAC world."); - return NULL; + return 0; #endif // !DACCESS_COMPILE } @@ -2730,13 +2730,13 @@ class DebuggerExitFrame : public Frame { LIMITED_METHOD_CONTRACT; if (ip) - *ip = NULL; + *ip = 0; if (returnIP) - *returnIP = NULL; + *returnIP = 0; if (returnSP) - *returnSP = NULL; + *returnSP = 0; } // Keep as last entry in class @@ -2838,7 +2838,7 @@ class InlinedCallFrame : public Frame return PTR_HOST_MEMBER_TADDR(InlinedCallFrame, this, m_pCallerReturnAddress); else - return NULL; + return 0; } virtual BOOL NeedsUpdateRegDisplay() @@ -2943,13 +2943,13 @@ class InlinedCallFrame : public Frame return pFrame && pFrame != FRAME_TOP && InlinedCallFrame::GetMethodFrameVPtr() == pFrame->GetVTablePtr() && - dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != NULL; + dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != 0; } // Marks the frame as inactive. void Reset() { - m_pCallerReturnAddress = NULL; + m_pCallerReturnAddress = 0; } int GetFrameType() diff --git a/src/coreclr/vm/gchandleutilities.h b/src/coreclr/vm/gchandleutilities.h index 1f0e7013f22b61..5545a925e078c1 100644 --- a/src/coreclr/vm/gchandleutilities.h +++ b/src/coreclr/vm/gchandleutilities.h @@ -53,7 +53,7 @@ inline BOOL IsHandleNullUnchecked(OBJECTHANDLE handle) { LIMITED_METHOD_CONTRACT; - return (handle == NULL || (*(_UNCHECKED_OBJECTREF *)handle) == NULL); + return (handle == (OBJECTHANDLE)NULL || (*(_UNCHECKED_OBJECTREF *)handle) == NULL); } inline BOOL ObjectHandleIsNull(OBJECTHANDLE handle) @@ -331,8 +331,8 @@ inline void DestroyTypedHandle(OBJECTHANDLE handle) #ifndef FEATURE_NATIVEAOT typedef Wrapper, DestroyHandle> OHWrapper; -typedef Wrapper, DestroyPinningHandle, NULL> PinningHandleHolder; -typedef Wrapper, DestroyAsyncPinningHandle, NULL> AsyncPinningHandleHolder; +typedef Wrapper, DestroyPinningHandle, 0> PinningHandleHolder; +typedef Wrapper, DestroyAsyncPinningHandle, 0> AsyncPinningHandleHolder; typedef Wrapper, DestroyRefcountedHandle> RefCountedOHWrapper; typedef Holder, DestroyLongWeakHandle> LongWeakHandleHolder; diff --git a/src/coreclr/vm/genmeth.cpp b/src/coreclr/vm/genmeth.cpp index 507eb4122a2e28..a4d28d12eff614 100644 --- a/src/coreclr/vm/genmeth.cpp +++ b/src/coreclr/vm/genmeth.cpp @@ -903,7 +903,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD, // Indicate that this is a stub method which takes a BOXed this pointer. // An BoxedEntryPointStub may still be an InstantiatedMethodDesc pResultMD->SetIsUnboxingStub(); - pResultMD->AsInstantiatedMethodDesc()->SetupWrapperStubWithInstantiations(pMDescInCanonMT, NULL, NULL); + pResultMD->AsInstantiatedMethodDesc()->SetupWrapperStubWithInstantiations(pMDescInCanonMT, 0, NULL); pResultMD->SetTemporaryEntryPoint(pAllocator, &amt); diff --git a/src/coreclr/vm/hash.cpp b/src/coreclr/vm/hash.cpp index 749783c6ccfb7a..54791c5fff9ba4 100644 --- a/src/coreclr/vm/hash.cpp +++ b/src/coreclr/vm/hash.cpp @@ -780,7 +780,7 @@ UPTR HashMap::Gethash (UPTR key) STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_FORBID_FAULT; - return LookupValue(key,NULL); + return LookupValue(key,0); } diff --git a/src/coreclr/vm/ilstubresolver.cpp b/src/coreclr/vm/ilstubresolver.cpp index 1efb9c2975e166..980d62032a4c9d 100644 --- a/src/coreclr/vm/ilstubresolver.cpp +++ b/src/coreclr/vm/ilstubresolver.cpp @@ -116,7 +116,7 @@ OBJECTHANDLE ILStubResolver::ConstructStringLiteral(mdToken token) { STANDARD_VM_CONTRACT; _ASSERTE(FALSE); - return NULL; + return (OBJECTHANDLE)NULL; } BOOL ILStubResolver::IsValidStringRef(mdToken metaTok) diff --git a/src/coreclr/vm/ilstubresolver.h b/src/coreclr/vm/ilstubresolver.h index ea823e7f773804..72372b21e0e3d8 100644 --- a/src/coreclr/vm/ilstubresolver.h +++ b/src/coreclr/vm/ilstubresolver.h @@ -76,7 +76,7 @@ class ILStubResolver : DynamicResolver enum CompileTimeStatePtrSpecialValues { - ILNotYetGenerated = NULL, + ILNotYetGenerated = 0, ILGeneratedAndFreed = 1, }; @@ -106,7 +106,7 @@ class ILStubResolver : DynamicResolver PTR_LoaderHeap m_loaderHeap; }; -typedef Holder, ILStubResolver::StubGenFailed, NULL> ILStubGenHolder; +typedef Holder, ILStubResolver::StubGenFailed, 0> ILStubGenHolder; #endif // __ILSTUBRESOLVER_H__ diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index 7a91cd41f7c14b..e5e10b0fecae51 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -3026,11 +3026,11 @@ FORCEINLINE void DispParamHolderRelease(VARIANT* value) } } -class DispParamHolder : public Wrapper +class DispParamHolder : public Wrapper { public: DispParamHolder(VARIANT* p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -3038,7 +3038,7 @@ class DispParamHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; diff --git a/src/coreclr/vm/invokeutil.cpp b/src/coreclr/vm/invokeutil.cpp index 7d0c8f80becdb7..cfec2c5259a5f1 100644 --- a/src/coreclr/vm/invokeutil.cpp +++ b/src/coreclr/vm/invokeutil.cpp @@ -692,7 +692,7 @@ OBJECTREF InvokeUtil::CreateTargetExcept(OBJECTREF* except) { } else { - args[1] = NULL; + args[1] = 0; } ctor.Call(args); diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 18629a0da24141..9bf29137fbb0e6 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -5042,7 +5042,7 @@ HCIMPLEND static PCODE JitPatchpointWorker(MethodDesc* pMD, EECodeInfo& codeInfo, int ilOffset) { STANDARD_VM_CONTRACT; - PCODE osrVariant = NULL; + PCODE osrVariant = (PCODE)NULL; // Fetch the patchpoint info for the current method EEJitManager* jitMgr = ExecutionManager::GetEEJitManager(); @@ -5054,7 +5054,7 @@ static PCODE JitPatchpointWorker(MethodDesc* pMD, EECodeInfo& codeInfo, int ilOf { // Unexpected, but not fatal STRESS_LOG1(LF_TIEREDCOMPILATION, LL_WARNING, "JitPatchpointWorker: failed to restore patchpoint info for Method=0x%pM\n", pMD); - return NULL; + return (PCODE)NULL; } // Set up a new native code version for the OSR variant of this method. @@ -5069,7 +5069,7 @@ static PCODE JitPatchpointWorker(MethodDesc* pMD, EECodeInfo& codeInfo, int ilOf { // Unexpected, but not fatal STRESS_LOG1(LF_TIEREDCOMPILATION, LL_WARNING, "JitPatchpointWorker: failed to add native code version for Method=0x%pM\n", pMD); - return NULL; + return (PCODE)NULL; } } @@ -5087,7 +5087,7 @@ static PCODE JitPatchpointWorker(MethodDesc* pMD, EECodeInfo& codeInfo, int ilOf // Helper method wrapper to set up a frame so we can invoke methods that might GC HCIMPL3(PCODE, JIT_Patchpoint_Framed, MethodDesc* pMD, EECodeInfo& codeInfo, int ilOffset) { - PCODE result = NULL; + PCODE result = (PCODE)NULL; HELPER_METHOD_FRAME_BEGIN_RET_0(); @@ -5129,7 +5129,7 @@ void JIT_Patchpoint(int* counter, int ilOffset) LoaderAllocator* allocator = pMD->GetLoaderAllocator(); OnStackReplacementManager* manager = allocator->GetOnStackReplacementManager(); PerPatchpointInfo * ppInfo = manager->GetPerPatchpointInfo(ip); - PCODE osrMethodCode = NULL; + PCODE osrMethodCode = (PCODE)NULL; bool isNewMethod = false; // In the current prototype, counter is shared by all patchpoints @@ -5164,7 +5164,7 @@ void JIT_Patchpoint(int* counter, int ilOffset) // See if we have an OSR method for this patchpoint. osrMethodCode = ppInfo->m_osrMethodCode; - if (osrMethodCode == NULL) + if (osrMethodCode == (PCODE)NULL) { // No OSR method yet, let's see if we should create one. // @@ -5266,7 +5266,7 @@ void JIT_Patchpoint(int* counter, int ilOffset) osrMethodCode = HCCALL3(JIT_Patchpoint_Framed, pMD, codeInfo, ilOffset); // If that failed, mark the patchpoint as invalid. - if (osrMethodCode == NULL) + if (osrMethodCode == (PCODE)NULL) { // Unexpected, but not fatal STRESS_LOG3(LF_TIEREDCOMPILATION, LL_WARNING, "Jit_Patchpoint: patchpoint (0x%p) OSR method creation failed," @@ -5454,7 +5454,7 @@ HCIMPL1(VOID, JIT_PartialCompilationPatchpoint, int ilOffset) { GCX_PREEMP(); - while (ppInfo->m_osrMethodCode == NULL) + while (ppInfo->m_osrMethodCode == (PCODE)NULL) { // Invalid patchpoints are fatal, for partial compilation patchpoints // @@ -5500,7 +5500,7 @@ HCIMPL1(VOID, JIT_PartialCompilationPatchpoint, int ilOffset) // If that failed, mark the patchpoint as invalid. // This is fatal, for partial compilation patchpoints // - if (newMethodCode == NULL) + if (newMethodCode == (PCODE)NULL) { STRESS_LOG3(LF_TIEREDCOMPILATION, LL_WARNING, "Jit_PartialCompilationPatchpoint: patchpoint (0x%p) OSR method creation failed," " marking patchpoint invalid for Method=0x%pM il offset %d\n", ip, pMD, ilOffset); @@ -5809,7 +5809,7 @@ HCIMPL2(void, JIT_DelegateProfile32, Object *obj, ICorJitInfo::HandleHistogram32 // MethodDesc* pRecordedMD = (MethodDesc*)DEFAULT_UNKNOWN_HANDLE; DELEGATEREF del = (DELEGATEREF)objRef; - if ((del->GetInvocationCount() == 0) && (del->GetMethodPtrAux() == NULL)) + if ((del->GetInvocationCount() == 0) && (del->GetMethodPtrAux() == (PCODE)NULL)) { MethodDesc* pMD = NonVirtualEntry2MethodDesc(del->GetMethodPtr()); if ((pMD != nullptr) && !pMD->GetLoaderAllocator()->IsCollectible() && !pMD->IsDynamicMethod()) @@ -5856,7 +5856,7 @@ HCIMPL2(void, JIT_DelegateProfile64, Object *obj, ICorJitInfo::HandleHistogram64 // MethodDesc* pRecordedMD = (MethodDesc*)DEFAULT_UNKNOWN_HANDLE; DELEGATEREF del = (DELEGATEREF)objRef; - if ((del->GetInvocationCount() == 0) && (del->GetMethodPtrAux() == NULL)) + if ((del->GetInvocationCount() == 0) && (del->GetMethodPtrAux() == (PCODE)NULL)) { MethodDesc* pMD = NonVirtualEntry2MethodDesc(del->GetMethodPtr()); if ((pMD != nullptr) && !pMD->GetLoaderAllocator()->IsCollectible() && !pMD->IsDynamicMethod()) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 0889e131f037cb..43d4ca4f1c9509 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -823,7 +823,7 @@ CHECK CheckContext(CORINFO_MODULE_HANDLE scopeHnd, CORINFO_CONTEXT_HANDLE contex if (context != METHOD_BEING_COMPILED_CONTEXT()) { CHECK_MSG(scopeHnd != NULL, "Illegal null scope"); - CHECK_MSG(((size_t)context & ~CORINFO_CONTEXTFLAGS_MASK) != NULL, "Illegal null context"); + CHECK_MSG(((size_t)context & ~CORINFO_CONTEXTFLAGS_MASK) != 0, "Illegal null context"); if (((size_t)context & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_CLASS) { TypeHandle handle((CORINFO_CLASS_HANDLE)((size_t)context & ~CORINFO_CONTEXTFLAGS_MASK)); @@ -869,9 +869,9 @@ void CEEInfo::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken _ASSERTE(CheckContext(pResolvedToken->tokenScope, pResolvedToken->tokenContext)); pResolvedToken->pTypeSpec = NULL; - pResolvedToken->cbTypeSpec = NULL; + pResolvedToken->cbTypeSpec = 0; pResolvedToken->pMethodSpec = NULL; - pResolvedToken->cbMethodSpec = NULL; + pResolvedToken->cbMethodSpec = 0; TypeHandle th; MethodDesc * pMD = NULL; @@ -12388,7 +12388,7 @@ void CEEJitInfo::setEHinfo ( if (m_pMethodBeingCompiled->IsDynamicMethod() && ((pEHClause->Flags & COR_ILEXCEPTION_CLAUSE_FILTER) == 0) && - (clause->ClassToken != NULL)) + (clause->ClassToken != mdTokenNil)) { ResolvedToken resolved{}; m_pMethodBeingCompiled->AsDynamicMethodDesc()->GetResolver()->ResolveToken(clause->ClassToken, &resolved); @@ -12878,7 +12878,7 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config, NativeCodeVersion nativeCodeVersion = config->GetCodeVersion(); MethodDesc* ftn = nativeCodeVersion.GetMethodDesc(); - PCODE ret = NULL; + PCODE ret = (PCODE)NULL; NormalizedTimer timer; int64_t c100nsTicksInJit = 0; @@ -14511,7 +14511,7 @@ EECodeInfo::EECodeInfo() { WRAPPER_NO_CONTRACT; - m_codeAddress = NULL; + m_codeAddress = (PCODE)NULL; m_pJM = NULL; m_pMD = NULL; diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index 90c3fdcc9f4d01..6f0abb7fa70fce 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -720,7 +720,7 @@ class CEEJitInfo : public CEEInfo #endif #ifdef FEATURE_EH_FUNCLETS - m_moduleBase = NULL; + m_moduleBase = (TADDR)0; m_totalUnwindSize = 0; m_usedUnwindSize = 0; m_theUnwindBlock = NULL; @@ -803,7 +803,7 @@ class CEEJitInfo : public CEEInfo m_pCodeHeap(NULL), m_ILHeader(header), #ifdef FEATURE_EH_FUNCLETS - m_moduleBase(NULL), + m_moduleBase(0), m_totalUnwindSize(0), m_usedUnwindSize(0), m_theUnwindBlock(NULL), diff --git a/src/coreclr/vm/listlock.h b/src/coreclr/vm/listlock.h index 8ad1fe4c967a5b..7c196d9e7d000c 100644 --- a/src/coreclr/vm/listlock.h +++ b/src/coreclr/vm/listlock.h @@ -65,7 +65,7 @@ class ListLockEntryBase m_pNext(NULL), m_dwRefCount(1), m_hrResultCode(S_FALSE), - m_hInitException(NULL), + m_hInitException((LOADERHANDLE)0), m_pLoaderAllocator(dac_cast(nullptr)) { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/loaderallocator.cpp b/src/coreclr/vm/loaderallocator.cpp index 53e5b679cfb6f2..607fdb8fd91f34 100644 --- a/src/coreclr/vm/loaderallocator.cpp +++ b/src/coreclr/vm/loaderallocator.cpp @@ -34,7 +34,7 @@ LoaderAllocator::LoaderAllocator(bool collectible) : m_pDynamicHelpersHeap = NULL; #endif m_pFuncPtrStubs = NULL; - m_hLoaderAllocatorObjectHandle = NULL; + m_hLoaderAllocatorObjectHandle = (OBJECTHANDLE)NULL; m_pStringLiteralMap = NULL; m_cReferences = (UINT32)-1; @@ -759,7 +759,7 @@ LOADERHANDLE LoaderAllocator::AllocateHandle(OBJECTREF value) gc.loaderAllocator = (LOADERALLOCATORREF)ObjectFromHandle(m_hLoaderAllocatorObjectHandle); if (gc.loaderAllocator == NULL) { // The managed LoaderAllocator is already collected, we cannot allocate any exposed managed objects for it - retVal = NULL; + retVal = (LOADERHANDLE)NULL; } else { diff --git a/src/coreclr/vm/marshalnative.cpp b/src/coreclr/vm/marshalnative.cpp index 40fc30849c3bb2..1406458b11d36e 100644 --- a/src/coreclr/vm/marshalnative.cpp +++ b/src/coreclr/vm/marshalnative.cpp @@ -104,7 +104,7 @@ extern "C" BOOL QCALLTYPE MarshalNative_TryGetStructMarshalStub(void* enregister if (th.IsBlittable()) { - *pStructMarshalStub = NULL; + *pStructMarshalStub = (PCODE)NULL; *pSize = th.GetMethodTable()->GetNativeSize(); ret = TRUE; } @@ -131,7 +131,7 @@ extern "C" BOOL QCALLTYPE MarshalNative_TryGetStructMarshalStub(void* enregister } else { - *pStructMarshalStub = NULL; + *pStructMarshalStub = (PCODE)NULL; *pSize = 0; } diff --git a/src/coreclr/vm/memberload.cpp b/src/coreclr/vm/memberload.cpp index 83a062f8f182ab..83d662568d912e 100644 --- a/src/coreclr/vm/memberload.cpp +++ b/src/coreclr/vm/memberload.cpp @@ -153,7 +153,7 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule, BOOL fIsMethod; TADDR pDatum = pModule->LookupMemberRef(MemberRef, &fIsMethod); - if (pDatum != NULL) + if (pDatum != (TADDR)NULL) { if (!fIsMethod) { @@ -190,7 +190,7 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule, if (TypeFromToken(parent) == mdtMethodDef) { // Return now if actualTypeRequired was set and the desc was cached - if (pDatum != NULL) + if (pDatum != (TADDR)NULL) { *ppTH = dac_cast(pDatum)->GetMethodTable(); return; @@ -329,7 +329,7 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule, } // Return now if actualTypeRequired was set and the desc was cached - if (pDatum != NULL) + if (pDatum != (TADDR)NULL) { *ppTH = typeHnd; return; diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 66296c4e06e12c..6f97c67c87895f 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -902,7 +902,7 @@ PCODE MethodDesc::GetNativeCode() } if (!HasStableEntryPoint() || HasPrecode()) - return NULL; + return (PCODE)NULL; return GetStableEntryPoint(); } @@ -913,7 +913,7 @@ PCODE MethodDesc::GetNativeCodeAnyVersion() SUPPORTS_DAC; PCODE pDefaultCode = GetNativeCode(); - if (pDefaultCode != NULL) + if (pDefaultCode != (PCODE)NULL) { return pDefaultCode; } @@ -929,13 +929,13 @@ PCODE MethodDesc::GetNativeCodeAnyVersion() for (NativeCodeVersionIterator curNative = nativeCollection.Begin(), endNative = nativeCollection.End(); curNative != endNative; curNative++) { PCODE native = curNative->GetNativeCode(); - if(native != NULL) + if(native != (PCODE)NULL) { return native; } } } - return NULL; + return (PCODE)NULL; } } @@ -1049,7 +1049,7 @@ COR_ILMETHOD* MethodDesc::GetILHeader() // Always pickup overrides like reflection emit, EnC, etc. TADDR pIL = pModule->GetDynamicIL(GetMemberDef()); - if (pIL == NULL) + if (pIL == (TADDR)NULL) { pIL = pModule->GetIL(GetRVA()); } @@ -1069,7 +1069,7 @@ COR_ILMETHOD* MethodDesc::GetILHeader() #endif #ifdef DACCESS_COMPILE - return (pIL != NULL) ? DacGetIlMethod(pIL) : NULL; + return (pIL != (TADDR)NULL) ? DacGetIlMethod(pIL) : NULL; #else // !DACCESS_COMPILE return PTR_COR_ILMETHOD(pIL); #endif // !DACCESS_COMPILE @@ -1915,7 +1915,7 @@ PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags /* PCODE ret = TryGetMultiCallableAddrOfCode(accessFlags); - if (ret == NULL) + if (ret == (PCODE)NULL) { GCX_COOP(); @@ -2023,7 +2023,7 @@ PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags if (IsVersionableWithVtableSlotBackpatch()) { // Caller has to call via slot or allocate funcptr stub - return NULL; + return (PCODE)NULL; } // Force the creation of the precode if we would eventually got one anyway @@ -2210,7 +2210,7 @@ void MethodDesc::Reset() if (HasNativeCodeSlot()) { - *GetAddrOfNativeCodeSlot() = NULL; + *GetAddrOfNativeCodeSlot() = (PCODE)NULL; } _ASSERTE(!HasNativeCode()); } @@ -3253,7 +3253,7 @@ void MethodDesc::ResetCodeEntryPointForEnC() PCODE pCode = *ppCode; LOG((LF_CORDB, LL_INFO1000000, "MD::RCEPFENC: %p -> %p\n", ppCode, pCode)); - *ppCode = NULL; + *ppCode = (PCODE)NULL; } } diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index f7f98b9f7331fb..b198ea27733a68 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -1368,7 +1368,7 @@ class MethodDesc { LIMITED_METHOD_DAC_CONTRACT; - return GetNativeCode() != NULL; + return GetNativeCode() != (PCODE)0; } // Perf warning: takes the CodeVersionManagerLock on every call @@ -1376,10 +1376,10 @@ class MethodDesc { LIMITED_METHOD_DAC_CONTRACT; - return GetNativeCodeAnyVersion() != NULL; + return GetNativeCodeAnyVersion() != (PCODE)0; } - BOOL SetNativeCodeInterlocked(PCODE addr, PCODE pExpected = NULL); + BOOL SetNativeCodeInterlocked(PCODE addr, PCODE pExpected = 0); PTR_PCODE GetAddrOfNativeCodeSlot(); @@ -2162,7 +2162,7 @@ class MethodDescChunk } CONTRACTL_END; - if (GetTemporaryEntryPoints() == NULL) + if (GetTemporaryEntryPoints() == (TADDR)0) CreateTemporaryEntryPoints(pLoaderAllocator, pamTracker); } @@ -2356,7 +2356,7 @@ class StoredSigMethodDesc : public MethodDesc bool HasStoredMethodSig(void) { LIMITED_METHOD_DAC_CONTRACT; - return m_pSig != NULL; + return m_pSig != 0; } PCCOR_SIGNATURE GetStoredMethodSig(DWORD* sigLen = NULL) { diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index 67903433833b51..27e1a70f9a8330 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -1931,7 +1931,7 @@ MethodDesc *MethodTable::GetMethodDescForInterfaceMethod(TypeHandle ownerType, M PCODE pTgt = VirtualCallStubManager::GetTarget( pInterfaceMT->GetLoaderAllocator()->GetDispatchToken(pInterfaceMT->GetTypeID(), pInterfaceMD->GetSlot()), this, throwOnConflict); - if (pTgt == NULL) + if (pTgt == (PCODE)NULL) { _ASSERTE(!throwOnConflict); return NULL; @@ -4657,7 +4657,7 @@ void MethodTable::DoRunClassInitThrowing() } else { // if the stored exception is a preallocated one we cannot store the new Exception object in it. // we'll attempt to create a new handle for the new TypeInitializationException object - LOADERHANDLE hNewInitException = NULL; + LOADERHANDLE hNewInitException = 0; // CreateHandle can throw due to OOM. We need to catch this so that we make sure to set the // init error. Whatever exception was thrown will be rethrown below, so no worries. EX_TRY { @@ -4667,7 +4667,7 @@ void MethodTable::DoRunClassInitThrowing() } EX_END_CATCH(SwallowAllExceptions); // if two threads are racing to set m_hInitException, clear the handle created by the loser - if (hNewInitException != NULL && + if (hNewInitException != 0 && InterlockedCompareExchangeT((&pEntry->m_hInitException), hNewInitException, hOrigInitException) != hOrigInitException) { pEntry->m_pLoaderAllocator->FreeHandle(hNewInitException); @@ -5161,7 +5161,7 @@ OBJECTREF MethodTable::GetManagedClassObject() GCStress::MaybeTrigger(); #endif // _DEBUG - if (GetAuxiliaryData()->m_hExposedClassObject == NULL) + if (GetAuxiliaryData()->m_hExposedClassObject == 0) { // Make sure that we have been restored CheckRestore(); @@ -6837,7 +6837,7 @@ DispatchSlot MethodTable::FindDispatchSlot(UINT32 typeID, UINT32 slotNumber, BOO } CONTRACTL_END; - DispatchSlot implSlot(NULL); + DispatchSlot implSlot(0); FindDispatchImpl(typeID, slotNumber, &implSlot, throwOnConflict); return implSlot; } @@ -8102,7 +8102,7 @@ DispatchSlot MethodTable::MethodDataInterfaceImpl::GetImplSlot(UINT32 slotNumber WRAPPER_NO_CONTRACT; UINT32 implSlotNumber = MapToImplSlotNumber(slotNumber); if (implSlotNumber == INVALID_SLOT_NUMBER) { - return DispatchSlot(NULL); + return DispatchSlot(0); } return m_pImpl->GetImplSlot(implSlotNumber); } @@ -8664,7 +8664,7 @@ MethodTable::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) EnumMemoryRegionsForExtraInterfaceInfo(); } - if (HasPerInstInfo() != NULL) + if (HasPerInstInfo() != FALSE) { DacEnumMemoryRegion(dac_cast(GetPerInstInfo()) - sizeof(GenericsDictInfo), GetPerInstInfoSize() + sizeof(GenericsDictInfo)); } diff --git a/src/coreclr/vm/methodtable.h b/src/coreclr/vm/methodtable.h index 703508e2126b50..f097785a7cf9dc 100644 --- a/src/coreclr/vm/methodtable.h +++ b/src/coreclr/vm/methodtable.h @@ -2819,7 +2819,7 @@ public : MethodDesc *m_pMD; // The MethodDesc for this slot public: - inline MethodDataEntry() : m_slot(NULL) + inline MethodDataEntry() : m_slot((PCODE)NULL) { WRAPPER_NO_CONTRACT; Init(); } inline void Init() @@ -2827,7 +2827,7 @@ public : LIMITED_METHOD_CONTRACT; m_chainDeltaAndTableIndex = INVALID_CHAIN_AND_INDEX; m_implSlotNum = INVALID_IMPL_SLOT_NUM; - m_slot = NULL; + m_slot = (PCODE)NULL; m_pMD = NULL; } diff --git a/src/coreclr/vm/methodtablebuilder.h b/src/coreclr/vm/methodtablebuilder.h index 121e1508972241..507e163d29f76b 100644 --- a/src/coreclr/vm/methodtablebuilder.h +++ b/src/coreclr/vm/methodtablebuilder.h @@ -38,7 +38,7 @@ class MethodTableBuilder BOOL fSharedByGenericInstantiations; // TRUE if this is canonical type shared by instantiations BOOL fContainsGenericVariables; // TRUE if this is an open type - inline bmtGenericsInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtGenericsInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } inline DWORD GetNumGenericArgs() const { LIMITED_METHOD_CONTRACT; return typeContext.m_classInst.GetNumArgs(); } inline BOOL HasInstantiation() const { LIMITED_METHOD_CONTRACT; return typeContext.m_classInst.GetNumArgs() != 0; } inline BOOL IsTypicalTypeDefinition() const { LIMITED_METHOD_CONTRACT; return !HasInstantiation() || fTypicalInstantiation; } @@ -1300,7 +1300,7 @@ class MethodTableBuilder DWORD dwNonGCRegularStaticFieldBytes; DWORD dwNonGCThreadStaticFieldBytes; - inline bmtProperties() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtProperties() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtProperties // -------------------------------------------------------------------------------------------- @@ -1552,7 +1552,7 @@ class MethodTableBuilder DWORD NumParentPointerSeries; MethodNameHash *pParentMethodHash; - inline bmtParentInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtParentInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtParentInfo // -------------------------------------------------------------------------------------------- @@ -1834,7 +1834,7 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- // Constructor - inline bmtInterfaceInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtInterfaceInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtInterfaceInfo // -------------------------------------------------------------------------------------------- @@ -1863,7 +1863,7 @@ class MethodTableBuilder inline bmtEnumFieldInfo(IMDInternalImport *pInternalImport) { LIMITED_METHOD_CONTRACT; - memset((void *)this, NULL, sizeof(*this)); + memset((void *)this, 0, sizeof(*this)); m_pInternalImport = pInternalImport; } }; // struct bmtEnumFieldInfo @@ -1886,7 +1886,7 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- // Constructor inline bmtMethodInfo() - { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } //----------------------------------------------------------------------------------------- // Add a declared method to the array @@ -1966,7 +1966,7 @@ class MethodTableBuilder bool fHasCovariantOverride; //----------------------------------------------------------------------------------------- - inline bmtMetaDataInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtMetaDataInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtMetaDataInfo // -------------------------------------------------------------------------------------------- @@ -1979,7 +1979,7 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- - inline bmtMethAndFieldDescs() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtMethAndFieldDescs() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtMethAndFieldDescs // -------------------------------------------------------------------------------------------- @@ -2038,7 +2038,7 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- // Constructor - inline bmtInternalInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtInternalInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtInternalInfo @@ -2141,7 +2141,7 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- // Constructor inline bmtMethodImplInfo() - { LIMITED_METHOD_CONTRACT; memset((void*) this, NULL, sizeof(*this)); } + { LIMITED_METHOD_CONTRACT; memset((void*) this, 0, sizeof(*this)); } //----------------------------------------------------------------------------------------- // Returns TRUE if tok acts as a body for any methodImpl entry. FALSE, otherwise. @@ -2399,7 +2399,7 @@ class MethodTableBuilder Substitution * pInterfaceSubstitution; SigTypeContext typeContext; // Exact type context used to supply final instantiation to substitution chains - inline bmtExactInterfaceInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtExactInterfaceInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtExactInterfaceInfo private: @@ -2449,7 +2449,7 @@ class MethodTableBuilder Substitution **ppInterfaceSubstitutionChains; SigTypeContext typeContext; - inline bmtInterfaceAmbiguityCheckInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, NULL, sizeof(*this)); } + inline bmtInterfaceAmbiguityCheckInfo() { LIMITED_METHOD_CONTRACT; memset((void *)this, 0, sizeof(*this)); } }; // struct bmtInterfaceAmbiguityCheckInfo static void diff --git a/src/coreclr/vm/multicorejit.h b/src/coreclr/vm/multicorejit.h index 7a61c22fd8b458..48596470921aa2 100644 --- a/src/coreclr/vm/multicorejit.h +++ b/src/coreclr/vm/multicorejit.h @@ -92,7 +92,7 @@ class MulticoreJitCodeInfo TADDR m_entryPointAndTierInfo; public: - MulticoreJitCodeInfo() : m_entryPointAndTierInfo(NULL) + MulticoreJitCodeInfo() : m_entryPointAndTierInfo(0) { LIMITED_METHOD_CONTRACT; } @@ -109,13 +109,13 @@ class MulticoreJitCodeInfo bool IsNull() const { LIMITED_METHOD_CONTRACT; - return m_entryPointAndTierInfo == NULL; + return m_entryPointAndTierInfo == 0; } PCODE GetEntryPoint() const { WRAPPER_NO_CONTRACT; - return IsNull() ? NULL : PINSTRToPCODE(m_entryPointAndTierInfo & ~(TADDR)TierInfo::Mask); + return IsNull() ? (PCODE)0 : PINSTRToPCODE(m_entryPointAndTierInfo & ~(TADDR)TierInfo::Mask); } bool WasTier0() const diff --git a/src/coreclr/vm/multicorejitplayer.cpp b/src/coreclr/vm/multicorejitplayer.cpp index 2b8a0a1ba80992..49f7c4a0527ac1 100644 --- a/src/coreclr/vm/multicorejitplayer.cpp +++ b/src/coreclr/vm/multicorejitplayer.cpp @@ -966,7 +966,7 @@ void MulticoreJitProfilePlayer::CompileMethodInfoRecord(Module *pModule, MethodD } } - if (pMethod->GetNativeCode() == NULL && !GetAppDomain()->GetMulticoreJitManager().GetMulticoreJitCodeStorage().LookupMethodCode(pMethod)) + if (pMethod->GetNativeCode() == (PCODE)NULL && !GetAppDomain()->GetMulticoreJitManager().GetMulticoreJitCodeStorage().LookupMethodCode(pMethod)) { if (CompileMethodDesc(pModule, pMethod)) { diff --git a/src/coreclr/vm/nativelibrary.cpp b/src/coreclr/vm/nativelibrary.cpp index c4460d91a5c01d..7acdce8b37df93 100644 --- a/src/coreclr/vm/nativelibrary.cpp +++ b/src/coreclr/vm/nativelibrary.cpp @@ -295,11 +295,11 @@ INT_PTR NativeLibrary::GetNativeLibraryExport(NATIVE_LIBRARY_HANDLE handle, LPCW #ifndef TARGET_UNIX INT_PTR address = reinterpret_cast(GetProcAddress((HMODULE)handle, lpstr)); - if ((address == NULL) && throwOnError) + if ((address == 0) && throwOnError) COMPlusThrow(kEntryPointNotFoundException, IDS_EE_NDIRECT_GETPROCADDR_WIN_DLL, symbolName); #else // !TARGET_UNIX INT_PTR address = reinterpret_cast(PAL_GetProcAddressDirect(handle, lpstr)); - if ((address == NULL) && throwOnError) + if ((address == 0) && throwOnError) COMPlusThrow(kEntryPointNotFoundException, IDS_EE_NDIRECT_GETPROCADDR_UNIX_SO, symbolName); #endif // !TARGET_UNIX @@ -386,7 +386,7 @@ namespace STANDARD_VM_CONTRACT; INT_PTR ptrManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(pAssembly); - if (ptrManagedAssemblyLoadContext == NULL) + if (ptrManagedAssemblyLoadContext == 0) { return NULL; } diff --git a/src/coreclr/vm/nativelibrarynative.cpp b/src/coreclr/vm/nativelibrarynative.cpp index c4594521cf09f3..1aeff462f4b357 100644 --- a/src/coreclr/vm/nativelibrarynative.cpp +++ b/src/coreclr/vm/nativelibrarynative.cpp @@ -60,7 +60,7 @@ extern "C" INT_PTR QCALLTYPE NativeLibrary_GetSymbol(INT_PTR handle, LPCWSTR sym { QCALL_CONTRACT; - INT_PTR address = NULL; + INT_PTR address = 0; BEGIN_QCALL; diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index c0774cae0d81fe..8e4d11cebdf525 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -1853,7 +1853,7 @@ class DelegateObject : public Object friend class CoreLibBinder; public: - BOOL IsWrapperDelegate() { LIMITED_METHOD_CONTRACT; return _methodPtrAux == NULL; } + BOOL IsWrapperDelegate() { LIMITED_METHOD_CONTRACT; return _methodPtrAux == 0; } OBJECTREF GetTarget() { LIMITED_METHOD_CONTRACT; return _target; } void SetTarget(OBJECTREF target) { WRAPPER_NO_CONTRACT; SetObjectReference(&_target, target); } @@ -2324,7 +2324,7 @@ class ExceptionObject : public Object { LIMITED_METHOD_CONTRACT; - return (_ipForWatsonBuckets != NULL); + return (_ipForWatsonBuckets != 0); } // This method returns the IP for Watson Buckets. @@ -2455,7 +2455,7 @@ class Nullable { static BOOL UnBox(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static BOOL UnBoxNoGC(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static void UnBoxNoCheck(void* dest, OBJECTREF boxedVal, MethodTable* destMT); - static OBJECTREF BoxedNullableNull(TypeHandle nullableType) { return 0; } + static OBJECTREF BoxedNullableNull(TypeHandle nullableType) { return nullptr; } // if 'Obj' is a true boxed nullable, return the form we want (either null or a boxed T) static OBJECTREF NormalizeBox(OBJECTREF obj); diff --git a/src/coreclr/vm/olevariant.cpp b/src/coreclr/vm/olevariant.cpp index 888ebdd380dae8..b477333b06ff2c 100644 --- a/src/coreclr/vm/olevariant.cpp +++ b/src/coreclr/vm/olevariant.cpp @@ -1175,11 +1175,11 @@ void SafeVariantClear(VARIANT* pVar) } } -class VariantEmptyHolder : public Wrapper, SafeVariantClear, NULL> +class VariantEmptyHolder : public Wrapper, SafeVariantClear, 0> { public: VariantEmptyHolder(VARIANT* p = NULL) : - Wrapper, SafeVariantClear, NULL>(p) + Wrapper, SafeVariantClear, 0>(p) { WRAPPER_NO_CONTRACT; } @@ -1188,7 +1188,7 @@ class VariantEmptyHolder : public Wrapper, SafeV { WRAPPER_NO_CONTRACT; - Wrapper, SafeVariantClear, NULL>::operator=(p); + Wrapper, SafeVariantClear, 0>::operator=(p); } }; @@ -1205,11 +1205,11 @@ FORCEINLINE void RecordVariantRelease(VARIANT* value) } } -class RecordVariantHolder : public Wrapper, RecordVariantRelease, NULL> +class RecordVariantHolder : public Wrapper, RecordVariantRelease, 0> { public: RecordVariantHolder(VARIANT* p = NULL) - : Wrapper, RecordVariantRelease, NULL>(p) + : Wrapper, RecordVariantRelease, 0>(p) { WRAPPER_NO_CONTRACT; } @@ -1217,7 +1217,7 @@ class RecordVariantHolder : public Wrapper, Reco FORCEINLINE void operator=(VARIANT* p) { WRAPPER_NO_CONTRACT; - Wrapper, RecordVariantRelease, NULL>::operator=(p); + Wrapper, RecordVariantRelease, 0>::operator=(p); } }; #endif // FEATURE_COMINTEROP diff --git a/src/coreclr/vm/peassembly.inl b/src/coreclr/vm/peassembly.inl index 3a805bea6300e3..23af8bd7a0940f 100644 --- a/src/coreclr/vm/peassembly.inl +++ b/src/coreclr/vm/peassembly.inl @@ -775,7 +775,7 @@ inline BOOL PEAssembly::IsStrongNamed() DWORD flags = 0; IfFailThrow(GetMDImport()->GetAssemblyProps(TokenFromRid(1, mdtAssembly), NULL, NULL, NULL, NULL, NULL, &flags)); - return (flags & afPublicKey) != NULL; + return (flags & afPublicKey) != 0; } diff --git a/src/coreclr/vm/peimagelayout.cpp b/src/coreclr/vm/peimagelayout.cpp index 3feaf538dbf878..500f97ff7a4d55 100644 --- a/src/coreclr/vm/peimagelayout.cpp +++ b/src/coreclr/vm/peimagelayout.cpp @@ -416,7 +416,7 @@ void ConvertedImageLayout::FreeImageParts() CLRUnmapViewOfFile(PtrFromPart(imagePart)); } - this->m_imageParts[i] = NULL; + this->m_imageParts[i] = 0; } } diff --git a/src/coreclr/vm/peimagelayout.inl b/src/coreclr/vm/peimagelayout.inl index 038b17be1eb271..21bb137449cb5a 100644 --- a/src/coreclr/vm/peimagelayout.inl +++ b/src/coreclr/vm/peimagelayout.inl @@ -80,7 +80,7 @@ inline BOOL PEImageLayout::CompareBase(UPTR base, UPTR mapping) MODE_ANY; } CONTRACTL_END; - if (base==NULL) //we were searching for 'Any' + if (base==0) //we were searching for 'Any' return TRUE; return ((PEImageLayout*)mapping)->GetBase()==((PEImageLayout*)(base<<1))->GetBase(); diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index d032dc6031dcee..9e553a975da0a7 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -127,7 +127,7 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) { // Call GetMethodDesc_NoRestore instead of GetMethodDesc to avoid restoring methods. MethodDesc *hotDesc = (MethodDesc *)mi.GetMethodDesc_NoRestore(); - if (hotDesc != nullptr && hotDesc->GetNativeCode() != NULL) + if (hotDesc != nullptr && hotDesc->GetNativeCode() != (PCODE)NULL) { PerfMap::LogPreCompiledMethod(hotDesc, hotDesc->GetNativeCode()); } diff --git a/src/coreclr/vm/precode.cpp b/src/coreclr/vm/precode.cpp index 3edc093add6b34..1a8c14eadfc63f 100644 --- a/src/coreclr/vm/precode.cpp +++ b/src/coreclr/vm/precode.cpp @@ -74,7 +74,7 @@ PCODE Precode::GetTarget() LIMITED_METHOD_CONTRACT; SUPPORTS_DAC; - PCODE target = NULL; + PCODE target = 0; PrecodeType precodeType = GetType(); switch (precodeType) @@ -108,7 +108,7 @@ MethodDesc* Precode::GetMethodDesc(BOOL fSpeculative /*= FALSE*/) SUPPORTS_DAC; } CONTRACTL_END; - TADDR pMD = NULL; + TADDR pMD = (TADDR)NULL; PrecodeType precodeType = GetType(); switch (precodeType) @@ -136,7 +136,7 @@ MethodDesc* Precode::GetMethodDesc(BOOL fSpeculative /*= FALSE*/) break; } - if (pMD == NULL) + if (pMD == (TADDR)NULL) { if (fSpeculative) return NULL; @@ -196,9 +196,7 @@ PCODE Precode::TryToSkipFixupPrecode(PCODE addr) GC_NOTRIGGER; } CONTRACTL_END; - PCODE pTarget = NULL; - - return pTarget; + return 0; } Precode* Precode::GetPrecodeForTemporaryEntryPoint(TADDR temporaryEntryPoints, int index) @@ -570,7 +568,7 @@ void StubPrecode::Init(StubPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator { // Use pMD == NULL in all precode initialization methods to allocate the initial jump stub in non-dynamic heap // that has the same lifetime like as the precode itself - if (target == NULL) + if (target == (TADDR)NULL) target = GetPreStubEntryPoint(); pStubData->Target = target; } diff --git a/src/coreclr/vm/precode.h b/src/coreclr/vm/precode.h index 3f6a2f532c4e67..fac2433c7428a8 100644 --- a/src/coreclr/vm/precode.h +++ b/src/coreclr/vm/precode.h @@ -117,7 +117,7 @@ struct StubPrecode static void (*StubPrecodeCode_End)(); #endif - void Init(StubPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator = NULL, BYTE type = StubPrecode::Type, TADDR target = NULL); + void Init(StubPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator = NULL, BYTE type = StubPrecode::Type, TADDR target = 0); static void StaticInitialize(); diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index 64638b96cddfbf..685bfba70f5013 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -344,7 +344,7 @@ bool MayUsePrecompiledILStub() PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig) { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; bool shouldTier = false; #if defined(FEATURE_TIERED_COMPILATION) @@ -398,7 +398,7 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig) if (pTargetMD != NULL) { pCode = pTargetMD->GetPrecompiledR2RCode(pConfig); - if (pCode != NULL) + if (pCode != (PCODE)NULL) { LOG_USING_R2R_CODE(this); pConfig->SetNativeCode(pCode, &pCode); @@ -409,24 +409,24 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig) } #endif // FEATURE_READYTORUN - if (pCode == NULL) + if (pCode == (PCODE)NULL) { pCode = GetPrecompiledCode(pConfig, shouldTier); } #ifdef FEATURE_PERFMAP - if (pCode != NULL) + if (pCode != (PCODE)NULL) PerfMap::LogPreCompiledMethod(this, pCode); #endif } - if (pConfig->IsForMulticoreJit() && pCode == NULL && pConfig->ReadyToRunRejectedPrecompiledCode()) + if (pConfig->IsForMulticoreJit() && pCode == (PCODE)NULL && pConfig->ReadyToRunRejectedPrecompiledCode()) { // Was unable to load code from r2r image in mcj thread, don't try to jit it, this method will be loaded later - return NULL; + return (PCODE)NULL; } - if (pCode == NULL) + if (pCode == (PCODE)NULL) { LOG((LF_CLASSLOADER, LL_INFO1000000, " In PrepareILBasedCode, calling JitCompileCode\n")); @@ -443,11 +443,11 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig) PCODE MethodDesc::GetPrecompiledCode(PrepareCodeConfig* pConfig, bool shouldTier) { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; #ifdef FEATURE_READYTORUN pCode = GetPrecompiledR2RCode(pConfig); - if (pCode != NULL) + if (pCode != (PCODE)NULL) { LOG_USING_R2R_CODE(this); @@ -499,7 +499,7 @@ PCODE MethodDesc::GetPrecompiledR2RCode(PrepareCodeConfig* pConfig) { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; #ifdef FEATURE_READYTORUN ReadyToRunInfo* pAlreadyExaminedInfos[2] = {NULL, NULL}; Module * pModule = GetModule(); @@ -510,7 +510,7 @@ PCODE MethodDesc::GetPrecompiledR2RCode(PrepareCodeConfig* pConfig) } // Generics may be located in several places - if (pCode == NULL && HasClassOrMethodInstantiation()) + if (pCode == (PCODE)NULL && HasClassOrMethodInstantiation()) { // Generics have an alternative location that is looked up which is based on the first generic // argument that the crossgen2 compiler will consider as requiring the cross module compilation logic to kick in. @@ -521,13 +521,13 @@ PCODE MethodDesc::GetPrecompiledR2RCode(PrepareCodeConfig* pConfig) pCode = pAlreadyExaminedInfos[1]->GetEntryPoint(this, pConfig, TRUE /* fFixups */); } - if (pCode == NULL) + if (pCode == (PCODE)NULL) { // R2R also supports a concept of R2R code that has code for "Unrelated" generics embedded within it // A linked list of these are formed as those modules are loaded, and this restricted set of modules // is examined for all generic method lookups ReadyToRunInfo* pUnrelatedInfo = ReadyToRunInfo::GetUnrelatedR2RModules(); - for (;pUnrelatedInfo != NULL && pCode == NULL; pUnrelatedInfo = pUnrelatedInfo->GetNextUnrelatedR2RModule()) + for (;pUnrelatedInfo != NULL && pCode == (PCODE)NULL; pUnrelatedInfo = pUnrelatedInfo->GetNextUnrelatedR2RModule()) { if (pUnrelatedInfo == pAlreadyExaminedInfos[0]) continue; if (pUnrelatedInfo == pAlreadyExaminedInfos[1]) continue; @@ -604,7 +604,7 @@ PCODE MethodDesc::JitCompileCode(PrepareCodeConfig* pConfig) CheckStacksAndPitch(); #endif - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; { // Enter the global lock which protects the list of all functions being JITd JitListLock::LockHolder pJitLock(AppDomain::GetCurrentDomain()->GetJitLock()); @@ -680,7 +680,7 @@ PCODE MethodDesc::JitCompileCode(PrepareCodeConfig* pConfig) { bool wasTier0 = false; pCode = GetMulticoreJitCode(pConfig, &wasTier0); - if (pCode != NULL) + if (pCode != (PCODE)NULL) { #ifdef FEATURE_TIERED_COMPILATION // Finalize the optimization tier before SetNativeCode() is called @@ -760,7 +760,7 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; ULONG sizeOfCode = 0; #ifdef PROFILING_SUPPORTED @@ -928,9 +928,9 @@ PCODE MethodDesc::JitCompileCodeLocked(PrepareCodeConfig* pConfig, COR_ILMETHOD_ { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; CORJIT_FLAGS jitFlags; - PCODE pOtherCode = NULL; + PCODE pOtherCode = (PCODE)NULL; EX_TRY { @@ -961,7 +961,7 @@ PCODE MethodDesc::JitCompileCodeLocked(PrepareCodeConfig* pConfig, COR_ILMETHOD_ } EX_END_CATCH(RethrowTerminalExceptions) - if (pOtherCode != NULL) + if (pOtherCode != (PCODE)NULL) { // Somebody finished jitting recursively while we were jitting the method. // Just use their method & leak the one we finished. (Normally we hope @@ -1087,7 +1087,7 @@ namespace CaNamedArg namedArgs[1]; CaType namedArgTypes[1]; namedArgTypes[0].Init(SERIALIZATION_TYPE_STRING); - namedArgs[0].Init("Name", SERIALIZATION_TYPE_PROPERTY, namedArgTypes[0], NULL); + namedArgs[0].Init("Name", SERIALIZATION_TYPE_PROPERTY, namedArgTypes[0]); if (FAILED(::ParseKnownCaNamedArgs(ca, namedArgs, ARRAY_SIZE(namedArgs)))) return false; @@ -1862,7 +1862,7 @@ BOOL PrepareCodeConfig::SetNativeCode(PCODE pCode, PCODE * ppAlternateCodeToUse) { LIMITED_METHOD_CONTRACT; - if (m_nativeCodeVersion.SetNativeCodeInterlocked(pCode, NULL)) + if (m_nativeCodeVersion.SetNativeCodeInterlocked(pCode, (PCODE)NULL)) { return TRUE; } @@ -2519,7 +2519,7 @@ static PCODE PreStubWorker_Preemptive( { _ASSERTE(pMD->HasUnmanagedCallersOnlyAttribute()); - PCODE pbRetVal = NULL; + PCODE pbRetVal = (PCODE)NULL; STATIC_CONTRACT_THROWS; STATIC_CONTRACT_GC_TRIGGERS; @@ -2571,7 +2571,7 @@ static PCODE PreStubWorker_Preemptive( //============================================================================= extern "C" PCODE STDCALL PreStubWorker(TransitionBlock* pTransitionBlock, MethodDesc* pMD) { - PCODE pbRetVal = NULL; + PCODE pbRetVal = (PCODE)NULL; BEGIN_PRESERVE_LAST_ERROR; @@ -2731,7 +2731,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo CONTRACT_END; Stub *pStub = NULL; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; Thread *pThread = GetThread(); @@ -2874,13 +2874,13 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo // a stub, we'll use it directly instead and avoid emitting an IL stub. PrepareCodeConfig config(NativeCodeVersion(this), TRUE, TRUE); pCode = GetPrecompiledR2RCode(&config); - if (pCode != NULL) + if (pCode != (PCODE)NULL) { LOG_USING_R2R_CODE(this); } } - if (pCode == NULL) + if (pCode == (PCODE)NULL) { pCode = GetStubForInteropMethod(this); } @@ -2935,7 +2935,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo MemoryBarrier(); #endif - if (pCode != NULL) + if (pCode != (PCODE)NULL) { _ASSERTE(!MayHaveEntryPointSlotsToBackpatch()); // This path doesn't lock the MethodDescBackpatchTracker as it should only // happen for jump-stampable or non-versionable methods @@ -3036,7 +3036,7 @@ static PCODE PatchNonVirtualExternalMethod(MethodDesc * pMD, PCODE pCode, PTR_RE && pMD->IsNativeCodeStableAfterInit()) { PCODE pDirectTarget = pMD->IsFCall() ? ECall::GetFCallImpl(pMD) : pMD->GetNativeCode(); - if (pDirectTarget != NULL) + if (pDirectTarget != (PCODE)NULL) pCode = pDirectTarget; } #endif //HAS_FIXUP_PRECODE @@ -3080,7 +3080,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl // the value of the Last Error before it could be retrieved and saved. // - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; BEGIN_PRESERVE_LAST_ERROR; @@ -3095,7 +3095,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl #if defined(TARGET_X86) || defined(TARGET_AMD64) // Decode indirection cell from callsite if it is not present - if (pIndirection == NULL) + if (pIndirection == (PCODE)NULL) { // Assume that the callsite is call [xxxxxxxx] PCODE retAddr = pEMFrame->GetReturnAddress(); @@ -3369,7 +3369,7 @@ static PCODE getHelperForInitializedStatic(Module * pModule, CORCOMPILE_FIXUP_BL { STANDARD_VM_CONTRACT; - PCODE pHelper = NULL; + PCODE pHelper = (PCODE)NULL; switch (kind) { @@ -3780,7 +3780,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR ThrowHR(COR_E_BADIMAGEFORMAT); } - PCODE pHelper = NULL; + PCODE pHelper = (PCODE)NULL; if (fReliable) { @@ -3883,7 +3883,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR UNREACHABLE(); } - if (pHelper != NULL) + if (pHelper != (PCODE)NULL) { *(TADDR *)pCell = pHelper; } @@ -3926,7 +3926,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR TADDR pArgument = GetFirstArgumentRegisterValuePtr(pTransitionBlock); - if (pArgument != NULL) + if (pArgument != (TADDR)NULL) { pDelegateType = (*(Object **)pArgument)->GetMethodTable(); _ASSERTE(pDelegateType->IsDelegate()); @@ -3953,7 +3953,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR } } - TADDR target = NULL; + TADDR target = (TADDR)NULL; if (pDelegateCtor != NULL) { @@ -3988,7 +3988,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR UNREACHABLE(); } - if (pHelper != NULL) + if (pHelper != (PCODE)NULL) { *(TADDR *)pCell = pHelper; } @@ -4004,8 +4004,8 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock, TADDR * pCell, DWORD sectionIndex, Module * pModule, INT frameFlags) { - PCODE pHelper = NULL; - SIZE_T result = NULL; + PCODE pHelper = (PCODE)NULL; + SIZE_T result = 0; STATIC_CONTRACT_THROWS; STATIC_CONTRACT_GC_TRIGGERS; @@ -4051,7 +4051,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock pHelper = DynamicHelperFixup(pTransitionBlock, pCell, sectionIndex, pModule, &kind, &th, &pMD, &pFD); } - if (pHelper == NULL) + if (pHelper == (PCODE)NULL) { TADDR pArgument = GetFirstArgumentRegisterValuePtr(pTransitionBlock); @@ -4068,7 +4068,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock else { _ASSERTE (!throwInvalidCast); - result = NULL; + result = 0; } } break; @@ -4126,7 +4126,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock pFrame->Pop(CURRENT_THREAD); - if (pHelper == NULL) + if (pHelper == (PCODE)NULL) *(SIZE_T *)((TADDR)pTransitionBlock + TransitionBlock::GetOffsetOfArgumentRegisters()) = result; return pHelper; } diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index e57cba3c597d7c..5a74df632305c3 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -341,7 +341,7 @@ static ClassID NonGenericTypeHandleToClassID(TypeHandle th) if ((!th.IsNull()) && (th.HasInstantiation())) { - return NULL; + return 0; } return TypeHandleToClassID(th); @@ -1067,7 +1067,7 @@ ClassID SafeGetClassIDFromObject(Object * pObj) TypeHandle th = pObj->GetGCSafeTypeHandleIfPossible(); if(th == NULL) { - return NULL; + return 0; } return TypeHandleToClassID(th); @@ -1635,7 +1635,7 @@ HRESULT ProfToEEInterfaceImpl::GetObjectSize(ObjectID objectId, ULONG *pcSize) "**PROF: GetObjectSize 0x%p.\n", objectId)); - if (objectId == NULL) + if (objectId == 0) { return E_INVALIDARG; } @@ -1699,7 +1699,7 @@ HRESULT ProfToEEInterfaceImpl::GetObjectSize2(ObjectID objectId, SIZE_T *pcSize) "**PROF: GetObjectSize2 0x%p.\n", objectId)); - if (objectId == NULL) + if (objectId == 0) { return E_INVALIDARG; } @@ -1763,7 +1763,7 @@ HRESULT ProfToEEInterfaceImpl::IsArrayClass( HRESULT hr; - if (classId == NULL) + if (classId == 0) { return E_INVALIDARG; } @@ -1801,7 +1801,7 @@ HRESULT ProfToEEInterfaceImpl::IsArrayClass( { if (pBaseClassId != NULL) { - *pBaseClassId = NULL; + *pBaseClassId = 0; } // This is not an array, S_FALSE indicates so. @@ -2130,7 +2130,7 @@ HRESULT ProfToEEInterfaceImpl::GetTokenAndMetaDataFromFunction( "**PROF: GetTokenAndMetaDataFromFunction 0x%p.\n", functionId)); - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -2259,7 +2259,7 @@ HRESULT GetCodeInfoFromCodeStart( HRESULT hr; - if (start == NULL) + if (start == (PCODE)NULL) { return CORPROF_E_FUNCTION_NOT_COMPILED; } @@ -2310,7 +2310,7 @@ HRESULT GetCodeInfoFromCodeStart( codeInfos[0].size = methodRegionInfo.coldSize; } - if (NULL != methodRegionInfo.coldStartAddress) + if ((PCODE)NULL != methodRegionInfo.coldStartAddress) { if (cCodeInfos > 1) { @@ -2333,7 +2333,7 @@ HRESULT GetCodeInfoFromCodeStart( if (NULL != pcCodeInfos) { - *pcCodeInfos = (NULL != methodRegionInfo.coldStartAddress) ? 2 : 1; + *pcCodeInfos = ((PCODE)NULL != methodRegionInfo.coldStartAddress) ? 2 : 1; } @@ -2534,7 +2534,7 @@ HRESULT ProfToEEInterfaceImpl::GetCodeInfo3(FunctionID functionId, hr = ValidateParametersForGetCodeInfo(pMethodDesc, cCodeInfos, codeInfos); if (SUCCEEDED(hr)) { - PCODE pCodeStart = NULL; + PCODE pCodeStart = (PCODE)NULL; CodeVersionManager* pCodeVersionManager = pMethodDesc->GetCodeVersionManager(); { CodeVersionManager::LockHolder codeVersioningLockHolder; @@ -2755,7 +2755,7 @@ HRESULT ProfToEEInterfaceImpl::GetArrayObjectInfo(ObjectID objectId, "**PROF: GetArrayObjectInfo 0x%p.\n", objectId)); - if (objectId == NULL) + if (objectId == 0) { return E_INVALIDARG; } @@ -2886,7 +2886,7 @@ HRESULT ProfToEEInterfaceImpl::GetBoxClassLayout(ClassID classId, return E_INVALIDARG; } - if (classId == NULL) + if (classId == 0) { return E_INVALIDARG; } @@ -2949,7 +2949,7 @@ HRESULT ProfToEEInterfaceImpl::GetThreadAppDomain(ThreadID threadId, Thread *pThread; - if (threadId == NULL) + if (threadId == 0) { pThread = GetThreadNULLOk(); } @@ -3021,7 +3021,7 @@ HRESULT ProfToEEInterfaceImpl::GetRVAStaticAddress(ClassID classId, // // Check for NULL parameters // - if ((classId == NULL) || (ppAddress == NULL)) + if ((classId == 0) || (ppAddress == NULL)) { return E_INVALIDARG; } @@ -3139,7 +3139,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainStaticAddress(ClassID classId, // // Check for NULL parameters // - if ((classId == NULL) || (appDomainId == NULL) || (ppAddress == NULL)) + if ((classId == 0) || (appDomainId == 0) || (ppAddress == NULL)) { return E_INVALIDARG; } @@ -3285,7 +3285,7 @@ HRESULT ProfToEEInterfaceImpl::GetThreadStaticAddress(ClassID classId, // // Verify the value of threadId, which must be the current thread ID or NULL, which means using curernt thread ID. // - if ((threadId != NULL) && (threadId != ((ThreadID)GetThreadNULLOk()))) + if ((threadId != 0) && (threadId != ((ThreadID)GetThreadNULLOk()))) { return E_INVALIDARG; } @@ -3296,7 +3296,7 @@ HRESULT ProfToEEInterfaceImpl::GetThreadStaticAddress(ClassID classId, // // Check for NULL parameters // - if ((classId == NULL) || (ppAddress == NULL) || !IsManagedThread(threadId) || (appDomainId == NULL)) + if ((classId == 0) || (ppAddress == NULL) || !IsManagedThread(threadId) || (appDomainId == 0)) { return E_INVALIDARG; } @@ -3360,7 +3360,7 @@ HRESULT ProfToEEInterfaceImpl::GetThreadStaticAddress2(ClassID classId, threadId)); - if (threadId == NULL) + if (threadId == 0) { if (GetThreadNULLOk() == NULL) { @@ -3373,7 +3373,7 @@ HRESULT ProfToEEInterfaceImpl::GetThreadStaticAddress2(ClassID classId, // // Check for NULL parameters // - if ((classId == NULL) || (ppAddress == NULL) || !IsManagedThread(threadId) || (appDomainId == NULL)) + if ((classId == 0) || (ppAddress == NULL) || !IsManagedThread(threadId) || (appDomainId == 0)) { return E_INVALIDARG; } @@ -3539,7 +3539,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainsContainingModule(ModuleID moduleId, // // Check for NULL parameters // - if ((moduleId == NULL) || ((appDomainIds == NULL) && (cAppDomainIds != 0)) || (pcAppDomainIds == NULL)) + if ((moduleId == 0) || ((appDomainIds == NULL) && (cAppDomainIds != 0)) || (pcAppDomainIds == NULL)) { return E_INVALIDARG; } @@ -3614,7 +3614,7 @@ HRESULT ProfToEEInterfaceImpl::GetStaticFieldInfo(ClassID classId, // // Check for NULL parameters // - if ((classId == NULL) || (pFieldInfo == NULL)) + if ((classId == 0) || (pFieldInfo == NULL)) { return E_INVALIDARG; } @@ -3717,7 +3717,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassIDInfo2(ClassID classId, // // Verify parameters. // - if (classId == NULL) + if (classId == 0) { return E_INVALIDARG; } @@ -3736,7 +3736,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassIDInfo2(ClassID classId, { if (pParentClassId != NULL) { - *pParentClassId = NULL; + *pParentClassId = 0; } if (pModuleId != NULL) @@ -3779,7 +3779,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassIDInfo2(ClassID classId, } else { - *pParentClassId = NULL; + *pParentClassId = 0; } } @@ -3996,7 +3996,7 @@ HRESULT ProfToEEInterfaceImpl::GetModuleInfo2(ModuleID moduleId, "**PROF: GetModuleInfo2 0x%p.\n", moduleId)); - if (moduleId == NULL) + if (moduleId == 0) { return E_INVALIDARG; } @@ -4149,7 +4149,7 @@ HRESULT ProfToEEInterfaceImpl::GetModuleMetaData(ModuleID moduleId, moduleId, dwOpenFlags)); - if (moduleId == NULL) + if (moduleId == 0) { return E_INVALIDARG; } @@ -4236,7 +4236,7 @@ HRESULT ProfToEEInterfaceImpl::GetILFunctionBody(ModuleID moduleId, ULONG RVA; // Return RVA of the method body. DWORD dwImplFlags; // Flags for the item. - if ((moduleId == NULL) || + if ((moduleId == 0) || (methodId == mdMethodDefNil) || (methodId == 0) || (TypeFromToken(methodId) != mdtMethodDef)) @@ -4359,7 +4359,7 @@ HRESULT ProfToEEInterfaceImpl::GetILFunctionBodyAllocator(ModuleID modul "**PROF: GetILFunctionBodyAllocator 0x%p.\n", moduleId)); - if ((moduleId == NULL) || (ppMalloc == NULL)) + if ((moduleId == 0) || (ppMalloc == NULL)) { return E_INVALIDARG; } @@ -4414,7 +4414,7 @@ HRESULT ProfToEEInterfaceImpl::SetILFunctionBody(ModuleID moduleId, moduleId, methodId)); - if ((moduleId == NULL) || + if ((moduleId == 0) || (methodId == mdMethodDefNil) || (TypeFromToken(methodId) != mdtMethodDef) || (pbNewILMethodHeader == NULL)) @@ -4489,7 +4489,7 @@ HRESULT ProfToEEInterfaceImpl::SetILInstrumentedCodeMap(FunctionID functionId, functionId, fStartJit)); - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -4698,19 +4698,19 @@ HRESULT ProfToEEInterfaceImpl::GetClassIDInfo(ClassID classId, "**PROF: GetClassIDInfo 0x%p.\n", classId)); - if (classId == NULL) + if (classId == 0) { return E_INVALIDARG; } if (pModuleId != NULL) { - *pModuleId = NULL; + *pModuleId = 0; } if (pTypeDefToken != NULL) { - *pTypeDefToken = NULL; + *pTypeDefToken = 0; } // Handle globals which don't have the instances. @@ -4726,7 +4726,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassIDInfo(ClassID classId, *pTypeDefToken = mdTokenNil; } } - else if (classId == NULL) + else if (classId == 0) { return E_INVALIDARG; } @@ -4786,7 +4786,7 @@ HRESULT ProfToEEInterfaceImpl::GetFunctionInfo(FunctionID functionId, "**PROF: GetFunctionInfo 0x%p.\n", functionId)); - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -4892,7 +4892,7 @@ HRESULT ProfToEEInterfaceImpl::GetILToNativeMapping2(FunctionID functionId, "**PROF: GetILToNativeMapping2 0x%p 0x%p.\n", functionId, reJitId)); - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -4923,7 +4923,7 @@ HRESULT ProfToEEInterfaceImpl::GetILToNativeMapping2(FunctionID functionId, } else { - PCODE pCodeStart = NULL; + PCODE pCodeStart = (PCODE)NULL; CodeVersionManager *pCodeVersionManager = pMD->GetCodeVersionManager(); ILCodeVersion ilCodeVersion = NULL; { @@ -4981,7 +4981,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassFromObject(ObjectID objectId, "**PROF: GetClassFromObject 0x%p.\n", objectId)); - if (objectId == NULL) + if (objectId == 0) { return E_INVALIDARG; } @@ -5037,7 +5037,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassFromToken(ModuleID moduleId, moduleId, typeDef)); - if ((moduleId == NULL) || (typeDef == mdTypeDefNil) || (typeDef == NULL)) + if ((moduleId == 0) || (typeDef == mdTypeDefNil) || (typeDef == mdTokenNil)) { return E_INVALIDARG; } @@ -5087,7 +5087,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassFromToken(ModuleID moduleId, // ClassID classId = NonGenericTypeHandleToClassID(th); - if (classId == NULL) + if (classId == 0) { return CORPROF_E_TYPE_IS_PARAMETERIZED; } @@ -5270,7 +5270,7 @@ HRESULT ProfToEEInterfaceImpl::GetFunctionFromToken(ModuleID moduleId, moduleId, typeDef)); - if ((moduleId == NULL) || (typeDef == mdTokenNil)) + if ((moduleId == 0) || (typeDef == mdTokenNil)) { return E_INVALIDARG; } @@ -5473,7 +5473,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainInfo(AppDomainID appDomainId, "**PROF: GetAppDomainInfo 0x%p.\n", appDomainId)); - if (appDomainId == NULL) + if (appDomainId == 0) { return E_INVALIDARG; } @@ -5584,7 +5584,7 @@ HRESULT ProfToEEInterfaceImpl::GetAssemblyInfo(AssemblyID assemblyId, "**PROF: GetAssemblyInfo 0x%p.\n", assemblyId)); - if (assemblyId == NULL) + if (assemblyId == 0) { return E_INVALIDARG; } @@ -5981,7 +5981,7 @@ HRESULT ProfToEEInterfaceImpl::GetFunctionInfo2(FunctionID funcId, // COR_PRF_FRAME_INFO_INTERNAL *pFrameInfo = (COR_PRF_FRAME_INFO_INTERNAL *)frameInfo; - if ((funcId == NULL) || + if ((funcId == 0) || ((pFrameInfo != NULL) && (pFrameInfo->funcID != funcId))) { return E_INVALIDARG; @@ -6005,7 +6005,7 @@ HRESULT ProfToEEInterfaceImpl::GetFunctionInfo2(FunctionID funcId, TypeHandle specificClass; MethodDesc* pActualMethod; - ClassID classId = NULL; + ClassID classId = 0; if (pMethDesc->IsSharedByGenericInstantiations()) { @@ -6056,7 +6056,7 @@ HRESULT ProfToEEInterfaceImpl::GetFunctionInfo2(FunctionID funcId, // // We could not get any class information. // - classId = NULL; + classId = 0; } } else @@ -6191,7 +6191,7 @@ HRESULT ProfToEEInterfaceImpl::IsFunctionDynamic(FunctionID functionId, BOOL *is // Verify parameters. // - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -6346,7 +6346,7 @@ HRESULT ProfToEEInterfaceImpl::GetDynamicFunctionInfo(FunctionID functionId, // Verify parameters. // - if (functionId == NULL) + if (functionId == 0) { return E_INVALIDARG; } @@ -6453,7 +6453,7 @@ HRESULT ProfToEEInterfaceImpl::GetNativeCodeStartAddresses(FunctionID functionID } CONTRACTL_END; - if (functionID == NULL) + if (functionID == 0) { return E_INVALIDARG; } @@ -6491,7 +6491,7 @@ HRESULT ProfToEEInterfaceImpl::GetNativeCodeStartAddresses(FunctionID functionID { PCODE codeStart = (*iter).GetNativeCode(); - if (codeStart != NULL) + if (codeStart != (PCODE)NULL) { addresses.Append(codeStart); ++trueLen; @@ -6564,7 +6564,7 @@ HRESULT ProfToEEInterfaceImpl::GetILToNativeMapping3(UINT_PTR pNativeCodeStartAd "**PROF: GetILToNativeMapping3 0x%p.\n", pNativeCodeStartAddress)); - if (pNativeCodeStartAddress == NULL) + if (pNativeCodeStartAddress == (PCODE)NULL) { return E_INVALIDARG; } @@ -7409,7 +7409,7 @@ HRESULT ProfToEEInterfaceImpl::CreateHandle( LL_INFO1000, "**PROF: CreateHandle.\n")); - if (object == NULL) + if (object == 0) { return E_INVALIDARG; } @@ -7833,7 +7833,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassLayout(ClassID classID, // // Verify parameters // - if ((pcFieldOffset == NULL) || (classID == NULL)) + if ((pcFieldOffset == NULL) || (classID == 0)) { return E_INVALIDARG; } @@ -8030,7 +8030,7 @@ StackWalkAction ProfilerStackWalkCallback(CrawlFrame *pCf, PROFILER_STACK_WALK_D } else { - frameInfo.funcID = NULL; + frameInfo.funcID = 0; frameInfo.extraArg = NULL; } @@ -8542,7 +8542,7 @@ HRESULT ProfToEEInterfaceImpl::DoStackSnapshot(ThreadID thread, return CORPROF_E_INCONSISTENT_WITH_FLAGS; } - if (thread == NULL) + if (thread == 0) { pThreadToSnapshot = pCurrentThread; } @@ -9732,7 +9732,7 @@ HRESULT ProfilingGetFunctionEnter3Info(FunctionID functionId, } CONTRACTL_END; - if ((functionId == NULL) || (eltInfo == NULL)) + if ((functionId == 0) || (eltInfo == 0)) { return E_INVALIDARG; } @@ -9931,7 +9931,7 @@ HRESULT ProfilingGetFunctionLeave3Info(FunctionID functionId, } CONTRACTL_END; - if ((pFrameInfo == NULL) || (eltInfo == NULL)) + if ((pFrameInfo == NULL) || (eltInfo == 0)) { return E_INVALIDARG; } @@ -10093,7 +10093,7 @@ HRESULT ProfilingGetFunctionTailcall3Info(FunctionID functionId, } CONTRACTL_END; - if ((functionId == NULL) || (eltInfo == NULL) || (pFrameInfo == NULL)) + if ((functionId == 0) || (eltInfo == 0) || (pFrameInfo == NULL)) { return E_INVALIDARG; } @@ -10540,7 +10540,7 @@ HRESULT ProfToEEInterfaceImpl::ApplyMetaData( PROFILER_TO_CLR_ENTRYPOINT_SYNC_EX(kP2EEAllowableAfterAttach | kP2EETriggers, (LF_CORPROF, LL_INFO1000, "**PROF: ApplyMetaData.\n")); - if (moduleId == NULL) + if (moduleId == 0) { return E_INVALIDARG; } @@ -10734,7 +10734,7 @@ HCIMPL_PROLOG(ProfileEnter) g_profControlBlock.mainProfilerInfo.pProfInterface->GetEnter2Hook()( functionId, clientData, - NULL, + 0, NULL); goto LExit; } @@ -10744,7 +10744,7 @@ HCIMPL_PROLOG(ProfileEnter) // ProfileSetFunctionIDInPlatformSpecificHandle(platformSpecificHandle, functionId); - COR_PRF_FRAME_INFO frameInfo = NULL; + COR_PRF_FRAME_INFO frameInfo = 0; COR_PRF_FUNCTION_ARGUMENT_INFO * pArgumentInfo = NULL; ULONG ulArgInfoSize = 0; @@ -10908,7 +10908,7 @@ HCIMPL_PROLOG(ProfileLeave) g_profControlBlock.mainProfilerInfo.pProfInterface->GetLeave2Hook()( functionId, clientData, - NULL, + 0, NULL); goto LExit; } @@ -10916,7 +10916,7 @@ HCIMPL_PROLOG(ProfileLeave) // // Whidbey Slow-Path ELT // - COR_PRF_FRAME_INFO frameInfo = NULL; + COR_PRF_FRAME_INFO frameInfo = 0; COR_PRF_FUNCTION_ARGUMENT_RANGE argumentRange; HRESULT hr = ProfilingGetFunctionLeave3Info(functionId, (COR_PRF_ELT_INFO)&eltInfo, &frameInfo, &argumentRange); @@ -11040,14 +11040,14 @@ HCIMPL2(EXTERN_C void, ProfileTailcall, UINT_PTR clientData, void * platformSpec g_profControlBlock.mainProfilerInfo.pProfInterface->GetTailcall2Hook()( functionId, clientData, - NULL); + 0); goto LExit; } // // Whidbey Slow-Path ELT // - COR_PRF_FRAME_INFO frameInfo = NULL; + COR_PRF_FRAME_INFO frameInfo = 0; HRESULT hr = ProfilingGetFunctionTailcall3Info(functionId, (COR_PRF_ELT_INFO)&eltInfo, &frameInfo); _ASSERTE(hr == S_OK); diff --git a/src/coreclr/vm/readytoruninfo.cpp b/src/coreclr/vm/readytoruninfo.cpp index a047e17ffa3dfb..4facca3a37bfb3 100644 --- a/src/coreclr/vm/readytoruninfo.cpp +++ b/src/coreclr/vm/readytoruninfo.cpp @@ -1019,7 +1019,7 @@ bool ReadyToRunInfo::GetPgoInstrumentationData(MethodDesc * pMD, BYTE** pAllocat { STANDARD_VM_CONTRACT; - PCODE pEntryPoint = NULL; + PCODE pEntryPoint = (PCODE)NULL; #ifdef PROFILING_SUPPORTED BOOL fShouldSearchCache = TRUE; #endif // PROFILING_SUPPORTED @@ -1092,7 +1092,7 @@ PCODE ReadyToRunInfo::GetEntryPoint(MethodDesc * pMD, PrepareCodeConfig* pConfig bool printedStart = false; #endif - PCODE pEntryPoint = NULL; + PCODE pEntryPoint = (PCODE)NULL; #ifdef PROFILING_SUPPORTED BOOL fShouldSearchCache = TRUE; #endif // PROFILING_SUPPORTED diff --git a/src/coreclr/vm/reflectioninvocation.cpp b/src/coreclr/vm/reflectioninvocation.cpp index a7f88289d037a4..465c811fdeeb35 100644 --- a/src/coreclr/vm/reflectioninvocation.cpp +++ b/src/coreclr/vm/reflectioninvocation.cpp @@ -1095,7 +1095,7 @@ FCIMPL5(void, RuntimeFieldHandle::SetValueDirect, ReflectFieldObject *pFieldUNSA Assembly *pAssem = pField->GetModule()->GetAssembly(); BYTE *pDst = NULL; - ARG_SLOT value = NULL; + ARG_SLOT value = 0; CorElementType fieldElType; HELPER_METHOD_FRAME_BEGIN_PROTECT(gc); @@ -1835,9 +1835,9 @@ extern "C" void QCALLTYPE RuntimeTypeHandle_GetActivationInfo( if (pMT->IsNullable()) { // CreateInstance returns null given Nullable - *ppfnAllocator = NULL; + *ppfnAllocator = (PCODE)NULL; *pvAllocatorFirstArg = NULL; - *ppfnCtor = NULL; + *ppfnCtor = (PCODE)NULL; *pfCtorIsPublic = TRUE; // no ctor call needed => assume 'public' equivalent } else @@ -1855,14 +1855,14 @@ extern "C" void QCALLTYPE RuntimeTypeHandle_GetActivationInfo( _ASSERTE(pMD != NULL); PCODE pCode = pMD->GetMultiCallableAddrOfCode(); - _ASSERTE(pCode != NULL); + _ASSERTE(pCode != (PCODE)NULL); *ppfnCtor = pCode; *pfCtorIsPublic = pMD->IsPublic(); } else if (pMT->IsValueType()) { - *ppfnCtor = NULL; // no ctor call needed; we're creating a boxed default(T) + *ppfnCtor = (PCODE)NULL; // no ctor call needed; we're creating a boxed default(T) *pfCtorIsPublic = TRUE; // no ctor call needed => assume 'public' equivalent } else diff --git a/src/coreclr/vm/runtimecallablewrapper.h b/src/coreclr/vm/runtimecallablewrapper.h index 0be5aaf97c0537..229966e307fdbb 100644 --- a/src/coreclr/vm/runtimecallablewrapper.h +++ b/src/coreclr/vm/runtimecallablewrapper.h @@ -788,11 +788,11 @@ FORCEINLINE void NewRCWHolderRelease(RCW* p) } }; -class NewRCWHolder : public Wrapper +class NewRCWHolder : public Wrapper { public: NewRCWHolder(RCW* p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -800,7 +800,7 @@ class NewRCWHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; @@ -1424,11 +1424,11 @@ FORCEINLINE void CtxEntryHolderRelease(CtxEntry *p) } } -class CtxEntryHolder : public Wrapper +class CtxEntryHolder : public Wrapper { public: CtxEntryHolder(CtxEntry *p = NULL) - : Wrapper(p) + : Wrapper(p) { WRAPPER_NO_CONTRACT; } @@ -1437,7 +1437,7 @@ class CtxEntryHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 56e76cdf4949d1..727723e259cb13 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -175,7 +175,7 @@ TADDR CrawlFrame::GetAmbientSPFromCrawlFrame() #elif defined(TARGET_ARM) return GetRegisterSet()->pCurrentContext->Sp; #else - return NULL; + return 0; #endif } @@ -692,11 +692,11 @@ PCODE Thread::VirtualUnwindNonLeafCallFrame(T_CONTEXT* pContext, KNONVOLATILE_CO #endif if (NULL == pFunctionEntry) { - return NULL; + return (PCODE)NULL; } } - RtlVirtualUnwind(NULL, + RtlVirtualUnwind(0, uImageBase, uControlPc, pFunctionEntry, @@ -1158,9 +1158,8 @@ BOOL StackFrameIterator::Init(Thread * pThread, #endif // FEATURE_HIJACK - // FRAME_TOP and NULL must be distinct values. This assert - // will fire if someone changes this. - static_assert_no_msg(FRAME_TOP_VALUE != NULL); + // FRAME_TOP must not be 0/NULL. + static_assert_no_msg(FRAME_TOP_VALUE != 0); m_frameState = SFITER_UNINITIALIZED; @@ -1454,7 +1453,7 @@ void StackFrameIterator::ResetCrawlFrame() m_crawl.isProfilerDoStackSnapshot = !!(this->m_flags & PROFILER_DO_STACK_SNAPSHOT); m_crawl.isNoFrameTransition = false; - m_crawl.taNoFrameTransitionMarker = NULL; + m_crawl.taNoFrameTransitionMarker = (TADDR)NULL; #if defined(FEATURE_EH_FUNCLETS) m_crawl.isFilterFunclet = false; diff --git a/src/coreclr/vm/stackwalk.h b/src/coreclr/vm/stackwalk.h index 736ca2653ee77e..eda0f70bda0477 100644 --- a/src/coreclr/vm/stackwalk.h +++ b/src/coreclr/vm/stackwalk.h @@ -247,7 +247,7 @@ class CrawlFrame LIMITED_METHOD_DAC_CONTRACT; _ASSERTE((int)isNoFrameTransition != 0xcc); - return (isNoFrameTransition ? taNoFrameTransitionMarker : NULL); + return (isNoFrameTransition ? taNoFrameTransitionMarker : 0); } /* Has the IP been adjusted to a point where it is safe to do GC ? diff --git a/src/coreclr/vm/stackwalktypes.h b/src/coreclr/vm/stackwalktypes.h index 2263740e67c225..26764372994b00 100644 --- a/src/coreclr/vm/stackwalktypes.h +++ b/src/coreclr/vm/stackwalktypes.h @@ -39,7 +39,7 @@ struct METHODTOKEN BOOL IsNull() const { - return m_pCodeHeader == NULL; + return m_pCodeHeader == 0; } }; diff --git a/src/coreclr/vm/stringliteralmap.cpp b/src/coreclr/vm/stringliteralmap.cpp index 55d2267f02c8c6..34f4eecea50152 100644 --- a/src/coreclr/vm/stringliteralmap.cpp +++ b/src/coreclr/vm/stringliteralmap.cpp @@ -49,7 +49,7 @@ #define EEHASH_MEMORY_POOL_GROW_COUNT 128 StringLiteralEntryArray *StringLiteralEntry::s_EntryList = NULL; -DWORD StringLiteralEntry::s_UsedEntries = NULL; +DWORD StringLiteralEntry::s_UsedEntries = 0; StringLiteralEntry *StringLiteralEntry::s_FreeEntryList = NULL; StringLiteralMap::StringLiteralMap() diff --git a/src/coreclr/vm/stubgen.cpp b/src/coreclr/vm/stubgen.cpp index 5ecb723b68c5d9..29595b9414d514 100644 --- a/src/coreclr/vm/stubgen.cpp +++ b/src/coreclr/vm/stubgen.cpp @@ -2044,7 +2044,7 @@ LocalSigBuilder::GetSig( } else { - return NULL; + return 0; } } @@ -2239,7 +2239,7 @@ FunctionSigBuilder::GetSig( } else { - return NULL; + return 0; } } diff --git a/src/coreclr/vm/stubhelpers.cpp b/src/coreclr/vm/stubhelpers.cpp index 95a5650a199f4a..27be9617ac3e59 100644 --- a/src/coreclr/vm/stubhelpers.cpp +++ b/src/coreclr/vm/stubhelpers.cpp @@ -432,7 +432,7 @@ FCIMPLEND FCIMPL1(void*, StubHelpers::GetDelegateTarget, DelegateObject *pThisUNSAFE) { - PCODE pEntryPoint = NULL; + PCODE pEntryPoint = (PCODE)NULL; #ifdef _DEBUG BEGIN_PRESERVE_LAST_ERROR; @@ -506,7 +506,7 @@ FCIMPL3(SIZE_T, StubHelpers::ProfilerBeginTransitionCallback, SIZE_T pSecretPara // even if the profiler doesn't want to track transitions. if (!CORProfilerTrackTransitions()) { - return NULL; + return 0; } MethodDesc* pRealMD = NULL; diff --git a/src/coreclr/vm/stubmgr.cpp b/src/coreclr/vm/stubmgr.cpp index 68af3ecf200a1d..84ae3e1fd0d7d3 100644 --- a/src/coreclr/vm/stubmgr.cpp +++ b/src/coreclr/vm/stubmgr.cpp @@ -428,7 +428,7 @@ BOOL StubManager::CheckIsStub_Worker(PCODE stubStartAddress) // @todo - consider having a single check for null right up front. // Though this may cover bugs where stub-managers don't handle bad addresses. // And someone could just as easily pass (0x01) as NULL. - if (stubStartAddress == NULL) + if (stubStartAddress == (PCODE)NULL) { return FALSE; } @@ -1037,7 +1037,7 @@ BOOL PrecodeStubManager::DoTraceStub(PCODE stubStartAddress, #ifndef DACCESS_COMPILE trace->InitForUnmanaged(GetEEFuncEntryPoint(NDirectImportThunk)); #else - trace->InitForOther(NULL); + trace->InitForOther((PCODE)NULL); #endif LOG_TRACE_DESTINATION(trace, stubStartAddress, "PrecodeStubManager::DoTraceStub - NDirect import"); return TRUE; @@ -1330,8 +1330,8 @@ static PCODE GetStubTarget(PTR_MethodDesc pTargetMD) targetCode = NativeCodeVersion(pTargetMD); #endif - if (targetCode.IsNull() || targetCode.GetNativeCode() == NULL) - return NULL; + if (targetCode.IsNull() || targetCode.GetNativeCode() == (PCODE)NULL) + return (PCODE)NULL; return targetCode.GetNativeCode(); } @@ -1460,7 +1460,7 @@ BOOL StubLinkStubManager::TraceManager(Thread *thread, _ASSERTE(pMD != NULL); PCODE target = GetStubTarget(pMD); - if (target == NULL) + if (target == (PCODE)NULL) { LOG((LF_CORDB,LL_INFO10000, "SLSM:TM Unable to determine stub target, pMD %p\n", pMD)); trace->InitForUnjittedMethod(pMD); @@ -1808,7 +1808,7 @@ BOOL ILStubManager::DoTraceStub(PCODE stubStartAddress, #ifndef DACCESS_COMPILE - PCODE traceDestination = NULL; + PCODE traceDestination = (PCODE)NULL; #ifdef FEATURE_MULTICASTSTUB_AS_IL MethodDesc* pStubMD = ExecutionManager::GetCodeMethodDesc(stubStartAddress); @@ -1829,7 +1829,7 @@ BOOL ILStubManager::DoTraceStub(PCODE stubStartAddress, return TRUE; #else // !DACCESS_COMPILE - trace->InitForOther(NULL); + trace->InitForOther((PCODE)NULL); return FALSE; #endif // !DACCESS_COMPILE @@ -1887,7 +1887,7 @@ BOOL ILStubManager::TraceManager(Thread *thread, pStubMD, arg, pThis)); // See code:ILStubCache.CreateNewMethodDesc for the code that sets flags on stub MDs - PCODE target = NULL; + PCODE target = (PCODE)NULL; #ifdef FEATURE_MULTICASTSTUB_AS_IL if (pStubMD->IsMulticastStub()) @@ -1965,7 +1965,7 @@ BOOL ILStubManager::TraceManager(Thread *thread, LOG((LF_CORDB, LL_INFO1000, "ILSM::TraceManager: Step through to target - 0x%p\n", pTargetMD)); target = GetStubTarget(pTargetMD); - if (target == NULL) + if (target == (PCODE)NULL) return FALSE; trace->InitForManaged(target); @@ -2094,7 +2094,7 @@ BOOL InteropDispatchStubManager::DoTraceStub(PCODE stubStartAddress, TraceDestin return TRUE; #else // !DACCESS_COMPILE - trace->InitForOther(NULL); + trace->InitForOther((PCODE)NULL); return FALSE; #endif // !DACCESS_COMPILE diff --git a/src/coreclr/vm/stubmgr.h b/src/coreclr/vm/stubmgr.h index 9da4f61f6d2a81..36955761bff197 100644 --- a/src/coreclr/vm/stubmgr.h +++ b/src/coreclr/vm/stubmgr.h @@ -215,7 +215,7 @@ class StubManager static BOOL IsStub(PCODE stubAddress) { WRAPPER_NO_CONTRACT; - return FindStubManager(stubAddress) != NULL; + return FindStubManager(stubAddress) != nullptr; } // Find stub manager for given code address diff --git a/src/coreclr/vm/syncblk.cpp b/src/coreclr/vm/syncblk.cpp index eb0b29fafdd026..48ede10b35fef0 100644 --- a/src/coreclr/vm/syncblk.cpp +++ b/src/coreclr/vm/syncblk.cpp @@ -2108,7 +2108,7 @@ void VoidDeleteSyncBlockMemory(SyncBlock* psb) SyncBlockCache::GetSyncBlockCache()->DeleteSyncBlockMemory(psb); } -typedef Wrapper, VoidDeleteSyncBlockMemory, NULL> SyncBlockMemoryHolder; +typedef Wrapper, VoidDeleteSyncBlockMemory, 0> SyncBlockMemoryHolder; // get the sync block for an existing object diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index f519ff758fbc95..e9e2409dde0c7b 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -330,7 +330,7 @@ bool Thread::DetectHandleILStubsForDebugger() // Check for M2U transition frames. See the comment at the beginning of this function. else if (pFrame->GetFrameType() == Frame::TYPE_EXIT) { - if (pFrame->GetReturnAddress() == NULL) + if (pFrame->GetReturnAddress() == (PCODE)NULL) { // If the return address is NULL, then the frame has not been initialized yet. // We may see InlinedCallFrame in ordinary methods as well. Have to do @@ -7648,7 +7648,7 @@ TADDR Thread::GetStaticFieldAddrNoCreate(FieldDesc *pFD) } if (base == NULL) - return NULL; + return (TADDR)NULL; DWORD offset = pFD->GetOffset(); _ASSERTE(offset <= FIELD_OFFSET_LAST_REAL_OFFSET); @@ -7662,7 +7662,7 @@ TADDR Thread::GetStaticFieldAddrNoCreate(FieldDesc *pFD) _ASSERTE(result != NULL); PTR_Object obj = *PTR_UNCHECKED_OBJECTREF(result); if (obj == NULL) - return NULL; + return (TADDR)NULL; result = dac_cast(obj->GetData()); } diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index b9472590fc8bad..4241893ee522bb 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -2398,7 +2398,7 @@ class Thread #ifndef DACCESS_COMPILE static PCODE VirtualUnwindLeafCallFrame(T_CONTEXT* pContext); static PCODE VirtualUnwindNonLeafCallFrame(T_CONTEXT* pContext, T_KNONVOLATILE_CONTEXT_POINTERS* pContextPointers = NULL, - PT_RUNTIME_FUNCTION pFunctionEntry = NULL, UINT_PTR uImageBase = NULL); + PT_RUNTIME_FUNCTION pFunctionEntry = NULL, UINT_PTR uImageBase = 0); static UINT_PTR VirtualUnwindToFirstManagedCallFrame(T_CONTEXT* pContext); #endif // DACCESS_COMPILE #endif // FEATURE_EH_FUNCLETS @@ -2918,13 +2918,13 @@ class Thread public: - BOOL IsLastThrownObjectNull() { WRAPPER_NO_CONTRACT; return (m_LastThrownObjectHandle == NULL); } + BOOL IsLastThrownObjectNull() { WRAPPER_NO_CONTRACT; return (m_LastThrownObjectHandle == (OBJECTHANDLE)0); } OBJECTREF LastThrownObject() { WRAPPER_NO_CONTRACT; - if (m_LastThrownObjectHandle == NULL) + if (m_LastThrownObjectHandle == (OBJECTHANDLE)0) { return NULL; } diff --git a/src/coreclr/vm/threads.inl b/src/coreclr/vm/threads.inl index c64382d4bbd08b..b15b7bef0895ba 100644 --- a/src/coreclr/vm/threads.inl +++ b/src/coreclr/vm/threads.inl @@ -108,7 +108,7 @@ inline void Thread::ClearThreadCurrNotification() } CONTRACTL_END; - m_hCurrNotification = NULL; + m_hCurrNotification = (OBJECTHANDLE)NULL; } diff --git a/src/coreclr/vm/threadstatics.cpp b/src/coreclr/vm/threadstatics.cpp index 6a8a43a0821efb..74d2eb08a3dc8d 100644 --- a/src/coreclr/vm/threadstatics.cpp +++ b/src/coreclr/vm/threadstatics.cpp @@ -52,11 +52,11 @@ void ThreadLocalBlock::FreeTLM(SIZE_T i, BOOL isThreadShuttingdown) ThreadLocalModule::CollectibleDynamicEntry *entry = (ThreadLocalModule::CollectibleDynamicEntry*)pThreadLocalModule->m_pDynamicClassTable[k].m_pDynamicEntry; PTR_LoaderAllocator pLoaderAllocator = entry->m_pLoaderAllocator; - if (entry->m_hGCStatics != NULL) + if (entry->m_hGCStatics != 0) { pLoaderAllocator->FreeHandle(entry->m_hGCStatics); } - if (entry->m_hNonGCStatics != NULL) + if (entry->m_hNonGCStatics != 0) { pLoaderAllocator->FreeHandle(entry->m_hNonGCStatics); } diff --git a/src/coreclr/vm/threadstatics.h b/src/coreclr/vm/threadstatics.h index f002f0059ce6f2..8c0c87998bf180 100644 --- a/src/coreclr/vm/threadstatics.h +++ b/src/coreclr/vm/threadstatics.h @@ -96,8 +96,8 @@ struct ThreadLocalModule LIMITED_METHOD_CONTRACT; } - LOADERHANDLE m_hGCStatics = NULL; - LOADERHANDLE m_hNonGCStatics = NULL; + LOADERHANDLE m_hGCStatics = (LOADERHANDLE)0; + LOADERHANDLE m_hNonGCStatics = (LOADERHANDLE)0; PTR_LoaderAllocator m_pLoaderAllocator = NULL; }; typedef DPTR(CollectibleDynamicEntry) PTR_CollectibleDynamicEntry; diff --git a/src/coreclr/vm/tieredcompilation.cpp b/src/coreclr/vm/tieredcompilation.cpp index 586f1945f5bd16..6160a7aaac6acc 100644 --- a/src/coreclr/vm/tieredcompilation.cpp +++ b/src/coreclr/vm/tieredcompilation.cpp @@ -645,7 +645,7 @@ bool TieredCompilationManager::TryDeactivateTieringDelay() } PCODE codeEntryPoint = activeCodeVersion.GetNativeCode(); - if (codeEntryPoint == NULL) + if (codeEntryPoint == (PCODE)NULL) { // The active IL/native code version has changed since the method was queued, and the currently active version // doesn't have a code entry point yet @@ -944,7 +944,7 @@ BOOL TieredCompilationManager::CompileCodeVersion(NativeCodeVersion nativeCodeVe { STANDARD_VM_CONTRACT; - PCODE pCode = NULL; + PCODE pCode = (PCODE)NULL; MethodDesc* pMethod = nativeCodeVersion.GetMethodDesc(); EX_TRY { @@ -968,7 +968,7 @@ BOOL TieredCompilationManager::CompileCodeVersion(NativeCodeVersion nativeCodeVe // point. // TODO: In the future, we should get some feedback from images containing pregenerated code and from tier 0 JIT // indicating that the method would not benefit from a rejit and avoid the rejit altogether. - pCode = NULL; + pCode = (PCODE)NULL; } } EX_CATCH @@ -979,7 +979,7 @@ BOOL TieredCompilationManager::CompileCodeVersion(NativeCodeVersion nativeCodeVe } EX_END_CATCH(RethrowTerminalExceptions) - return pCode != NULL; + return pCode != (PCODE)NULL; } // Updates the MethodDesc and precode so that future invocations of a method will diff --git a/src/coreclr/vm/typedesc.cpp b/src/coreclr/vm/typedesc.cpp index 72bc9e50c29bc7..81a2e58364320e 100644 --- a/src/coreclr/vm/typedesc.cpp +++ b/src/coreclr/vm/typedesc.cpp @@ -525,7 +525,7 @@ OBJECTREF ParamTypeDesc::GetManagedClassObject() } CONTRACTL_END; - if (m_hExposedClassObject == NULL) + if (m_hExposedClassObject == 0) { TypeHandle(this).AllocateManagedClassObject(&m_hExposedClassObject); } @@ -549,7 +549,7 @@ OBJECTREF FnPtrTypeDesc::GetManagedClassObject() } CONTRACTL_END; - if (m_hExposedClassObject == NULL) + if (m_hExposedClassObject == 0) { TypeHandle(this).AllocateManagedClassObject(&m_hExposedClassObject); } @@ -1629,7 +1629,7 @@ OBJECTREF TypeVarTypeDesc::GetManagedClassObject() } CONTRACTL_END; - if (m_hExposedClassObject == NULL) + if (m_hExposedClassObject == 0) { TypeHandle(this).AllocateManagedClassObject(&m_hExposedClassObject); } diff --git a/src/coreclr/vm/typehandle.cpp b/src/coreclr/vm/typehandle.cpp index 91c6013bb527cd..103f2ca4250ccf 100644 --- a/src/coreclr/vm/typehandle.cpp +++ b/src/coreclr/vm/typehandle.cpp @@ -337,7 +337,7 @@ void TypeHandle::AllocateManagedClassObject(RUNTIMETYPEHANDLE* pDest) // Take a lock here since we don't want to allocate redundant objects which won't be collected CrstHolder exposedClassLock(AppDomain::GetMethodTableExposedClassObjectLock()); - if (VolatileLoad(pDest) == NULL) + if (VolatileLoad(pDest) == 0) { FrozenObjectHeapManager* foh = SystemDomain::GetFrozenObjectHeapManager(); Object* obj = foh->TryAllocateObject(g_pRuntimeTypeClass, g_pRuntimeTypeClass->GetBaseSize()); @@ -363,7 +363,7 @@ void TypeHandle::AllocateManagedClassObject(RUNTIMETYPEHANDLE* pDest) // Let all threads fight over who wins using InterlockedCompareExchange. // Only the winner can set m_ExposedClassObject from NULL. - if (InterlockedCompareExchangeT(pDest, exposedClassObjectHandle, static_cast(NULL))) + if (InterlockedCompareExchangeT(pDest, exposedClassObjectHandle, (RUNTIMETYPEHANDLE)0)) { // GC will collect unused instance allocator->FreeHandle(exposedClassObjectHandle); diff --git a/src/coreclr/vm/util.cpp b/src/coreclr/vm/util.cpp index 58dc2d28ee373e..d03ecb73260736 100644 --- a/src/coreclr/vm/util.cpp +++ b/src/coreclr/vm/util.cpp @@ -384,13 +384,13 @@ SIZE_T DereferenceByRefVar(SIZE_T addr) { STATIC_CONTRACT_WRAPPER; - SIZE_T result = NULL; + SIZE_T result = 0; #if defined(DACCESS_COMPILE) HRESULT hr = DacReadAll(addr, &result, sizeof(result), false); if (FAILED(hr)) { - result = NULL; + result = 0; } #else // !DACCESS_COMPILE @@ -1070,7 +1070,7 @@ BOOL JITNotifications::SetAllNotifications(TADDR clrModule,USHORT NType,BOOL *ch { JITNotification *pCurrent = m_jitTable + i; if (!pCurrent->IsFree() && - ((clrModule == NULL) || (pCurrent->clrModule == clrModule))&& + ((clrModule == (TADDR)NULL) || (pCurrent->clrModule == clrModule))&& pCurrent->state != NType) { pCurrent->state = NType; @@ -1102,7 +1102,7 @@ BOOL JITNotifications::SetNotification(TADDR clrModule, mdToken token, USHORT NT return FALSE; } - if (clrModule == NULL) + if (clrModule == (TADDR)NULL) { return FALSE; } @@ -1255,7 +1255,7 @@ BOOL UpdateOutOfProcTable(__GlobalPtr(pHostTable) == NULL) + if (dac_cast(pHostTable) == (TADDR)NULL) { // The table has not been initialized in the target. Allocate space for it and update the pointer // in the target so that we'll use this allocated memory from now on. Note that we never free this @@ -1492,14 +1492,14 @@ void DACNotifyExceptionHelper(TADDR *args, UINT argCount) DACRaiseException(args, argCount); - g_clrNotificationArguments[0] = NULL; + g_clrNotificationArguments[0] = 0; } } void InitializeClrNotifications() { g_clrNotificationCrst.Init(CrstClrNotification, CRST_UNSAFE_ANYMODE); - g_clrNotificationArguments[0] = NULL; + g_clrNotificationArguments[0] = 0; } // FIX IN BETA 2 diff --git a/src/coreclr/vm/util.hpp b/src/coreclr/vm/util.hpp index ef05074b186a41..17a106fdc926a2 100644 --- a/src/coreclr/vm/util.hpp +++ b/src/coreclr/vm/util.hpp @@ -542,7 +542,7 @@ FORCEINLINE void VoidFreeNativeLibrary(NATIVE_LIBRARY_HANDLE h) #endif } -typedef Wrapper, VoidFreeNativeLibrary, NULL> NativeLibraryHandleHolder; +typedef Wrapper, VoidFreeNativeLibrary, 0> NativeLibraryHandleHolder; extern thread_local size_t t_CantStopCount; @@ -587,7 +587,7 @@ struct JITNotification JITNotification() { SetFree(); } BOOL IsFree() { return state == CLRDATA_METHNOTIFY_NONE; } - void SetFree() { state = CLRDATA_METHNOTIFY_NONE; clrModule = NULL; methodToken = 0; } + void SetFree() { state = CLRDATA_METHNOTIFY_NONE; clrModule = 0; methodToken = 0; } void SetState(TADDR moduleIn, mdToken tokenIn, USHORT NType) { _ASSERTE(IsValidMethodCodeNotification(NType)); diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index a87eac54f607cd..8da8aea4be5721 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -1311,7 +1311,7 @@ PCODE VSD_ResolveWorker(TransitionBlock * pTransitionBlock, _ASSERTE(protectedObj != NULL); OBJECTREF pObj = *protectedObj; - PCODE target = NULL; + PCODE target = (PCODE)NULL; if (pObj == NULL) { pSDFrame->SetForNullReferenceException(); @@ -1506,7 +1506,7 @@ PCODE VirtualCallStubManager::ResolveWorker(StubCallSite* pCallSite, bCallToShorterLivedTarget ? "bCallToShorterLivedTarget" : "" )); PCODE stub = CALL_STUB_EMPTY_ENTRY; - PCODE target = NULL; + PCODE target = (PCODE)NULL; BOOL patch = FALSE; // This code can throw an OOM, but we do not want to fail in this case because @@ -1539,7 +1539,7 @@ PCODE VirtualCallStubManager::ResolveWorker(StubCallSite* pCallSite, ///////////////////////////////////////////////////////////////////////////////////// // Second see if we can find a ResolveCacheElem for this token and type. // If a match is found, use the target stored in the entry. - if (target == NULL) + if (target == (PCODE)NULL) { ResolveCacheElem * elem = NULL; ResolveCacheEntry entryRC; @@ -1564,7 +1564,7 @@ PCODE VirtualCallStubManager::ResolveWorker(StubCallSite* pCallSite, // If we failed to find a target in either the resolver or cache entry hash tables, // we need to perform a full resolution of the token and type. //@TODO: Would be nice to add assertion code to ensure we only ever call Resolver once per . - if (target == NULL) + if (target == (PCODE)NULL) { CONSISTENCY_CHECK(stub == CALL_STUB_EMPTY_ENTRY); patch = Resolver(objectType, token, protectedObj, &target, TRUE /* throwOnConflict */); @@ -1610,7 +1610,7 @@ PCODE VirtualCallStubManager::ResolveWorker(StubCallSite* pCallSite, DispatchCache::InsertKind insertKind = DispatchCache::IK_NONE; - if (target != NULL) + if (target != (PCODE)NULL) { if (patch) { @@ -1630,7 +1630,7 @@ PCODE VirtualCallStubManager::ResolveWorker(StubCallSite* pCallSite, // Only X86 implementation needs a BackPatch function pBackPatchFcn = (PCODE) GetEEFuncEntryPoint(BackPatchWorkerAsmStub); #else // !TARGET_X86 - pBackPatchFcn = NULL; + pBackPatchFcn = (PCODE)NULL; #endif // !TARGET_X86 #ifdef CHAIN_LOOKUP @@ -1932,7 +1932,7 @@ VirtualCallStubManager::Resolver( { // Skip fixup precode jump for better perf PCODE pDirectTarget = Precode::TryToSkipFixupPrecode(implSlot.GetTarget()); - if (pDirectTarget != NULL) + if (pDirectTarget != (PCODE)NULL) implSlot = DispatchSlot(pDirectTarget); // Only patch to a target if it's not going to call the prestub. @@ -2060,7 +2060,7 @@ VirtualCallStubManager::Resolver( if (!throwOnConflict) { // Assume we got null because there was a default interface method conflict - *ppTarget = NULL; + *ppTarget = (PCODE)NULL; return FALSE; } else @@ -2220,11 +2220,11 @@ VirtualCallStubManager::GetTarget( GCX_COOP(); // This is necessary for BucketTable synchronization - PCODE target = NULL; + PCODE target = (PCODE)NULL; #ifndef STUB_DISPATCH_PORTABLE target = CacheLookup(token.To_SIZE_T(), DispatchCache::INVALID_HASH, pMT); - if (target != NULL) + if (target != (PCODE)NULL) return target; #endif // !STUB_DISPATCH_PORTABLE @@ -3810,7 +3810,7 @@ MethodDesc *VirtualCallStubManagerManager::Entry2MethodDesc( // Do the full resolve DispatchToken token(VirtualCallStubManager::GetTokenFromStubQuick(pMgr, stubStartAddress, sk)); - PCODE target = NULL; + PCODE target = (PCODE)NULL; // TODO: passing NULL as protectedObj here can lead to incorrect behavior for ICastable objects // We need to review if this is the case and refactor this code if we want ICastable to become officially supported VirtualCallStubManager::Resolver(pMT, token, NULL, &target, TRUE /* throwOnConflict */); diff --git a/src/coreclr/vm/wrappers.h b/src/coreclr/vm/wrappers.h index 15be566391e80d..ff032765684a4c 100644 --- a/src/coreclr/vm/wrappers.h +++ b/src/coreclr/vm/wrappers.h @@ -152,11 +152,11 @@ FORCEINLINE void VariantPtrRelease(VARIANT* value) } } -class VariantPtrHolder : public Wrapper +class VariantPtrHolder : public Wrapper { public: VariantPtrHolder(VARIANT* p = NULL) - : Wrapper(p) + : Wrapper(p) { LIMITED_METHOD_CONTRACT; } @@ -165,7 +165,7 @@ class VariantPtrHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; @@ -194,11 +194,11 @@ FORCEINLINE void SafeArrayPtrRelease(SAFEARRAY* value) } } -class SafeArrayPtrHolder : public Wrapper +class SafeArrayPtrHolder : public Wrapper { public: SafeArrayPtrHolder(SAFEARRAY* p = NULL) - : Wrapper(p) + : Wrapper(p) { LIMITED_METHOD_CONTRACT; } @@ -207,7 +207,7 @@ class SafeArrayPtrHolder : public Wrapper::operator=(p); + Wrapper::operator=(p); } }; @@ -230,11 +230,11 @@ FORCEINLINE void ZeroRelease(VOID* value) } } -class ZeroHolder : public Wrapper +class ZeroHolder : public Wrapper { public: ZeroHolder(VOID* p = NULL) - : Wrapper(p) + : Wrapper(p) { LIMITED_METHOD_CONTRACT; } @@ -243,7 +243,7 @@ class ZeroHolder : public Wrapper { WRAPPER_NO_CONTRACT; - Wrapper::operator=(p); + Wrapper::operator=(p); } }; From 13cb6e6ac81ba23fea77a0b0f328b59afbd43fde Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 11 Apr 2024 14:17:43 -0700 Subject: [PATCH 02/10] Use delgating constructors to simplify DAC pointer types. --- src/coreclr/inc/daccess.h | 104 ++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 61 deletions(-) diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 8581dcae888feb..2e591b55ec8198 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -938,18 +938,13 @@ class __DPtrBase : public __TPtrBase typedef type _Type; typedef type* _Ptr; -protected: - // Constructors - // All protected - this type should not be used directly - use one of the derived types instead. - __DPtrBase< type, DPtrType >(void) : __TPtrBase() {} - __DPtrBase< type, DPtrType >(TADDR addr) : __TPtrBase(addr) {} - __DPtrBase< type, DPtrType >(std::nullptr_t) : __TPtrBase(nullptr) {} + using __TPtrBase::__TPtrBase; - explicit __DPtrBase< type, DPtrType >(__TPtrBase addr) + explicit __DPtrBase(__TPtrBase addr) { m_addr = addr.GetAddr(); } - explicit __DPtrBase< type, DPtrType >(type const * host) + explicit __DPtrBase(type const * host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } @@ -1205,29 +1200,24 @@ template class __DPtr : public __DPtrBase > { public: - // constructors - all chain to __DPtrBase constructors - __DPtr< type >(void) : __DPtrBase >() {} - __DPtr< type >(TADDR addr) : __DPtrBase >(addr) {} - __DPtr< type >(std::nullptr_t) : __DPtrBase >(nullptr) {} + using __DPtrBase>::__DPtrBase; // construct const from non-const typedef typename std::remove_const::type mutable_type; - __DPtr< type >(__DPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} + __DPtr(__DPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} // construct from GlobalPtr - explicit __DPtr< type >(__GlobalPtr< type*, __DPtr< type > > globalPtr) : + explicit __DPtr(__GlobalPtr< type*, __DPtr< type > > globalPtr) : __DPtrBase >(globalPtr.GetAddr()) {} - explicit __DPtr< type >(__TPtrBase addr) : __DPtrBase >(addr) {} - explicit __DPtr< type >(type const * host) : __DPtrBase >(host) {} - operator type*() const { return (type*)DacInstantiateTypeByAddress(this->m_addr, sizeof(type), true); } + type* operator->() const { - return (type*)DacInstantiateTypeByAddress(this->m_addr, sizeof(type), true); + return (type*)this; } }; @@ -1244,16 +1234,11 @@ template class __ArrayDPtr : public __DPtrBase > { public: - // constructors - all chain to __DPtrBase constructors - __ArrayDPtr< type >(void) : __DPtrBase >() {} - __ArrayDPtr< type >(TADDR addr) : __DPtrBase >(addr) {} - __ArrayDPtr< type >(std::nullptr_t) : __DPtrBase >(nullptr) {} + using __DPtrBase>::__DPtrBase; // construct const from non-const typedef typename std::remove_const::type mutable_type; - __ArrayDPtr< type >(__ArrayDPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} - - explicit __ArrayDPtr< type >(__TPtrBase addr) : __DPtrBase >(addr) {} + __ArrayDPtr(__ArrayDPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} // Note that there is also no explicit constructor from host instances (type*). // Going this direction is less problematic, but often still represents risky coding. @@ -1273,14 +1258,13 @@ class __SPtr : public __TPtrBase typedef type _Type; typedef type* _Ptr; - __SPtr< type >(void) : __TPtrBase() {} - __SPtr< type >(TADDR addr) : __TPtrBase(addr) {} - __SPtr< type >(std::nullptr_t) : __TPtrBase(nullptr) {} - explicit __SPtr< type >(__TPtrBase addr) + using __TPtrBase::__TPtrBase; + + explicit __SPtr(__TPtrBase addr) { m_addr = addr.GetAddr(); } - explicit __SPtr< type >(type* host) + explicit __SPtr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } @@ -1371,9 +1355,8 @@ class __VPtr : public __TPtrBase typedef type* _Type; typedef type* _Ptr; - __VPtr< type >(void) : __TPtrBase() {} - __VPtr< type >(TADDR addr) : __TPtrBase(addr) {} - __VPtr< type >(std::nullptr_t) : __TPtrBase(nullptr) {} + using __TPtrBase::__TPtrBase; + explicit __VPtr< type >(__TPtrBase addr) { m_addr = addr.GetAddr(); @@ -1457,13 +1440,13 @@ class __Str8Ptr : public __DPtr typedef type _Type; typedef type* _Ptr; - __Str8Ptr< type, maxChars >(void) : __DPtr() {} - __Str8Ptr< type, maxChars >(TADDR addr) : __DPtr(addr) {} - explicit __Str8Ptr< type, maxChars >(__TPtrBase addr) + using __DPtr::__DPtr; + + explicit __Str8Ptr(__TPtrBase addr) { m_addr = addr.GetAddr(); } - explicit __Str8Ptr< type, maxChars >(type* host) + explicit __Str8Ptr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } @@ -1510,8 +1493,8 @@ class __Str16Ptr : public __DPtr typedef type _Type; typedef type* _Ptr; - __Str16Ptr< type, maxChars >(void) : __DPtr() {} - __Str16Ptr< type, maxChars >(TADDR addr) : __DPtr(addr) {} + __Str16Ptr(void) : __DPtr() {} + __Str16Ptr(TADDR addr) : __DPtr(addr) {} explicit __Str16Ptr< type, maxChars >(__TPtrBase addr) { m_addr = addr.GetAddr(); @@ -1521,12 +1504,12 @@ class __Str16Ptr : public __DPtr m_addr = DacGetTargetAddrForHostAddr(host, true); } - __Str16Ptr< type, maxChars >& operator=(const __TPtrBase& ptr) + __Str16Ptr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __Str16Ptr< type, maxChars >& operator=(TADDR addr) + __Str16Ptr& operator=(TADDR addr) { m_addr = addr; return *this; @@ -1605,7 +1588,7 @@ template class __GlobalArray { public: - __GlobalArray< type, size >(TADDR DacGlobals::* ptr) + __GlobalArray(TADDR DacGlobals::* ptr) { m_ptr = ptr; } @@ -1637,20 +1620,21 @@ class __GlobalArray template class __GlobalPtr { + using DPtr = __DPtr; public: - __GlobalPtr< acc_type, store_type >(TADDR DacGlobals::* ptr) + __GlobalPtr(TADDR DacGlobals::* ptr) { m_ptr = ptr; } - __DPtr< store_type > operator&() const + DPtr operator&() const { - return __DPtr< store_type >(DacGlobalValues()->*m_ptr); + return DPtr(DacGlobalValues()->*m_ptr); } - store_type & operator=(store_type & val) + store_type& operator=(store_type & val) { - store_type* ptr = __DPtr< store_type >(DacGlobalValues()->*m_ptr); + store_type* ptr = DPtr(DacGlobalValues()->*m_ptr); // Update the host copy; *ptr = val; // Write back to the target. @@ -1660,34 +1644,34 @@ class __GlobalPtr acc_type operator->() const { - return (acc_type)*__DPtr< store_type >(DacGlobalValues()->*m_ptr); + return (acc_type)*DPtr(DacGlobalValues()->*m_ptr); } operator acc_type() const { - return (acc_type)*__DPtr< store_type >(DacGlobalValues()->*m_ptr); + return (acc_type)*DPtr(DacGlobalValues()->*m_ptr); } operator store_type() const { - return *__DPtr< store_type >(DacGlobalValues()->*m_ptr); + return *DPtr(DacGlobalValues()->*m_ptr); } bool operator!() const { - return !*__DPtr< store_type >(DacGlobalValues()->*m_ptr); + return !*DPtr(DacGlobalValues()->*m_ptr); } typename store_type::_Type& operator[](int index) { - return (*__DPtr< store_type >(DacGlobalValues()->*m_ptr))[index]; + return (*DPtr(DacGlobalValues()->*m_ptr))[index]; } typename store_type::_Type& operator[](unsigned int index) { - return (*__DPtr< store_type >(DacGlobalValues()->*m_ptr))[index]; + return (*DPtr(DacGlobalValues()->*m_ptr))[index]; } TADDR GetAddr() const { - return (*__DPtr< store_type >(DacGlobalValues()->*m_ptr)).GetAddr(); + return (*DPtr(DacGlobalValues()->*m_ptr)).GetAddr(); } TADDR GetAddrRaw () const @@ -1700,17 +1684,17 @@ class __GlobalPtr // bool IsValidPtr(void) const { - return __DPtr< store_type >(DacGlobalValues()->*m_ptr).IsValid(); + return DPtr(DacGlobalValues()->*m_ptr).IsValid(); } bool IsValid(void) const { - return __DPtr< store_type >(DacGlobalValues()->*m_ptr).IsValid() && - (*__DPtr< store_type >(DacGlobalValues()->*m_ptr)).IsValid(); + return DPtr(DacGlobalValues()->*m_ptr).IsValid() && + (*DPtr(DacGlobalValues()->*m_ptr)).IsValid(); } void EnumMem(void) const { - __DPtr< store_type > ptr(DacGlobalValues()->*m_ptr); + DPtr ptr(DacGlobalValues()->*m_ptr); ptr.EnumMem(); if (ptr.IsValid()) { @@ -1782,9 +1766,7 @@ inline bool operator!=(acc_type host, class __VoidPtr : public __TPtrBase { public: - __VoidPtr(void) : __TPtrBase() {} - __VoidPtr(TADDR addr) : __TPtrBase(addr) {} - __VoidPtr(std::nullptr_t) : __TPtrBase(nullptr) {} + using __TPtrBase::__TPtrBase; // Note, unlike __DPtr, this ctor form is not explicit. We allow implicit // conversions from any pointer type (just like for void*). From 4eba0c0850990e74598bbedcf5a224f8590e8051 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 11 Apr 2024 15:50:15 -0700 Subject: [PATCH 03/10] Consolidate code in the DACized pointer types and fix the nullptr/NULL problem with them --- src/coreclr/inc/daccess.h | 256 +++++++++++++++----------------------- 1 file changed, 97 insertions(+), 159 deletions(-) diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 2e591b55ec8198..30cb0ee76d3ba7 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -856,7 +856,7 @@ inline TADDR DacTAddrOffset( TADDR taBase, TSIZE_T dwIndex, TSIZE_T dwElementSiz class __TPtrBase { public: - __TPtrBase(void) + __TPtrBase() { // Make uninitialized pointers obvious. m_addr = (TADDR)-1; @@ -865,20 +865,44 @@ class __TPtrBase { m_addr = addr; } - __TPtrBase(std::nullptr_t) + + // We use this delayed check to avoid ambiguous overload issues with TADDR + // on platforms where NULL is defined as anything other than a uintptr_t constant + // or nullptr_t exactly. + // Without this, any valid "null pointer contstant" that is not directly either type + // will be implicitly convertible to both TADDR and std::nullptr_t, causing ambiguity. + // With this, this constructor (and all similarly declared operators) drop out of + // consideration when used with NULL (and not nullptr_t). + // With this workaround, we get identical behavior between the DAC and non-DAC builds for assigning NULL + // to DACized pointer types. + template::value>::type> + __TPtrBase(T) { m_addr = 0; } + __TPtrBase& operator=(TADDR addr) + { + m_addr = addr; + return *this; + } + + template::value>::type> + __TPtrBase& operator=(T) + { + m_addr = 0; + return *this; + } + bool operator!() const { return m_addr == 0; } - // We'd like to have an implicit conversion to bool here since the C++ - // standard says all pointer types are implicitly converted to bool. - // Unfortunately, that would cause ambiguous overload errors for uses - // of operator== and operator!=. Instead callers will have to compare - // directly against NULL. + + explicit operator bool() const + { + return m_addr != 0; + } bool operator==(TADDR addr) const { @@ -888,11 +912,15 @@ class __TPtrBase { return m_addr != addr; } - bool operator==(std::nullptr_t) const + + template::value>::type> + bool operator==(T) const { return m_addr == 0; } - bool operator!=(std::nullptr_t) const + + template::value>::type> + bool operator!=(T) const { return m_addr != 0; } @@ -931,70 +959,53 @@ class __TPtrBase // This has the common functionality between __DPtr and __ArrayDPtr. // The DPtrType type parameter is the actual derived type in use. This is necessary so that // inhereted functions preserve exact return types. -template +template class DPtrTemplate> class __DPtrBase : public __TPtrBase { public: typedef type _Type; typedef type* _Ptr; + using DPtrType = DPtrTemplate; using __TPtrBase::__TPtrBase; - explicit __DPtrBase(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __DPtrBase(type const * host) + explicit __DPtrBase(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} + + // construct const from non-const + __DPtrBase(__DPtrBase::type, DPtrTemplate> const & rhs) : __DPtrBase(rhs.GetAddr()) {} + + explicit __DPtrBase(type const * host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } public: + using __TPtrBase::operator=; + DPtrType& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return DPtrType(m_addr); } - DPtrType& operator=(TADDR addr) - { - m_addr = addr; - return DPtrType(m_addr); - } - DPtrType& operator=(std::nullptr_t) - { - m_addr = 0; - return DPtrType(m_addr); - } type& operator*(void) const { return *(type*)DacInstantiateTypeByAddress(m_addr, sizeof(type), true); } + using __TPtrBase::operator==; + using __TPtrBase::operator!=; + bool operator==(const DPtrType& ptr) const { return m_addr == ptr.GetAddr(); } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator==(std::nullptr_t) const - { - return m_addr == 0; - } + bool operator!=(const DPtrType& ptr) const { return !operator==(ptr); } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator!=(std::nullptr_t) const - { - return m_addr != 0; - } + bool operator<(const DPtrType& ptr) const { return m_addr < ptr.GetAddr(); @@ -1197,18 +1208,14 @@ class __GlobalPtr; // Pointer wrapper for objects which are just plain data // and need no special handling. template -class __DPtr : public __DPtrBase > +class __DPtr : public __DPtrBase { public: - using __DPtrBase>::__DPtrBase; - - // construct const from non-const - typedef typename std::remove_const::type mutable_type; - __DPtr(__DPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} + using __DPtrBase::__DPtrBase; // construct from GlobalPtr - explicit __DPtr(__GlobalPtr< type*, __DPtr< type > > globalPtr) : - __DPtrBase >(globalPtr.GetAddr()) {} + explicit __DPtr(__GlobalPtr< type*, __DPtr< type > > globalPtr) : + __DPtrBase(globalPtr.GetAddr()) {} operator type*() const { @@ -1231,17 +1238,14 @@ class __DPtr : public __DPtrBase > // If you really must marshal a single instance (eg. converting T* to PTR_T is too painful for now), // then use code:DacUnsafeMarshalSingleElement so we can identify such unsafe code. template -class __ArrayDPtr : public __DPtrBase > +class __ArrayDPtr : public __DPtrBase { public: - using __DPtrBase>::__DPtrBase; - - // construct const from non-const - typedef typename std::remove_const::type mutable_type; - __ArrayDPtr(__ArrayDPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} + using __DPtrBase::__DPtrBase; - // Note that there is also no explicit constructor from host instances (type*). + // We delete the base type's constructor from host pointer. // Going this direction is less problematic, but often still represents risky coding. + explicit __ArrayDPtr(type const * host) = delete; }; #define ArrayDPTR(type) __ArrayDPtr< type > @@ -1260,30 +1264,20 @@ class __SPtr : public __TPtrBase using __TPtrBase::__TPtrBase; - explicit __SPtr(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __SPtr(type* host) + explicit __SPtr(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} + + explicit __SPtr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } - __SPtr< type >& operator=(const __TPtrBase& ptr) + using __TPtrBase::operator=; + + __SPtr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __SPtr< type >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - __SPtr< type >& operator=(std::nullptr_t) - { - m_addr = 0; - return *this; - } operator type*() const { @@ -1357,30 +1351,20 @@ class __VPtr : public __TPtrBase using __TPtrBase::__TPtrBase; - explicit __VPtr< type >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __VPtr< type >(type* host) + explicit __VPtr(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} + + explicit __VPtr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } - __VPtr< type >& operator=(const __TPtrBase& ptr) + using __TPtrBase::operator=; + + __VPtr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __VPtr< type >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - __VPtr< type >& operator=(std::nullptr_t) - { - m_addr = 0; - return *this; - } operator type*() const { @@ -1391,30 +1375,18 @@ class __VPtr : public __TPtrBase return (type*)DacInstantiateClassByVTable(m_addr, sizeof(type), true); } - bool operator==(const __VPtr< type >& ptr) const + using __TPtrBase::operator==; + using __TPtrBase::operator!=; + + bool operator==(const __VPtr& ptr) const { return m_addr == ptr.m_addr; } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator==(std::nullptr_t) const - { - return m_addr == 0; - } - bool operator!=(const __VPtr< type >& ptr) const + + bool operator!=(const __VPtr& ptr) const { return !operator==(ptr); } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator!=(std::nullptr_t) const - { - return m_addr != 0; - } bool IsValid(void) const { @@ -1442,25 +1414,18 @@ class __Str8Ptr : public __DPtr using __DPtr::__DPtr; - explicit __Str8Ptr(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __Str8Ptr(type* host) + explicit __Str8Ptr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } - __Str8Ptr< type, maxChars >& operator=(const __TPtrBase& ptr) + using __TPtrBase::operator=; + + __Str8Ptr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __Str8Ptr< type, maxChars >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } operator type*() const { @@ -1493,27 +1458,20 @@ class __Str16Ptr : public __DPtr typedef type _Type; typedef type* _Ptr; - __Str16Ptr(void) : __DPtr() {} - __Str16Ptr(TADDR addr) : __DPtr(addr) {} - explicit __Str16Ptr< type, maxChars >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __Str16Ptr< type, maxChars >(type* host) + using __DPtr::__DPtr; + + explicit __Str16Ptr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); } - __Str16Ptr& operator=(const __TPtrBase& ptr) + using __TPtrBase::operator=; + + __Str16Ptr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __Str16Ptr& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } operator type*() const { @@ -1542,7 +1500,7 @@ template class __GlobalVal { public: - __GlobalVal< type >(TADDR DacGlobals::* ptr) + __GlobalVal(TADDR DacGlobals::* ptr) { m_ptr = ptr; } @@ -1588,7 +1546,7 @@ template class __GlobalArray { public: - __GlobalArray(TADDR DacGlobals::* ptr) + __GlobalArray(TADDR DacGlobals::* ptr) { m_ptr = ptr; } @@ -1622,7 +1580,7 @@ class __GlobalPtr { using DPtr = __DPtr; public: - __GlobalPtr(TADDR DacGlobals::* ptr) + __GlobalPtr(TADDR DacGlobals::* ptr) { m_ptr = ptr; } @@ -1792,51 +1750,31 @@ class __VoidPtr : public __TPtrBase // Note, unlike __DPtr, any pointer type can be assigned to a __VoidPtr // This is to mirror the assignability of any pointer type to a void* + using __TPtrBase::operator=; + __VoidPtr& operator=(const __TPtrBase& ptr) { m_addr = ptr.GetAddr(); return *this; } - __VoidPtr& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - __VoidPtr& operator=(std::nullptr_t) - { - m_addr = 0; - return *this; - } // note, no marshalling operators (type* conversion, operator ->, operator*) // A void* can't be marshalled because we don't know how much to copy // PTR_Void can be compared to any other pointer type (because conceptually, // any other pointer type should be implicitly convertible to void*) + + using __TPtrBase::operator==; + using __TPtrBase::operator!=; + bool operator==(const __TPtrBase& ptr) const { return m_addr == ptr.GetAddr(); } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator==(std::nullptr_t) const - { - return m_addr == 0; - } bool operator!=(const __TPtrBase& ptr) const { return !operator==(ptr); } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator!=(std::nullptr_t) const - { - return m_addr != 0; - } bool operator<(const __TPtrBase& ptr) const { return m_addr < ptr.GetAddr(); From 2f7c5a96d8d454b46c530ea72804c46bf4878194 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 11 Apr 2024 16:13:37 -0700 Subject: [PATCH 04/10] Define nullptr helpers for our checked objref types like our dacized ptr types --- src/coreclr/vm/vars.hpp | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index 51533187c8b656..5beb4ae7151e2e 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -163,6 +163,26 @@ class OBJECTREF { //------------------------------------------------------------- OBJECTREF& operator=(const OBJECTREF &objref); OBJECTREF& operator=(TADDR nul); + + // We use this delayed check to avoid ambiguous overload issues with TADDR + // on platforms where NULL is defined as anything other than a uintptr_t constant + // or nullptr_t exactly. + // Without this, any valid "null pointer contstant" that is not directly either type + // will be implicitly convertible to both TADDR and std::nullptr_t, causing ambiguity. + // With this, this constructor (and all similarly declared operators) drop out of + // consideration when used with NULL (and not nullptr_t). + // With this workaround, we get identical behavior between the Checked OBJECTREF builds + // and the release builds. + template::value>::type> + OBJECTREF(T) + : OBJECTREF(TADDR(0)) + { + } + template::value>::type> + OBJECTREF& operator=(T) + { + return *this = TADDR(0); + } // allow explicit casts explicit OBJECTREF(Object *pObject); @@ -183,17 +203,7 @@ template class REF : public OBJECTREF { public: - - //------------------------------------------------------------- - // Default constructor, for non-initializing declarations: - // - // OBJECTREF or; - //------------------------------------------------------------- - REF() :OBJECTREF () - { - LIMITED_METHOD_CONTRACT; - // no op - } + using OBJECTREF::OBJECTREF; //------------------------------------------------------------- // Copy constructor, for passing OBJECTREF's as function arguments. @@ -204,16 +214,6 @@ class REF : public OBJECTREF //no op } - - //------------------------------------------------------------- - // To allow NULL to be used as an OBJECTREF. - //------------------------------------------------------------- - REF(TADDR nul) : OBJECTREF (nul) - { - LIMITED_METHOD_CONTRACT; - // no op - } - explicit REF(T* pObject) : OBJECTREF(pObject) { LIMITED_METHOD_CONTRACT; From 9c2e7cb796711d021f56f9aa4edfe9714749f667 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 11 Apr 2024 16:20:29 -0700 Subject: [PATCH 05/10] Fixes for the glibc-based build --- src/coreclr/utilcode/loaderheap.cpp | 12 ++++++------ src/coreclr/vm/object.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/utilcode/loaderheap.cpp b/src/coreclr/utilcode/loaderheap.cpp index 95cd7d16e17631..252f7afb237e90 100644 --- a/src/coreclr/utilcode/loaderheap.cpp +++ b/src/coreclr/utilcode/loaderheap.cpp @@ -78,7 +78,7 @@ void RangeList::InitBlock(RangeListBlock *b) while (r < rEnd) r++->id = (TADDR)NULL; - b->next = nullptr; + b->next = NULL; } BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) @@ -92,7 +92,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) } CONTRACTL_END - _ASSERTE(id != (TADDR)NULL); + _ASSERTE(id != NULL); RangeListBlock *b = m_firstEmptyBlock; Range *r = b->ranges + m_firstEmptyRange; @@ -123,7 +123,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) // new one. // - if (b->next == nullptr) + if (b->next == NULL) { RangeListBlock *newBlock = new (nothrow) RangeListBlock; @@ -136,7 +136,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id) InitBlock(newBlock); - newBlock->next = nullptr; + newBlock->next = NULL; b->next = newBlock; } @@ -204,7 +204,7 @@ void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end) // If there are no more blocks, we're done. // - if (b->next == nullptr) + if (b->next == NULL) { m_firstEmptyRange = 0; m_firstEmptyBlock = &m_starterBlock; @@ -266,7 +266,7 @@ BOOL RangeList::IsInRangeWorker(TADDR address, TADDR *pID /* = NULL */) // If there are no more blocks, we're done. // - if (b->next == nullptr) + if (b->next == NULL) return FALSE; // diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index 8e4d11cebdf525..17803b62521e7c 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -2455,7 +2455,7 @@ class Nullable { static BOOL UnBox(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static BOOL UnBoxNoGC(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static void UnBoxNoCheck(void* dest, OBJECTREF boxedVal, MethodTable* destMT); - static OBJECTREF BoxedNullableNull(TypeHandle nullableType) { return nullptr; } + static OBJECTREF BoxedNullableNull(TypeHandle nullableType) { return NULL; } // if 'Obj' is a true boxed nullable, return the form we want (either null or a boxed T) static OBJECTREF NormalizeBox(OBJECTREF obj); From 138eefbc1981670ef6f371e803b33917d08d4e37 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 11 Apr 2024 16:32:45 -0700 Subject: [PATCH 06/10] Convert some of the 0s back to NULLs --- src/coreclr/binder/assemblybindercommon.cpp | 2 +- src/coreclr/binder/customassemblybinder.cpp | 8 ++++---- src/coreclr/binder/defaultassemblybinder.cpp | 6 +++--- src/coreclr/classlibnative/bcltype/arraynative.cpp | 2 +- src/coreclr/debug/daccess/dacimpl.h | 2 +- src/coreclr/debug/di/process.cpp | 2 +- src/coreclr/debug/ee/controller.cpp | 4 ++-- src/coreclr/debug/ee/debugger.h | 8 ++++---- src/coreclr/debug/ee/debugger.inl | 2 +- src/coreclr/debug/ee/functioninfo.cpp | 2 +- src/coreclr/debug/inc/dbgipcevents.h | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/coreclr/binder/assemblybindercommon.cpp b/src/coreclr/binder/assemblybindercommon.cpp index c58b502ec417de..e1de7af70677e0 100644 --- a/src/coreclr/binder/assemblybindercommon.cpp +++ b/src/coreclr/binder/assemblybindercommon.cpp @@ -1297,7 +1297,7 @@ HRESULT AssemblyBinderCommon::CreateDefaultBinder(DefaultAssemblyBinder** ppDefa hr = pApplicationContext->Init(); if (SUCCEEDED(hr)) { - pBinder->SetManagedAssemblyLoadContext((TADDR)0); + pBinder->SetManagedAssemblyLoadContext((INT_PTR)NULL); *ppDefaultBinder = pBinder.Extract(); } } diff --git a/src/coreclr/binder/customassemblybinder.cpp b/src/coreclr/binder/customassemblybinder.cpp index dd0014043ad224..99297c2bd9ce31 100644 --- a/src/coreclr/binder/customassemblybinder.cpp +++ b/src/coreclr/binder/customassemblybinder.cpp @@ -242,13 +242,13 @@ void CustomAssemblyBinder::PrepareForLoadContextRelease(INT_PTR ptrManagedStrong CustomAssemblyBinder::CustomAssemblyBinder() { m_pDefaultBinder = NULL; - m_ptrManagedStrongAssemblyLoadContext = 0; + m_ptrManagedStrongAssemblyLoadContext = (INT_PTR)NULL; } void CustomAssemblyBinder::ReleaseLoadContext() { - VERIFY(GetManagedAssemblyLoadContext() != 0); - VERIFY(m_ptrManagedStrongAssemblyLoadContext != 0); + VERIFY(GetManagedAssemblyLoadContext() != (INT_PTR)NULL); + VERIFY(m_ptrManagedStrongAssemblyLoadContext != (INT_PTR)NULL); // This method is called to release the weak and strong handles on the managed AssemblyLoadContext // once the Unloading event has been fired @@ -256,7 +256,7 @@ void CustomAssemblyBinder::ReleaseLoadContext() DestroyLongWeakHandle(handle); handle = reinterpret_cast(m_ptrManagedStrongAssemblyLoadContext); DestroyHandle(handle); - SetManagedAssemblyLoadContext(0); + SetManagedAssemblyLoadContext((INT_PTR)NULL); // The AssemblyLoaderAllocator is in a process of shutdown and should not be used // after this point. diff --git a/src/coreclr/binder/defaultassemblybinder.cpp b/src/coreclr/binder/defaultassemblybinder.cpp index f0296f4a03b83b..54a70e51f05ece 100644 --- a/src/coreclr/binder/defaultassemblybinder.cpp +++ b/src/coreclr/binder/defaultassemblybinder.cpp @@ -63,7 +63,7 @@ HRESULT DefaultAssemblyBinder::BindUsingAssemblyName(BINDER_SPACE::AssemblyName // Attempt to resolve the assembly via managed ALC instance. This can either fail the bind or return reference to an existing // assembly that has been loaded INT_PTR pManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(); - if (pManagedAssemblyLoadContext == 0) + if (pManagedAssemblyLoadContext == (INT_PTR)NULL) { // For satellite assemblies, the managed ALC has additional resolution logic (defined by the runtime) which // should be run even if the managed default ALC has not yet been used. (For non-satellite assemblies, any @@ -78,11 +78,11 @@ HRESULT DefaultAssemblyBinder::BindUsingAssemblyName(BINDER_SPACE::AssemblyName CALL_MANAGED_METHOD_NORET(args) pManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(); - _ASSERTE(pManagedAssemblyLoadContext != 0); + _ASSERTE(pManagedAssemblyLoadContext != (INT_PTR)NULL); } } - if (pManagedAssemblyLoadContext != 0) + if (pManagedAssemblyLoadContext != (INT_PTR)NULL) { hr = AssemblyBinderCommon::BindUsingHostAssemblyResolver(pManagedAssemblyLoadContext, pAssemblyName, NULL, this, &pCoreCLRFoundAssembly); diff --git a/src/coreclr/classlibnative/bcltype/arraynative.cpp b/src/coreclr/classlibnative/bcltype/arraynative.cpp index 6b6bb6ff5d32f1..02ff0360ac4b7d 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.cpp +++ b/src/coreclr/classlibnative/bcltype/arraynative.cpp @@ -32,7 +32,7 @@ extern "C" PCODE QCALLTYPE Array_GetElementConstructorEntrypoint(QCall::TypeHand { QCALL_CONTRACT; - PCODE ctorEntrypoint = (PCODE)0; + PCODE ctorEntrypoint = (PCODE)NULL; BEGIN_QCALL; diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index 751229f450a75a..e698eed4c1803b 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -519,7 +519,7 @@ struct ProcessModIter { m_nextDomain = false; - if (AppDomain::GetCurrentDomain() == (PTR_AppDomain)nullptr) + if (AppDomain::GetCurrentDomain() == nullptr) { return NULL; } diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index f785c5e11d53b5..9920ed2dce0146 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -14913,7 +14913,7 @@ HRESULT CordbProcess::GetReferenceValueFromGCHandle( EX_TRY { - if (gcHandle == 0) + if (gcHandle == (UINT_PTR)0) { ThrowHR(CORDBG_E_BAD_REFERENCE_VALUE); } diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index ea00d18a923e25..fc7626a26f0fbc 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -770,7 +770,7 @@ DebuggerControllerPatch *DebuggerPatchTable::GetNextPatch(DebuggerControllerPatc #ifdef _DEBUG void DebuggerPatchTable::CheckPatchTable() { - if (0 != m_pcEntries) + if ((TADDR)NULL != m_pcEntries) { LOG((LF_CORDB,LL_INFO1000, "DPT:CPT: %u\n", m_iEntries)); DebuggerControllerPatch *dcp; @@ -793,7 +793,7 @@ int DebuggerPatchTable::GetNumberOfPatches() { int total = 0; - if (0 != m_pcEntries) + if ((TADDR)NULL != m_pcEntries) { DebuggerControllerPatch *dcp; ULONG i = 0; diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h index 1e50dd8cc37a85..38bbb73d2932e4 100644 --- a/src/coreclr/debug/ee/debugger.h +++ b/src/coreclr/debug/ee/debugger.h @@ -1237,8 +1237,8 @@ class CodeRegionInfo { public: CodeRegionInfo() : - m_addrOfHotCode((PCODE)0), - m_addrOfColdCode((PCODE)0), + m_addrOfHotCode((PCODE)NULL), + m_addrOfColdCode((PCODE)NULL), m_sizeOfHotCode(0), m_sizeOfColdCode(0) { @@ -1273,7 +1273,7 @@ class CodeRegionInfo { LIMITED_METHOD_CONTRACT; - if (m_addrOfHotCode != 0) + if (m_addrOfHotCode != (PCODE)NULL) { if (offset < m_sizeOfHotCode) { @@ -1289,7 +1289,7 @@ class CodeRegionInfo } else { - return (PCODE)0; + return (PCODE)NULL; } } diff --git a/src/coreclr/debug/ee/debugger.inl b/src/coreclr/debug/ee/debugger.inl index a8a14caed17ae0..4a8ea12740f739 100644 --- a/src/coreclr/debug/ee/debugger.inl +++ b/src/coreclr/debug/ee/debugger.inl @@ -202,7 +202,7 @@ inline TADDR FuncEvalFrame::GetReturnAddressPtr() if (GetDebuggerEval()->m_evalDuringException) { - return (TADDR)0; + return (TADDR)NULL; } else { diff --git a/src/coreclr/debug/ee/functioninfo.cpp b/src/coreclr/debug/ee/functioninfo.cpp index 9cb28204dd1e7a..41a16ef763163e 100644 --- a/src/coreclr/debug/ee/functioninfo.cpp +++ b/src/coreclr/debug/ee/functioninfo.cpp @@ -253,7 +253,7 @@ DebuggerJitInfo::DebuggerJitInfo(DebuggerMethodInfo *minfo, NativeCodeVersion na m_encBreakpointsApplied(false), #endif //FEATURE_METADATA_UPDATER m_methodInfo(minfo), - m_addrOfCode(0), + m_addrOfCode((CORDB_ADDRESS)NULL), m_sizeOfCode(0), m_prevJitInfo(NULL), m_nextJitInfo(NULL), m_lastIL(0), m_sequenceMap(NULL), diff --git a/src/coreclr/debug/inc/dbgipcevents.h b/src/coreclr/debug/inc/dbgipcevents.h index 350edce62e2f0a..68f18192c24ab4 100644 --- a/src/coreclr/debug/inc/dbgipcevents.h +++ b/src/coreclr/debug/inc/dbgipcevents.h @@ -780,7 +780,7 @@ class MSLAYOUT VMPTR_Base #endif // _PREFAST_ VMPTR_This dummy; - dummy.m_addr = (TADDR)0; + dummy.m_addr = (TADDR)NULL; return dummy; #ifdef _PREFAST_ From 098dbaa6a16d8973c6f495c70214698ddb21d356 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 12 Apr 2024 11:51:19 -0700 Subject: [PATCH 07/10] Apply suggestions --- src/coreclr/vm/clrex.h | 2 +- src/coreclr/vm/codeversion.cpp | 2 +- src/coreclr/vm/custommarshalerinfo.cpp | 2 +- src/coreclr/vm/domainassembly.cpp | 4 ++-- src/coreclr/vm/exceptionhandling.h | 4 ++-- src/coreclr/vm/exinfo.cpp | 2 +- src/coreclr/vm/listlock.h | 2 +- src/coreclr/vm/multicorejit.h | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/vm/clrex.h b/src/coreclr/vm/clrex.h index fa0b64e9da6868..586798f397fab3 100644 --- a/src/coreclr/vm/clrex.h +++ b/src/coreclr/vm/clrex.h @@ -934,7 +934,7 @@ LONG CLRNoCatchHandler(EXCEPTION_POINTERS* pExceptionInfo, PVOID pv); // --------------------------------------------------------------------------- inline CLRException::CLRException() - : m_throwableHandle((OBJECTHANDLE)NULL) + : m_throwableHandle{} { LIMITED_METHOD_CONTRACT; } diff --git a/src/coreclr/vm/codeversion.cpp b/src/coreclr/vm/codeversion.cpp index 1e38f1647208a1..ea95e274419cef 100644 --- a/src/coreclr/vm/codeversion.cpp +++ b/src/coreclr/vm/codeversion.cpp @@ -60,7 +60,7 @@ NativeCodeVersionNode::NativeCodeVersionNode( PatchpointInfo* patchpointInfo, unsigned ilOffset) : - m_pNativeCode((PCODE)NULL), + m_pNativeCode{}, m_pMethodDesc(pMethodDesc), m_parentId(parentId), m_pNextMethodDescSibling(NULL), diff --git a/src/coreclr/vm/custommarshalerinfo.cpp b/src/coreclr/vm/custommarshalerinfo.cpp index d7955a95ade177..4245a8a4b82acd 100644 --- a/src/coreclr/vm/custommarshalerinfo.cpp +++ b/src/coreclr/vm/custommarshalerinfo.cpp @@ -25,7 +25,7 @@ CustomMarshalerInfo::CustomMarshalerInfo(LoaderAllocator *pLoaderAllocator, Type : m_NativeSize(0) , m_hndManagedType(hndManagedType) , m_pLoaderAllocator(pLoaderAllocator) -, m_hndCustomMarshaler(0) +, m_hndCustomMarshaler{} , m_pMarshalNativeToManagedMD(NULL) , m_pMarshalManagedToNativeMD(NULL) , m_pCleanUpNativeDataMD(NULL) diff --git a/src/coreclr/vm/domainassembly.cpp b/src/coreclr/vm/domainassembly.cpp index f81b67b6b584b7..0e86d312ae88a3 100644 --- a/src/coreclr/vm/domainassembly.cpp +++ b/src/coreclr/vm/domainassembly.cpp @@ -37,8 +37,8 @@ DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoader m_pLoaderAllocator(pLoaderAllocator), m_level(FILE_LOAD_CREATE), m_loading(TRUE), - m_hExposedModuleObject((LOADERHANDLE)NULL), - m_hExposedAssemblyObject((LOADERHANDLE)NULL), + m_hExposedModuleObject{}, + m_hExposedAssemblyObject{}, m_pError(NULL), m_bDisableActivationCheck(FALSE), m_fHostAssemblyPublished(FALSE), diff --git a/src/coreclr/vm/exceptionhandling.h b/src/coreclr/vm/exceptionhandling.h index 5ac4337759d466..3977587a76b9ff 100644 --- a/src/coreclr/vm/exceptionhandling.h +++ b/src/coreclr/vm/exceptionhandling.h @@ -132,7 +132,7 @@ struct ExceptionTrackerBase ExceptionTrackerBase(PTR_EXCEPTION_RECORD pExceptionRecord, PTR_CONTEXT pExceptionContext, PTR_ExceptionTrackerBase pPrevNestedInfo) : m_pPrevNestedInfo(pPrevNestedInfo), - m_hThrowable(0), + m_hThrowable{}, m_ptrs({pExceptionRecord, pExceptionContext}), m_fDeliveredFirstChanceNotification(FALSE), m_ExceptionCode((pExceptionRecord != PTR_NULL) ? pExceptionRecord->ExceptionCode : 0) @@ -265,7 +265,7 @@ class ExceptionTracker : public ExceptionTrackerBase PTR_CONTEXT pContextRecord) : ExceptionTrackerBase(pExceptionRecord, pContextRecord, PTR_NULL), m_pThread(GetThread()), - m_uCatchToCallPC(0), + m_uCatchToCallPC{}, m_pSkipToParentFunctionMD(NULL), // these members were added for resume frame processing m_pClauseForCatchToken(NULL) diff --git a/src/coreclr/vm/exinfo.cpp b/src/coreclr/vm/exinfo.cpp index 424af106e94423..49287d3957e9df 100644 --- a/src/coreclr/vm/exinfo.cpp +++ b/src/coreclr/vm/exinfo.cpp @@ -317,7 +317,7 @@ ExInfo::ExInfo(Thread *pThread, EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pEx m_kind(exceptionKind), m_passNumber(1), m_idxCurClause(0xffffffff), - m_notifyDebuggerSP(0), + m_notifyDebuggerSP{}, m_pFrame(pThread->GetFrame()), m_ClauseForCatch({}), #ifdef HOST_UNIX diff --git a/src/coreclr/vm/listlock.h b/src/coreclr/vm/listlock.h index 7c196d9e7d000c..c062c68fc087b0 100644 --- a/src/coreclr/vm/listlock.h +++ b/src/coreclr/vm/listlock.h @@ -65,7 +65,7 @@ class ListLockEntryBase m_pNext(NULL), m_dwRefCount(1), m_hrResultCode(S_FALSE), - m_hInitException((LOADERHANDLE)0), + m_hInitException{}, m_pLoaderAllocator(dac_cast(nullptr)) { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/multicorejit.h b/src/coreclr/vm/multicorejit.h index 48596470921aa2..37eea5782156c6 100644 --- a/src/coreclr/vm/multicorejit.h +++ b/src/coreclr/vm/multicorejit.h @@ -92,7 +92,7 @@ class MulticoreJitCodeInfo TADDR m_entryPointAndTierInfo; public: - MulticoreJitCodeInfo() : m_entryPointAndTierInfo(0) + MulticoreJitCodeInfo() : m_entryPointAndTierInfo{} { LIMITED_METHOD_CONTRACT; } From 8dd2b41176b74d5eedae03dd79bd5222ffbd3bd0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 12 Apr 2024 12:05:11 -0700 Subject: [PATCH 08/10] MSVC requires explicitly-defaulted default constructors when using delegating constructors. Also remove the explicit bool cast as it breaks comparisons against NULL with MSVC's definition. --- src/coreclr/inc/daccess.h | 25 +++++++++++++++++++++---- src/coreclr/vm/vars.hpp | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 30cb0ee76d3ba7..2ded8e1b4cdbbb 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -899,10 +899,11 @@ class __TPtrBase return m_addr == 0; } - explicit operator bool() const - { - return m_addr != 0; - } + // We'd like to have an explicit conversion to bool here since the C++ + // standard says all pointer types are implicitly converted to bool. + // Unfortunately, that would cause ambiguous overload errors for uses + // of operator== and operator!= with NULL on MSVC (where NULL is a 32-bit int on all platforms). + // Instead callers will have to compare directly against NULL. bool operator==(TADDR addr) const { @@ -969,6 +970,8 @@ class __DPtrBase : public __TPtrBase using __TPtrBase::__TPtrBase; + __DPtrBase() = default; + explicit __DPtrBase(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} // construct const from non-const @@ -1213,6 +1216,8 @@ class __DPtr : public __DPtrBase public: using __DPtrBase::__DPtrBase; + __DPtr() = default; + // construct from GlobalPtr explicit __DPtr(__GlobalPtr< type*, __DPtr< type > > globalPtr) : __DPtrBase(globalPtr.GetAddr()) {} @@ -1243,6 +1248,8 @@ class __ArrayDPtr : public __DPtrBase public: using __DPtrBase::__DPtrBase; + __ArrayDPtr() = default; + // We delete the base type's constructor from host pointer. // Going this direction is less problematic, but often still represents risky coding. explicit __ArrayDPtr(type const * host) = delete; @@ -1264,6 +1271,8 @@ class __SPtr : public __TPtrBase using __TPtrBase::__TPtrBase; + __SPtr() = default; + explicit __SPtr(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} explicit __SPtr(type* host) @@ -1351,6 +1360,8 @@ class __VPtr : public __TPtrBase using __TPtrBase::__TPtrBase; + __VPtr() = default; + explicit __VPtr(__TPtrBase ptr) : __TPtrBase(ptr.GetAddr()) {} explicit __VPtr(type* host) @@ -1414,6 +1425,8 @@ class __Str8Ptr : public __DPtr using __DPtr::__DPtr; + __Str8Ptr() = default; + explicit __Str8Ptr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); @@ -1460,6 +1473,8 @@ class __Str16Ptr : public __DPtr using __DPtr::__DPtr; + __Str16Ptr() = default; + explicit __Str16Ptr(type* host) { m_addr = DacGetTargetAddrForHostAddr(host, true); @@ -1726,6 +1741,8 @@ class __VoidPtr : public __TPtrBase public: using __TPtrBase::__TPtrBase; + __VoidPtr() = default; + // Note, unlike __DPtr, this ctor form is not explicit. We allow implicit // conversions from any pointer type (just like for void*). __VoidPtr(__TPtrBase addr) diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index 5beb4ae7151e2e..d4c0f36d6ae349 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -203,6 +203,7 @@ template class REF : public OBJECTREF { public: + REF() = default; using OBJECTREF::OBJECTREF; //------------------------------------------------------------- From c26d61deafc3d5f9e9d7263081eab28f2ef77bb1 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 12 Apr 2024 12:05:57 -0700 Subject: [PATCH 09/10] Fix typo in comment about NULL pattern --- src/coreclr/inc/daccess.h | 2 +- src/coreclr/vm/vars.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 2ded8e1b4cdbbb..1525f22d615bbd 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -869,7 +869,7 @@ class __TPtrBase // We use this delayed check to avoid ambiguous overload issues with TADDR // on platforms where NULL is defined as anything other than a uintptr_t constant // or nullptr_t exactly. - // Without this, any valid "null pointer contstant" that is not directly either type + // Without this, any valid "null pointer constant" that is not directly either type // will be implicitly convertible to both TADDR and std::nullptr_t, causing ambiguity. // With this, this constructor (and all similarly declared operators) drop out of // consideration when used with NULL (and not nullptr_t). diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index d4c0f36d6ae349..5de1df5da60565 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -167,7 +167,7 @@ class OBJECTREF { // We use this delayed check to avoid ambiguous overload issues with TADDR // on platforms where NULL is defined as anything other than a uintptr_t constant // or nullptr_t exactly. - // Without this, any valid "null pointer contstant" that is not directly either type + // Without this, any valid "null pointer constant" that is not directly either type // will be implicitly convertible to both TADDR and std::nullptr_t, causing ambiguity. // With this, this constructor (and all similarly declared operators) drop out of // consideration when used with NULL (and not nullptr_t). From 506c922ae82d24a80a3eee2deb1b660e7672d905 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 12 Apr 2024 14:15:13 -0700 Subject: [PATCH 10/10] Fix cast --- src/coreclr/inc/daccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 1525f22d615bbd..dc9b02daa1cda8 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -1229,7 +1229,7 @@ class __DPtr : public __DPtrBase type* operator->() const { - return (type*)this; + return (type*)(*this); } };