Replace NULL with nullptr
Also fixed some lines that were too long, and a few other minor
details.
Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 03a47a3..0589cdd 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -57,7 +57,7 @@
const uint8_t DexFile::kDexMagicVersion[] = { '0', '3', '5', '\0' };
static int OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* error_msg) {
- CHECK(magic != NULL);
+ CHECK(magic != nullptr);
ScopedFd fd(open(filename, O_RDONLY, 0));
if (fd.get() == -1) {
*error_msg = StringPrintf("Unable to open '%s' : %s", filename, strerror(errno));
@@ -77,7 +77,7 @@
}
bool DexFile::GetChecksum(const char* filename, uint32_t* checksum, std::string* error_msg) {
- CHECK(checksum != NULL);
+ CHECK(checksum != nullptr);
uint32_t magic;
// Strip ":...", which is the location
@@ -98,14 +98,15 @@
return false;
}
if (IsZipMagic(magic)) {
- std::unique_ptr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(fd.release(), filename, error_msg));
- if (zip_archive.get() == NULL) {
+ std::unique_ptr<ZipArchive> zip_archive(
+ ZipArchive::OpenFromFd(fd.release(), filename, error_msg));
+ if (zip_archive.get() == nullptr) {
*error_msg = StringPrintf("Failed to open zip archive '%s' (error msg: %s)", file_part,
error_msg->c_str());
return false;
}
std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(zip_entry_name, error_msg));
- if (zip_entry.get() == NULL) {
+ if (zip_entry.get() == nullptr) {
*error_msg = StringPrintf("Zip archive '%s' doesn't contain %s (error msg: %s)", file_part,
zip_entry_name, error_msg->c_str());
return false;
@@ -114,8 +115,9 @@
return true;
}
if (IsDexMagic(magic)) {
- std::unique_ptr<const DexFile> dex_file(DexFile::OpenFile(fd.release(), filename, false, error_msg));
- if (dex_file.get() == NULL) {
+ std::unique_ptr<const DexFile> dex_file(
+ DexFile::OpenFile(fd.release(), filename, false, error_msg));
+ if (dex_file.get() == nullptr) {
return false;
}
*checksum = dex_file->GetHeader().checksum_;
@@ -127,7 +129,7 @@
bool DexFile::Open(const char* filename, const char* location, std::string* error_msg,
std::vector<std::unique_ptr<const DexFile>>* dex_files) {
- DCHECK(dex_files != nullptr) << "DexFile::Open: out-param is NULL";
+ DCHECK(dex_files != nullptr) << "DexFile::Open: out-param is nullptr";
uint32_t magic;
ScopedFd fd(OpenAndReadMagic(filename, &magic, error_msg));
if (fd.get() == -1) {
@@ -152,7 +154,7 @@
}
int DexFile::GetPermissions() const {
- if (mem_map_.get() == NULL) {
+ if (mem_map_.get() == nullptr) {
return 0;
} else {
return mem_map_->GetProtect();
@@ -165,7 +167,7 @@
bool DexFile::EnableWrite() const {
CHECK(IsReadOnly());
- if (mem_map_.get() == NULL) {
+ if (mem_map_.get() == nullptr) {
return false;
} else {
return mem_map_->Protect(PROT_READ | PROT_WRITE);
@@ -174,7 +176,7 @@
bool DexFile::DisableWrite() const {
CHECK(!IsReadOnly());
- if (mem_map_.get() == NULL) {
+ if (mem_map_.get() == nullptr) {
return false;
} else {
return mem_map_->Protect(PROT_READ);
@@ -233,7 +235,7 @@
bool DexFile::OpenZip(int fd, const std::string& location, std::string* error_msg,
std::vector<std::unique_ptr<const DexFile>>* dex_files) {
- DCHECK(dex_files != nullptr) << "DexFile::OpenZip: out-param is NULL";
+ DCHECK(dex_files != nullptr) << "DexFile::OpenZip: out-param is nullptr";
std::unique_ptr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(fd, location.c_str(), error_msg));
if (zip_archive.get() == nullptr) {
DCHECK(!error_msg->empty());
@@ -260,12 +262,12 @@
ZipOpenErrorCode* error_code) {
CHECK(!location.empty());
std::unique_ptr<ZipEntry> zip_entry(zip_archive.Find(entry_name, error_msg));
- if (zip_entry.get() == NULL) {
+ if (zip_entry.get() == nullptr) {
*error_code = ZipOpenErrorCode::kEntryNotFound;
return nullptr;
}
std::unique_ptr<MemMap> map(zip_entry->ExtractToMemMap(location.c_str(), entry_name, error_msg));
- if (map.get() == NULL) {
+ if (map.get() == nullptr) {
*error_msg = StringPrintf("Failed to extract '%s' from '%s': %s", entry_name, location.c_str(),
error_msg->c_str());
*error_code = ZipOpenErrorCode::kExtractToMemoryError;
@@ -297,7 +299,7 @@
bool DexFile::OpenFromZip(const ZipArchive& zip_archive, const std::string& location,
std::string* error_msg,
std::vector<std::unique_ptr<const DexFile>>* dex_files) {
- DCHECK(dex_files != nullptr) << "DexFile::OpenFromZip: out-param is NULL";
+ DCHECK(dex_files != nullptr) << "DexFile::OpenFromZip: out-param is nullptr";
ZipOpenErrorCode error_code;
std::unique_ptr<const DexFile> dex_file(Open(zip_archive, kClassesDex, location, error_msg,
&error_code));
@@ -371,7 +373,7 @@
find_class_def_misses_(0),
class_def_index_(nullptr),
oat_dex_file_(oat_dex_file) {
- CHECK(begin_ != NULL) << GetLocation();
+ CHECK(begin_ != nullptr) << GetLocation();
CHECK_GT(size_, 0U) << GetLocation();
}
@@ -487,7 +489,7 @@
return &class_def;
}
}
- return NULL;
+ return nullptr;
}
const DexFile::FieldId* DexFile::FindFieldId(const DexFile::TypeId& declaring_klass,
@@ -522,7 +524,7 @@
}
}
}
- return NULL;
+ return nullptr;
}
const DexFile::MethodId* DexFile::FindMethodId(const DexFile::TypeId& declaring_klass,
@@ -557,7 +559,7 @@
}
}
}
- return NULL;
+ return nullptr;
}
const DexFile::StringId* DexFile::FindStringId(const char* string) const {
@@ -576,7 +578,7 @@
return &str_id;
}
}
- return NULL;
+ return nullptr;
}
const DexFile::StringId* DexFile::FindStringId(const uint16_t* string, size_t length) const {
@@ -595,7 +597,7 @@
return &str_id;
}
}
- return NULL;
+ return nullptr;
}
const DexFile::TypeId* DexFile::FindTypeId(uint32_t string_idx) const {
@@ -612,7 +614,7 @@
return &type_id;
}
}
- return NULL;
+ return nullptr;
}
const DexFile::ProtoId* DexFile::FindProtoId(uint16_t return_type_idx,
@@ -648,7 +650,7 @@
return &proto;
}
}
- return NULL;
+ return nullptr;
}
// Given a signature place the type ids into the given vector
@@ -687,11 +689,11 @@
// TODO: avoid creating a std::string just to get a 0-terminated char array
std::string descriptor(signature.data() + start_offset, offset - start_offset);
const DexFile::StringId* string_id = FindStringId(descriptor.c_str());
- if (string_id == NULL) {
+ if (string_id == nullptr) {
return false;
}
const DexFile::TypeId* type_id = FindTypeId(GetIndexForStringId(*string_id));
- if (type_id == NULL) {
+ if (type_id == nullptr) {
return false;
}
uint16_t type_idx = GetIndexForTypeId(*type_id);
@@ -713,7 +715,7 @@
return Signature::NoSignature();
}
const ProtoId* proto_id = FindProtoId(return_type_idx, param_type_indices);
- if (proto_id == NULL) {
+ if (proto_id == nullptr) {
return Signature::NoSignature();
}
return Signature(this, *proto_id);
@@ -727,12 +729,12 @@
}
const CodeItem* code_item = GetCodeItem(method->GetCodeItemOffset());
- DCHECK(code_item != NULL) << PrettyMethod(method) << " " << GetLocation();
+ DCHECK(code_item != nullptr) << PrettyMethod(method) << " " << GetLocation();
// A method with no line number info should return -1
LineNumFromPcContext context(rel_pc, -1);
DecodeDebugInfo(code_item, method->IsStatic(), method->GetDexMethodIndex(), LineNumForPcCb,
- NULL, &context);
+ nullptr, &context);
return context.line_num_;
}
@@ -771,19 +773,20 @@
void DexFile::DecodeDebugInfo0(const CodeItem* code_item, bool is_static, uint32_t method_idx,
DexDebugNewPositionCb position_cb, DexDebugNewLocalCb local_cb,
- void* context, const uint8_t* stream, LocalInfo* local_in_reg) const {
+ void* context, const uint8_t* stream, LocalInfo* local_in_reg)
+ const {
uint32_t line = DecodeUnsignedLeb128(&stream);
uint32_t parameters_size = DecodeUnsignedLeb128(&stream);
uint16_t arg_reg = code_item->registers_size_ - code_item->ins_size_;
uint32_t address = 0;
- bool need_locals = (local_cb != NULL);
+ bool need_locals = (local_cb != nullptr);
if (!is_static) {
if (need_locals) {
const char* descriptor = GetMethodDeclaringClassDescriptor(GetMethodId(method_idx));
local_in_reg[arg_reg].name_ = "this";
local_in_reg[arg_reg].descriptor_ = descriptor;
- local_in_reg[arg_reg].signature_ = NULL;
+ local_in_reg[arg_reg].signature_ = nullptr;
local_in_reg[arg_reg].start_address_ = 0;
local_in_reg[arg_reg].is_live_ = true;
}
@@ -803,7 +806,7 @@
const char* name = StringDataByIdx(id);
local_in_reg[arg_reg].name_ = name;
local_in_reg[arg_reg].descriptor_ = descriptor;
- local_in_reg[arg_reg].signature_ = NULL;
+ local_in_reg[arg_reg].signature_ = nullptr;
local_in_reg[arg_reg].start_address_ = address;
local_in_reg[arg_reg].is_live_ = true;
}
@@ -895,7 +898,7 @@
}
if (need_locals) {
- if (local_in_reg[reg].name_ == NULL || local_in_reg[reg].descriptor_ == NULL) {
+ if (local_in_reg[reg].name_ == nullptr || local_in_reg[reg].descriptor_ == nullptr) {
LOG(ERROR) << "invalid stream - no name or descriptor in " << GetLocation();
return;
}
@@ -920,7 +923,7 @@
address += adjopcode / DBG_LINE_RANGE;
line += DBG_LINE_BASE + (adjopcode % DBG_LINE_RANGE);
- if (position_cb != NULL) {
+ if (position_cb != nullptr) {
if (position_cb(context, address, line)) {
// early exit
return;
@@ -937,14 +940,16 @@
void* context) const {
DCHECK(code_item != nullptr);
const uint8_t* stream = GetDebugInfoStream(code_item);
- std::unique_ptr<LocalInfo[]> local_in_reg(local_cb != NULL ?
+ std::unique_ptr<LocalInfo[]> local_in_reg(local_cb != nullptr ?
new LocalInfo[code_item->registers_size_] :
- NULL);
- if (stream != NULL) {
- DecodeDebugInfo0(code_item, is_static, method_idx, position_cb, local_cb, context, stream, &local_in_reg[0]);
+ nullptr);
+ if (stream != nullptr) {
+ DecodeDebugInfo0(code_item, is_static, method_idx, position_cb, local_cb, context, stream,
+ &local_in_reg[0]);
}
for (int reg = 0; reg < code_item->registers_size_; reg++) {
- InvokeLocalCbIfLive(context, reg, code_item->insns_size_in_code_units_, &local_in_reg[0], local_cb);
+ InvokeLocalCbIfLive(context, reg, code_item->insns_size_in_code_units_, &local_in_reg[0],
+ local_cb);
}
}
@@ -1051,7 +1056,7 @@
// Decodes the header section from the class data bytes.
void ClassDataItemIterator::ReadClassDataHeader() {
- CHECK(ptr_pos_ != NULL);
+ CHECK(ptr_pos_ != nullptr);
header_.static_fields_size_ = DecodeUnsignedLeb128(&ptr_pos_);
header_.instance_fields_size_ = DecodeUnsignedLeb128(&ptr_pos_);
header_.direct_methods_size_ = DecodeUnsignedLeb128(&ptr_pos_);
@@ -1129,17 +1134,16 @@
return val;
}
-EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(const DexFile& dex_file,
- Handle<mirror::DexCache>* dex_cache,
- Handle<mirror::ClassLoader>* class_loader,
- ClassLinker* linker,
- const DexFile::ClassDef& class_def)
+EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(
+ const DexFile& dex_file, Handle<mirror::DexCache>* dex_cache,
+ Handle<mirror::ClassLoader>* class_loader, ClassLinker* linker,
+ const DexFile::ClassDef& class_def)
: dex_file_(dex_file), dex_cache_(dex_cache), class_loader_(class_loader), linker_(linker),
array_size_(), pos_(-1), type_(kByte) {
DCHECK(dex_cache != nullptr);
DCHECK(class_loader != nullptr);
ptr_ = dex_file.GetEncodedStaticFieldValuesArray(class_def);
- if (ptr_ == NULL) {
+ if (ptr_ == nullptr) {
array_size_ = 0;
} else {
array_size_ = DecodeUnsignedLeb128(&ptr_);
@@ -1199,7 +1203,7 @@
UNIMPLEMENTED(FATAL) << ": type " << type_;
UNREACHABLE();
case kNull:
- jval_.l = NULL;
+ jval_.l = nullptr;
width = 0;
break;
default:
@@ -1212,7 +1216,8 @@
template<bool kTransactionActive>
void EncodedStaticFieldValueIterator::ReadValueToField(ArtField* field) const {
switch (type_) {
- case kBoolean: field->SetBoolean<kTransactionActive>(field->GetDeclaringClass(), jval_.z); break;
+ case kBoolean: field->SetBoolean<kTransactionActive>(field->GetDeclaringClass(), jval_.z);
+ break;
case kByte: field->SetByte<kTransactionActive>(field->GetDeclaringClass(), jval_.b); break;
case kShort: field->SetShort<kTransactionActive>(field->GetDeclaringClass(), jval_.s); break;
case kChar: field->SetChar<kTransactionActive>(field->GetDeclaringClass(), jval_.c); break;
@@ -1220,7 +1225,7 @@
case kLong: field->SetLong<kTransactionActive>(field->GetDeclaringClass(), jval_.j); break;
case kFloat: field->SetFloat<kTransactionActive>(field->GetDeclaringClass(), jval_.f); break;
case kDouble: field->SetDouble<kTransactionActive>(field->GetDeclaringClass(), jval_.d); break;
- case kNull: field->SetObject<kTransactionActive>(field->GetDeclaringClass(), NULL); break;
+ case kNull: field->SetObject<kTransactionActive>(field->GetDeclaringClass(), nullptr); break;
case kString: {
mirror::String* resolved = linker_->ResolveString(dex_file_, jval_.i, *dex_cache_);
field->SetObject<kTransactionActive>(field->GetDeclaringClass(), resolved);
@@ -1275,7 +1280,7 @@
Init(DexFile::GetCatchHandlerData(code_item, offset));
} else {
// Not found, initialize as empty
- current_data_ = NULL;
+ current_data_ = nullptr;
remaining_count_ = -1;
catch_all_ = false;
DCHECK(!HasNext());