Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp
index e4c32fa..4a19fe1 100644
--- a/benchmarks/bionic_benchmarks.cpp
+++ b/benchmarks/bionic_benchmarks.cpp
@@ -78,12 +78,12 @@
static struct option g_long_options[] =
{
- {"bionic_cpu", required_argument, 0, 'c'},
- {"bionic_xml", required_argument, 0, 'x'},
- {"bionic_iterations", required_argument, 0, 'i'},
- {"bionic_extra", required_argument, 0, 'a'},
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0},
+ {"bionic_cpu", required_argument, nullptr, 'c'},
+ {"bionic_xml", required_argument, nullptr, 'x'},
+ {"bionic_iterations", required_argument, nullptr, 'i'},
+ {"bionic_extra", required_argument, nullptr, 'a'},
+ {"help", no_argument, nullptr, 'h'},
+ {nullptr, 0, nullptr, 0},
};
typedef std::vector<std::vector<int64_t>> args_vector_t;
@@ -100,7 +100,7 @@
int fake_argc = 2;
char argv0[] = "bionic_benchmarks";
char argv1[] = "--help";
- char* fake_argv[3] {argv0, argv1, NULL};
+ char* fake_argv[3] {argv0, argv1, nullptr};
benchmark::Initialize(&fake_argc, fake_argv);
exit(1);
}
@@ -132,7 +132,7 @@
}
}
}
- new_argv->push_back(0);
+ new_argv->push_back(nullptr);
}
bench_opts_t ParseOpts(int argc, char** argv) {
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 17e37b0..9251a05 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -163,7 +163,7 @@
size_t i = 0;
while (state.KeepRunning()) {
- pa.system_properties().Read(pinfo[i], 0, propvalue);
+ pa.system_properties().Read(pinfo[i], nullptr, propvalue);
i = (i + 1) % nprops;
}
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index c72736e..09654c8 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -31,7 +31,7 @@
static void BM_pthread_getspecific(benchmark::State& state) {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, nullptr);
while (state.KeepRunning()) {
pthread_getspecific(key);
@@ -43,10 +43,10 @@
static void BM_pthread_setspecific(benchmark::State& state) {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, nullptr);
while (state.KeepRunning()) {
- pthread_setspecific(key, NULL);
+ pthread_setspecific(key, nullptr);
}
pthread_key_delete(key);
@@ -147,7 +147,7 @@
static void BM_pthread_rwlock_read(benchmark::State& state) {
pthread_rwlock_t lock;
- pthread_rwlock_init(&lock, NULL);
+ pthread_rwlock_init(&lock, nullptr);
while (state.KeepRunning()) {
pthread_rwlock_rdlock(&lock);
@@ -160,7 +160,7 @@
static void BM_pthread_rwlock_write(benchmark::State& state) {
pthread_rwlock_t lock;
- pthread_rwlock_init(&lock, NULL);
+ pthread_rwlock_init(&lock, nullptr);
while (state.KeepRunning()) {
pthread_rwlock_wrlock(&lock);
@@ -172,42 +172,42 @@
BIONIC_BENCHMARK(BM_pthread_rwlock_write);
static void* IdleThread(void*) {
- return NULL;
+ return nullptr;
}
static void BM_pthread_create(benchmark::State& state) {
while (state.KeepRunning()) {
pthread_t thread;
- pthread_create(&thread, NULL, IdleThread, NULL);
+ pthread_create(&thread, nullptr, IdleThread, nullptr);
state.PauseTiming();
- pthread_join(thread, NULL);
+ pthread_join(thread, nullptr);
state.ResumeTiming();
}
}
BIONIC_BENCHMARK(BM_pthread_create);
static void* RunThread(void*) {
- return NULL;
+ return nullptr;
}
static void BM_pthread_create_and_run(benchmark::State& state) {
while (state.KeepRunning()) {
pthread_t thread;
- pthread_create(&thread, NULL, RunThread, &state);
- pthread_join(thread, NULL);
+ pthread_create(&thread, nullptr, RunThread, &state);
+ pthread_join(thread, nullptr);
}
}
BIONIC_BENCHMARK(BM_pthread_create_and_run);
static void* ExitThread(void*) {
- pthread_exit(NULL);
+ pthread_exit(nullptr);
}
static void BM_pthread_exit_and_join(benchmark::State& state) {
while (state.KeepRunning()) {
pthread_t thread;
- pthread_create(&thread, NULL, ExitThread, nullptr);
- pthread_join(thread, NULL);
+ pthread_create(&thread, nullptr, ExitThread, nullptr);
+ pthread_join(thread, nullptr);
}
}
BIONIC_BENCHMARK(BM_pthread_exit_and_join);
@@ -215,7 +215,7 @@
static void BM_pthread_key_create(benchmark::State& state) {
while (state.KeepRunning()) {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, nullptr);
state.PauseTiming();
pthread_key_delete(key);
@@ -228,7 +228,7 @@
while (state.KeepRunning()) {
state.PauseTiming();
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, nullptr);
state.ResumeTiming();
pthread_key_delete(key);
diff --git a/benchmarks/semaphore_benchmark.cpp b/benchmarks/semaphore_benchmark.cpp
index a4aa7bb..ba89137 100644
--- a/benchmarks/semaphore_benchmark.cpp
+++ b/benchmarks/semaphore_benchmark.cpp
@@ -75,7 +75,7 @@
while ((BM_semaphore_sem_post_running > 0) && !sem_wait(semaphore)) {
}
BM_semaphore_sem_post_running = -1;
- return NULL;
+ return nullptr;
}
class SemaphoreFixture : public benchmark::Fixture {
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index 9c81e0f..21d9dc0 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -43,7 +43,7 @@
char* buf = new char[chunk_size];
if (!buffered) {
- setvbuf(fp, 0, _IONBF, 0);
+ setvbuf(fp, nullptr, _IONBF, 0);
}
while (state.KeepRunning()) {
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 24773de..880bc1d 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -111,7 +111,7 @@
wchar_t wc = 0;
while (state.KeepRunning()) {
- for (j = 0; buf_aligned[j]; j+=mbrtowc(&wc, buf_aligned + j, 4, NULL)) {
+ for (j = 0; buf_aligned[j]; j+=mbrtowc(&wc, buf_aligned + j, 4, nullptr)) {
}
}