mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:40:07 +00:00
[vm] Fix zero-as-null-pointer-constant warnings in the VM.
Unfortunately we cannot enable -Wzero-as-null-pointer-constant because of zlib and icu headers we include. TEST=build Change-Id: I9ffd7d7e26f2b3dd616ce54d164b92e60a2366dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293882 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
parent
956bb9ac57
commit
1eae028526
|
@ -112,7 +112,7 @@ MappedMemory* File::Map(MapType type,
|
|||
void MappedMemory::Unmap() {
|
||||
int result = munmap(address_, size_);
|
||||
ASSERT(result == 0);
|
||||
address_ = 0;
|
||||
address_ = nullptr;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ MappedMemory* File::Map(MapType type,
|
|||
void MappedMemory::Unmap() {
|
||||
int result = munmap(address_, size_);
|
||||
ASSERT(result == 0);
|
||||
address_ = 0;
|
||||
address_ = nullptr;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ MappedMemory* File::Map(MapType type,
|
|||
void MappedMemory::Unmap() {
|
||||
int result = munmap(address_, size_);
|
||||
ASSERT(result == 0);
|
||||
address_ = 0;
|
||||
address_ = nullptr;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ MappedMemory* File::Map(MapType type,
|
|||
void MappedMemory::Unmap() {
|
||||
int result = munmap(address_, size_);
|
||||
ASSERT(result == 0);
|
||||
address_ = 0;
|
||||
address_ = nullptr;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ MappedMemory* File::Map(File::MapType type,
|
|||
void MappedMemory::Unmap() {
|
||||
BOOL result = VirtualFree(address_, 0, MEM_RELEASE);
|
||||
ASSERT(result);
|
||||
address_ = 0;
|
||||
address_ = nullptr;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ void Decompress(const uint8_t* input,
|
|||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
strm.avail_in = 0;
|
||||
strm.next_in = 0;
|
||||
strm.next_in = Z_NULL;
|
||||
int ret = inflateInit2(&strm, 32 + MAX_WBITS);
|
||||
ASSERT(ret == Z_OK);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ bool Platform::Initialize() {
|
|||
// handler error EPIPE is set instead.
|
||||
struct sigaction act = {};
|
||||
act.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &act, 0) != 0) {
|
||||
if (sigaction(SIGPIPE, &act, nullptr) != 0) {
|
||||
perror("Setting signal handler failed");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ bool Platform::Initialize() {
|
|||
// handler error EPIPE is set instead.
|
||||
struct sigaction act = {};
|
||||
act.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &act, 0) != 0) {
|
||||
if (sigaction(SIGPIPE, &act, nullptr) != 0) {
|
||||
perror("Setting signal handler failed");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ bool Platform::Initialize() {
|
|||
// handler error EPIPE is set instead.
|
||||
struct sigaction act = {};
|
||||
act.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &act, 0) != 0) {
|
||||
if (sigaction(SIGPIPE, &act, nullptr) != 0) {
|
||||
perror("Setting signal handler failed");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class SocketAddress {
|
|||
// unix(7) require sun_path to be 108 bytes on Linux and Android, 104 bytes on
|
||||
// Mac OS.
|
||||
static const intptr_t kMaxUnixPathLength =
|
||||
sizeof(((struct sockaddr_un*)0)->sun_path);
|
||||
sizeof(((struct sockaddr_un*)nullptr)->sun_path);
|
||||
char as_string_[kMaxUnixPathLength];
|
||||
#else
|
||||
char as_string_[INET6_ADDRSTRLEN];
|
||||
|
|
|
@ -251,13 +251,13 @@ AddressList<SocketAddress>* SocketBase::LookupAddress(const char* host,
|
|||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
struct addrinfo* info = NULL;
|
||||
int status = getaddrinfo(host, 0, &hints, &info);
|
||||
struct addrinfo* info = nullptr;
|
||||
int status = getaddrinfo(host, nullptr, &hints, &info);
|
||||
if (status != 0) {
|
||||
// We failed, try without AI_ADDRCONFIG. This can happen when looking up
|
||||
// e.g. '::1', when there are no IPv6 addresses.
|
||||
hints.ai_flags = 0;
|
||||
status = getaddrinfo(host, 0, &hints, &info);
|
||||
status = getaddrinfo(host, nullptr, &hints, &info);
|
||||
if (status != 0) {
|
||||
ASSERT(*os_error == NULL);
|
||||
*os_error =
|
||||
|
|
|
@ -261,13 +261,13 @@ AddressList<SocketAddress>* SocketBase::LookupAddress(const char* host,
|
|||
hints.ai_protocol = IPPROTO_TCP;
|
||||
struct addrinfo* info = NULL;
|
||||
LOG_INFO("SocketBase::LookupAddress: calling getaddrinfo\n");
|
||||
int status = NO_RETRY_EXPECTED(getaddrinfo(host, 0, &hints, &info));
|
||||
int status = NO_RETRY_EXPECTED(getaddrinfo(host, nullptr, &hints, &info));
|
||||
if (status != 0) {
|
||||
// We failed, try without AI_ADDRCONFIG. This can happen when looking up
|
||||
// e.g. '::1', when there are no global IPv6 addresses.
|
||||
hints.ai_flags = 0;
|
||||
LOG_INFO("SocketBase::LookupAddress: calling getaddrinfo again\n");
|
||||
status = NO_RETRY_EXPECTED(getaddrinfo(host, 0, &hints, &info));
|
||||
status = NO_RETRY_EXPECTED(getaddrinfo(host, nullptr, &hints, &info));
|
||||
if (status != 0) {
|
||||
ASSERT(*os_error == NULL);
|
||||
*os_error =
|
||||
|
|
|
@ -63,13 +63,13 @@ AddressList<SocketAddress>* SocketBase::LookupAddress(const char* host,
|
|||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
struct addrinfo* info = NULL;
|
||||
int status = NO_RETRY_EXPECTED(getaddrinfo(host, 0, &hints, &info));
|
||||
struct addrinfo* info = nullptr;
|
||||
int status = NO_RETRY_EXPECTED(getaddrinfo(host, nullptr, &hints, &info));
|
||||
if (status != 0) {
|
||||
// We failed, try without AI_ADDRCONFIG. This can happen when looking up
|
||||
// e.g. '::1', when there are no global IPv6 addresses.
|
||||
hints.ai_flags = 0;
|
||||
status = NO_RETRY_EXPECTED(getaddrinfo(host, 0, &hints, &info));
|
||||
status = NO_RETRY_EXPECTED(getaddrinfo(host, nullptr, &hints, &info));
|
||||
if (status != 0) {
|
||||
ASSERT(*os_error == NULL);
|
||||
*os_error =
|
||||
|
|
|
@ -60,8 +60,8 @@ AddressList<SocketAddress>* SocketBase::LookupAddress(const char* host,
|
|||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
struct addrinfo* info = NULL;
|
||||
int status = getaddrinfo(host, 0, &hints, &info);
|
||||
struct addrinfo* info = nullptr;
|
||||
int status = getaddrinfo(host, nullptr, &hints, &info);
|
||||
if (status != 0) {
|
||||
ASSERT(*os_error == NULL);
|
||||
*os_error =
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" void __asan_unpoison_memory_region(void*, size_t);
|
|||
#define NO_SANITIZE_ADDRESS
|
||||
#define ASAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#endif // defined(USING_ADDRESS_SANITIZER)
|
||||
|
||||
#endif // RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_
|
||||
|
|
|
@ -23,10 +23,10 @@ extern "C" void __lsan_unregister_root_region(const void* p, size_t size);
|
|||
#else // defined(USING_LEAK_SANITIZER)
|
||||
#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#endif // defined(USING_LEAK_SANITIZER)
|
||||
|
||||
#endif // RUNTIME_PLATFORM_LEAK_SANITIZER_H_
|
||||
|
|
|
@ -28,13 +28,13 @@ extern "C" void __msan_check_mem_is_initialized(const volatile void*, size_t);
|
|||
#else // defined(USING_MEMORY_SANITIZER)
|
||||
#define MSAN_POISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#define MSAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#define MSAN_CHECK_INITIALIZED(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
} while (false && (ptr) == nullptr && (len) == 0)
|
||||
#endif // defined(USING_MEMORY_SANITIZER)
|
||||
|
||||
#endif // RUNTIME_PLATFORM_MEMORY_SANITIZER_H_
|
||||
|
|
|
@ -375,12 +375,12 @@ class EmbeddedArray<T, 0> {
|
|||
intptr_t length() const { return 0; }
|
||||
const T& operator[](intptr_t i) const {
|
||||
UNREACHABLE();
|
||||
static T sentinel = 0;
|
||||
static T sentinel = nullptr;
|
||||
return sentinel;
|
||||
}
|
||||
T& operator[](intptr_t i) {
|
||||
UNREACHABLE();
|
||||
static T sentinel = 0;
|
||||
static T sentinel = nullptr;
|
||||
return sentinel;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -184,7 +184,7 @@ class IlTestPrinter : public AllStatic {
|
|||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
static constexpr bool value = decltype(test<T>(nullptr))::value;
|
||||
};
|
||||
|
||||
class AttributesSerializer : public InstructionVisitor {
|
||||
|
@ -239,7 +239,7 @@ class IlTestPrinter : public AllStatic {
|
|||
template <typename T>
|
||||
void WriteDescriptor(
|
||||
const char* name,
|
||||
typename std::enable_if_t<HasGetAttributes<T>::value>* = 0) {
|
||||
typename std::enable_if_t<HasGetAttributes<T>::value>* = nullptr) {
|
||||
writer_->OpenArray(name);
|
||||
WriteTuple(T::GetAttributeNames());
|
||||
writer_->CloseArray();
|
||||
|
@ -248,7 +248,7 @@ class IlTestPrinter : public AllStatic {
|
|||
template <typename T>
|
||||
void WriteDescriptor(
|
||||
const char* name,
|
||||
typename std::enable_if_t<!HasGetAttributes<T>::value>* = 0) {}
|
||||
typename std::enable_if_t<!HasGetAttributes<T>::value>* = nullptr) {}
|
||||
|
||||
JSONWriter* writer_;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace dart {
|
||||
|
||||
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {};
|
||||
|
||||
void CpuInfo::Init() {
|
||||
// Initialize our read from /proc/cpuinfo.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace dart {
|
||||
|
||||
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {};
|
||||
|
||||
void CpuInfo::Init() {
|
||||
// TODO(zra): Add support for HOST_ARCH_ARM64
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace dart {
|
||||
|
||||
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {};
|
||||
|
||||
void CpuInfo::Init() {
|
||||
#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace dart {
|
||||
|
||||
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {};
|
||||
|
||||
void CpuInfo::Init() {
|
||||
method_ = kCpuInfoSystem;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace dart {
|
||||
|
||||
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
||||
const char* CpuInfo::fields_[kCpuInfoMax] = {};
|
||||
|
||||
void CpuInfo::Init() {
|
||||
method_ = kCpuInfoCpuId;
|
||||
|
|
|
@ -571,7 +571,7 @@ bool Api::StringGetPeerHelper(NativeArguments* arguments,
|
|||
if (cid == kOneByteStringCid || cid == kTwoByteStringCid) {
|
||||
auto isolate_group = arguments->thread()->isolate_group();
|
||||
*peer = isolate_group->heap()->GetPeer(raw_obj);
|
||||
return (*peer != 0);
|
||||
return (*peer != nullptr);
|
||||
}
|
||||
if (cid == kExternalTwoByteStringCid) {
|
||||
ExternalTwoByteStringPtr raw_string =
|
||||
|
@ -5347,7 +5347,7 @@ DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
|
|||
"an Error.",
|
||||
ret_obj.ToCString());
|
||||
}
|
||||
ASSERT(retval != 0);
|
||||
ASSERT(retval != nullptr);
|
||||
Api::SetReturnValue(arguments, retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -728,7 +728,7 @@ void GCCompactor::VisitTypedDataViewPointers(TypedDataViewPtr view,
|
|||
} else {
|
||||
// The backing store didn't move, we therefore don't need to update the
|
||||
// inner pointer.
|
||||
if (view->untag()->data_ == 0) {
|
||||
if (view->untag()->data_ == nullptr) {
|
||||
ASSERT(RawSmiValue(view->untag()->offset_in_bytes()) == 0 &&
|
||||
RawSmiValue(view->untag()->length()) == 0 &&
|
||||
view->untag()->typed_data() == Object::null());
|
||||
|
|
|
@ -357,7 +357,7 @@ FreeListElement* FreeList::TryAllocateLargeLocked(intptr_t minimum_size) {
|
|||
return current;
|
||||
} else if (tries_left-- < 0) {
|
||||
freelist_search_budget_ = kInitialFreeListSearchBudget;
|
||||
return 0; // Trigger allocation of new page.
|
||||
return nullptr; // Trigger allocation of new page.
|
||||
}
|
||||
previous = current;
|
||||
current = next;
|
||||
|
|
|
@ -15399,7 +15399,7 @@ const UntaggedCompressedStackMaps::Payload* InstructionsTable::FindStackMap(
|
|||
*start_pc = InstructionsTable::start_pc(table) + entries[idx].pc_offset;
|
||||
return rodata->StackMapAt(entries[idx].stack_map_offset);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CodePtr InstructionsTable::FindCode(InstructionsTablePtr table, uword pc) {
|
||||
|
|
|
@ -337,8 +337,8 @@ void InitializeExternalTypedDataWithSafepointChecks(
|
|||
|
||||
void InitializeTypedDataView(TypedDataViewPtr obj) {
|
||||
obj.untag()->typed_data_ = TypedDataBase::null();
|
||||
obj.untag()->offset_in_bytes_ = 0;
|
||||
obj.untag()->length_ = 0;
|
||||
obj.untag()->offset_in_bytes_ = Smi::New(0);
|
||||
obj.untag()->length_ = Smi::New(0);
|
||||
}
|
||||
|
||||
void FreeExternalTypedData(void* isolate_callback_data, void* buffer) {
|
||||
|
@ -1848,8 +1848,8 @@ class ObjectCopy : public Base {
|
|||
Base::StoreCompressedPointerNoBarrier(
|
||||
Types::GetTypedDataViewPtr(to),
|
||||
OFFSET_OF(UntaggedTypedDataView, typed_data_), Object::null());
|
||||
raw_to->length_ = 0;
|
||||
raw_to->offset_in_bytes_ = 0;
|
||||
raw_to->length_ = Smi::New(0);
|
||||
raw_to->offset_in_bytes_ = Smi::New(0);
|
||||
ASSERT(Base::exception_msg_ != nullptr);
|
||||
return;
|
||||
}
|
||||
|
@ -2109,7 +2109,8 @@ class FastObjectCopy : public ObjectCopy<FastObjectCopyBase> {
|
|||
// uses the information from the header and therefore might visit one slot
|
||||
// more than the actual size of the instance).
|
||||
*reinterpret_cast<ObjectPtr*>(UntaggedObject::ToAddr(to) +
|
||||
from.untag()->HeapSize() - kWordSize) = 0;
|
||||
from.untag()->HeapSize() - kWordSize) =
|
||||
nullptr;
|
||||
SetNewSpaceTaggingWord(to, cid, size);
|
||||
|
||||
// Fall back to virtual variant for predefined classes
|
||||
|
|
|
@ -986,10 +986,10 @@ class ProfilerDartStackWalker : public ProfilerStackWalker {
|
|||
}
|
||||
|
||||
uword* exit_fp = reinterpret_cast<uword*>(thread_->top_exit_frame_info());
|
||||
bool has_exit_frame = exit_fp != 0;
|
||||
bool has_exit_frame = exit_fp != nullptr;
|
||||
if (has_exit_frame) {
|
||||
// Exited from compiled code.
|
||||
pc_ = 0;
|
||||
pc_ = nullptr;
|
||||
fp_ = exit_fp;
|
||||
|
||||
// Skip exit frame.
|
||||
|
@ -1029,9 +1029,9 @@ class ProfilerDartStackWalker : public ProfilerStackWalker {
|
|||
for (;;) {
|
||||
// Skip entry frame.
|
||||
if (StubCode::InInvocationStub(reinterpret_cast<uword>(pc_))) {
|
||||
pc_ = 0;
|
||||
pc_ = nullptr;
|
||||
fp_ = ExitLink();
|
||||
if (fp_ == 0) {
|
||||
if (fp_ == nullptr) {
|
||||
break; // End of Dart stack.
|
||||
}
|
||||
|
||||
|
|
|
@ -3607,7 +3607,8 @@ void OnEveryRuntimeEntryCall(Thread* thread,
|
|||
if (IsolateGroup::IsSystemIsolateGroup(thread->isolate_group())) {
|
||||
return;
|
||||
}
|
||||
const bool is_deopt_related = strstr(runtime_call_name, "Deoptimize") != 0;
|
||||
const bool is_deopt_related =
|
||||
strstr(runtime_call_name, "Deoptimize") != nullptr;
|
||||
if (is_deopt_related) {
|
||||
return;
|
||||
}
|
||||
|
@ -3618,7 +3619,7 @@ void OnEveryRuntimeEntryCall(Thread* thread,
|
|||
(strlen(runtime_call_name) !=
|
||||
strlen(FLAG_deoptimize_on_runtime_call_name_filter) ||
|
||||
strstr(runtime_call_name,
|
||||
FLAG_deoptimize_on_runtime_call_name_filter) == 0)) {
|
||||
FLAG_deoptimize_on_runtime_call_name_filter) == nullptr)) {
|
||||
return;
|
||||
}
|
||||
const uint32_t count = thread->IncrementAndGetRuntimeCallCount();
|
||||
|
|
|
@ -36,8 +36,8 @@ VirtualMemory* VirtualMemory::ForImagePage(void* pointer, uword size) {
|
|||
// Memory for precompilated instructions was allocated by the embedder, so
|
||||
// create a VirtualMemory without allocating.
|
||||
MemoryRegion region(pointer, size);
|
||||
MemoryRegion reserved(0, 0); // nullptr reservation indicates VM should not
|
||||
// attempt to free this memory.
|
||||
MemoryRegion reserved(nullptr, 0); // null reservation indicates VM should
|
||||
// not attempt to free this memory.
|
||||
VirtualMemory* memory = new VirtualMemory(region, region, reserved);
|
||||
ASSERT(!memory->vm_owns_region());
|
||||
return memory;
|
||||
|
|
Loading…
Reference in a new issue