Replace NULL macros with nullptr literals.
Change-Id: Id2311cda59dd42c74b3ed54d3ff6cfd509012738
diff --git a/lib/ExecutionEngine/ELFObjectLoaderImpl.cpp b/lib/ExecutionEngine/ELFObjectLoaderImpl.cpp
index 8797ce1..867b7ab 100644
--- a/lib/ExecutionEngine/ELFObjectLoaderImpl.cpp
+++ b/lib/ExecutionEngine/ELFObjectLoaderImpl.cpp
@@ -38,7 +38,7 @@
#else
mObject = ELFObject<32>::read(reader);
#endif
- if (mObject == NULL) {
+ if (mObject == nullptr) {
ALOGE("Unable to load the ELF object!");
return false;
}
@@ -51,7 +51,7 @@
mSymTab = static_cast<ELFSectionSymTab<32> *>(
mObject->getSectionByName(".symtab"));
#endif
- if (mSymTab == NULL) {
+ if (mSymTab == nullptr) {
ALOGW("Object doesn't contain any symbol table.");
}
@@ -125,7 +125,7 @@
ELFSectionBits<32> *section =
static_cast<ELFSectionBits<32> *>(mObject->getSectionByIndex(i));
#endif
- if (section != NULL) {
+ if (section != nullptr) {
uintptr_t address = reinterpret_cast<uintptr_t>(section->getBuffer());
#ifdef __LP64__
LOG_FATAL_IF(address > 0xFFFFFFFFFFFFFFFFu, "Out of bound address for Elf64_Addr");
@@ -142,8 +142,8 @@
}
void *ELFObjectLoaderImpl::getSymbolAddress(const char *pName) const {
- if (mSymTab == NULL) {
- return NULL;
+ if (mSymTab == nullptr) {
+ return nullptr;
}
#ifdef __LP64__
@@ -151,9 +151,9 @@
#else
const ELFSymbol<32> *symbol = mSymTab->getByName(pName);
#endif
- if (symbol == NULL) {
+ if (symbol == nullptr) {
ALOGV("Request symbol '%s' is not found in the object!", pName);
- return NULL;
+ return nullptr;
}
return symbol->getAddress(mObject->getHeader()->getMachine(),
@@ -161,7 +161,7 @@
}
size_t ELFObjectLoaderImpl::getSymbolSize(const char *pName) const {
- if (mSymTab == NULL) {
+ if (mSymTab == nullptr) {
return 0;
}
@@ -171,7 +171,7 @@
const ELFSymbol<32> *symbol = mSymTab->getByName(pName);
#endif
- if (symbol == NULL) {
+ if (symbol == nullptr) {
ALOGV("Request symbol '%s' is not found in the object!", pName);
return 0;
}
@@ -183,7 +183,7 @@
bool
ELFObjectLoaderImpl::getSymbolNameList(std::vector<const char *>& pNameList,
ObjectLoader::SymbolType pType) const {
- if (mSymTab == NULL) {
+ if (mSymTab == nullptr) {
return false;
}
@@ -208,14 +208,14 @@
#else
ELFSymbol<32> *symbol = (*mSymTab)[i];
#endif
- if (symbol == NULL) {
+ if (symbol == nullptr) {
continue;
}
if ((pType == ObjectLoader::kUnknownType) ||
(symbol->getType() == elf_type)) {
const char *symbol_name = symbol->getName();
- if (symbol_name != NULL) {
+ if (symbol_name != nullptr) {
pNameList.push_back(symbol_name);
}
}
diff --git a/lib/ExecutionEngine/ELFObjectLoaderImpl.h b/lib/ExecutionEngine/ELFObjectLoaderImpl.h
index 8734558..1490bcb 100644
--- a/lib/ExecutionEngine/ELFObjectLoaderImpl.h
+++ b/lib/ExecutionEngine/ELFObjectLoaderImpl.h
@@ -40,7 +40,7 @@
#endif
public:
- ELFObjectLoaderImpl() : ObjectLoaderImpl(), mObject(NULL), mSymTab(NULL) { }
+ ELFObjectLoaderImpl() : ObjectLoaderImpl(), mObject(nullptr), mSymTab(nullptr) { }
virtual bool load(const void *pMem, size_t pMemSize);
diff --git a/lib/ExecutionEngine/GDBJITRegistrar.cpp b/lib/ExecutionEngine/GDBJITRegistrar.cpp
index 68d6833..3afc984 100644
--- a/lib/ExecutionEngine/GDBJITRegistrar.cpp
+++ b/lib/ExecutionEngine/GDBJITRegistrar.cpp
@@ -116,10 +116,10 @@
__jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
// Insert this entry at the head of the list.
- JITCodeEntry->prev_entry = NULL;
+ JITCodeEntry->prev_entry = nullptr;
jit_code_entry* NextEntry = __jit_debug_descriptor.first_entry;
JITCodeEntry->next_entry = NextEntry;
- if (NextEntry != NULL) {
+ if (NextEntry != nullptr) {
NextEntry->prev_entry = JITCodeEntry;
}
__jit_debug_descriptor.first_entry = JITCodeEntry;
@@ -128,13 +128,13 @@
}
GDBJITRegistrar* RegistrarSingleton() {
- static GDBJITRegistrar* sRegistrar = NULL;
- if (sRegistrar == NULL) {
+ static GDBJITRegistrar* sRegistrar = nullptr;
+ if (sRegistrar == nullptr) {
// The mutex is here so that it won't slow down access once the registrar
// is instantiated
llvm::MutexGuard locked(JITDebugLock);
// Check again to be sure another thread didn't create this while we waited
- if (sRegistrar == NULL) {
+ if (sRegistrar == nullptr) {
sRegistrar = new GDBJITRegistrar;
}
}
@@ -225,7 +225,7 @@
}
delete JITCodeEntry;
- JITCodeEntry = NULL;
+ JITCodeEntry = nullptr;
}
} // end namespace
diff --git a/lib/ExecutionEngine/ObjectLoader.cpp b/lib/ExecutionEngine/ObjectLoader.cpp
index 79209d3..bb9a205 100644
--- a/lib/ExecutionEngine/ObjectLoader.cpp
+++ b/lib/ExecutionEngine/ObjectLoader.cpp
@@ -30,10 +30,10 @@
const char *pName,
SymbolResolverInterface &pResolver,
bool pEnableGDBDebug) {
- ObjectLoader *result = NULL;
+ ObjectLoader *result = nullptr;
// Check parameters.
- if ((pMemStart == NULL) || (pMemSize <= 0)) {
+ if ((pMemStart == nullptr) || (pMemSize <= 0)) {
ALOGE("Invalid memory '%s' was given to load (memory addr: %p, size: %u)",
pName, pMemStart, static_cast<unsigned>(pMemSize));
goto bail;
@@ -41,7 +41,7 @@
// Create result object
result = new (std::nothrow) ObjectLoader();
- if (result == NULL) {
+ if (result == nullptr) {
ALOGE("Out of memory when create object loader for %s!", pName);
goto bail;
}
@@ -50,7 +50,7 @@
// to detect the object file type and to select the one appropriated. Directly
// try out the ELF object loader.
result->mImpl = new (std::nothrow) ELFObjectLoaderImpl();
- if (result->mImpl == NULL) {
+ if (result->mImpl == nullptr) {
ALOGE("Out of memory when create ELF object loader for %s", pName);
goto bail;
}
@@ -79,7 +79,7 @@
// section lives in the process image. Therefore, a writable memory with its
// contents initialized to the contents of pFile is created.
result->mDebugImage = new (std::nothrow) uint8_t [ pMemSize ];
- if (result->mDebugImage != NULL) {
+ if (result->mDebugImage != nullptr) {
::memcpy(result->mDebugImage, pMemStart, pMemSize);
if (!result->mImpl->prepareDebugImage(result->mDebugImage, pMemSize)) {
ALOGW("GDB debug for %s is enabled by the user but won't work due to "
@@ -96,22 +96,22 @@
bail:
delete result;
- return NULL;
+ return nullptr;
}
ObjectLoader *ObjectLoader::Load(FileBase &pFile,
SymbolResolverInterface &pResolver,
bool pEnableGDBDebug) {
size_t file_size;
- android::FileMap *file_map = NULL;
+ android::FileMap *file_map = nullptr;
const char *input_filename = pFile.getName().c_str();
- ObjectLoader *result = NULL;
+ ObjectLoader *result = nullptr;
// Check the inputs.
if (pFile.hasError()) {
ALOGE("Input file %s to the object loader is in the invalid state! (%s)",
input_filename, pFile.getErrorMessage().c_str());
- return NULL;
+ return nullptr;
}
// Get the file size.
@@ -119,21 +119,21 @@
if (pFile.hasError()) {
ALOGE("Failed to get size of file %s! (%s)", input_filename,
pFile.getErrorMessage().c_str());
- return NULL;
+ return nullptr;
}
// Abort on empty file.
if (file_size <= 0) {
ALOGE("Empty file %s to the object loader.", input_filename);
- return NULL;
+ return nullptr;
}
// Create memory map for the input file.
file_map = pFile.createMap(0, file_size, /* pIsReadOnly */true);
- if ((file_map == NULL) || pFile.hasError()) {
+ if ((file_map == nullptr) || pFile.hasError()) {
ALOGE("Failed to map the file %s to the memory! (%s)", input_filename,
pFile.getErrorMessage().c_str());
- return NULL;
+ return nullptr;
}
// Delegate the load request.
diff --git a/lib/ExecutionEngine/SymbolResolverProxy.cpp b/lib/ExecutionEngine/SymbolResolverProxy.cpp
index 8a9073c..7644d59 100644
--- a/lib/ExecutionEngine/SymbolResolverProxy.cpp
+++ b/lib/ExecutionEngine/SymbolResolverProxy.cpp
@@ -22,13 +22,13 @@
// Search the address of the symbol by following the chain of resolvers.
for (auto resolver : mChain) {
void *addr = resolver->getAddress(pName);
- if (addr != NULL) {
+ if (addr != nullptr) {
return addr;
}
}
// Symbol not found or there's no resolver containing in the chain.
- return NULL;
+ return nullptr;
}
void SymbolResolverProxy::chainResolver(SymbolResolverInterface &pResolver) {
diff --git a/lib/ExecutionEngine/SymbolResolvers.cpp b/lib/ExecutionEngine/SymbolResolvers.cpp
index 4194a6b..1112ee2 100644
--- a/lib/ExecutionEngine/SymbolResolvers.cpp
+++ b/lib/ExecutionEngine/SymbolResolvers.cpp
@@ -21,7 +21,7 @@
#else
/* TODO hack: definitions from bionic/libc/include/dlfcn.h */
void* dlopen(const char* filename, int flag) {
- return NULL;
+ return nullptr;
}
int dlclose(void* handle) {
@@ -33,7 +33,7 @@
}
void* dlsym(void* handle, const char* symbol) {
- return NULL;
+ return nullptr;
}
#define RTLD_NOW 0
@@ -54,7 +54,7 @@
// DyldSymbolResolver
//===----------------------------------------------------------------------===//
DyldSymbolResolver::DyldSymbolResolver(const char *pFileName,
- bool pLazyBinding) : mError(NULL) {
+ bool pLazyBinding) : mError(nullptr) {
int flags = (pLazyBinding) ? RTLD_LAZY : RTLD_NOW;
// Make the symbol within the given library to be local such that it won't
@@ -62,34 +62,34 @@
flags |= RTLD_LOCAL;
mHandle = ::dlopen(pFileName, flags);
- if (mHandle == NULL) {
+ if (mHandle == nullptr) {
const char *err = ::dlerror();
#define DYLD_ERROR_MSG_PATTERN "Failed to load %s! (%s)"
size_t error_length = ::strlen(DYLD_ERROR_MSG_PATTERN) +
::strlen(pFileName) + 1;
- if (err != NULL) {
+ if (err != nullptr) {
error_length += ::strlen(err);
}
mError = new (std::nothrow) char [error_length];
- if (mError != NULL) {
+ if (mError != nullptr) {
::snprintf(mError, error_length, DYLD_ERROR_MSG_PATTERN, pFileName,
- ((err != NULL) ? err : ""));
+ ((err != nullptr) ? err : ""));
}
}
#undef DYLD_ERROR_MSG_PATTERN
}
void *DyldSymbolResolver::getAddress(const char *pName) {
- assert((mHandle != NULL) && "Invalid DyldSymbolResolver!");
+ assert((mHandle != nullptr) && "Invalid DyldSymbolResolver!");
return ::dlsym(mHandle, pName);
}
DyldSymbolResolver::~DyldSymbolResolver() {
- if (mHandle != NULL) {
+ if (mHandle != nullptr) {
::dlclose(mHandle);
- mHandle = NULL;
+ mHandle = nullptr;
}
delete [] mError;
}