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)) {
}
}
diff --git a/libc/async_safe/async_safe_log.cpp b/libc/async_safe/async_safe_log.cpp
index c6b8b53..5f22c74 100644
--- a/libc/async_safe/async_safe_log.cpp
+++ b/libc/async_safe/async_safe_log.cpp
@@ -333,7 +333,7 @@
if (c == 's') {
/* string */
str = va_arg(args, const char*);
- if (str == NULL) {
+ if (str == nullptr) {
str = "(null)";
}
} else if (c == 'c') {
diff --git a/libc/bionic/__cmsg_nxthdr.cpp b/libc/bionic/__cmsg_nxthdr.cpp
index f962788..354e17e 100644
--- a/libc/bionic/__cmsg_nxthdr.cpp
+++ b/libc/bionic/__cmsg_nxthdr.cpp
@@ -33,7 +33,7 @@
ptr = reinterpret_cast<cmsghdr*>(reinterpret_cast<char*>(cmsg) + CMSG_ALIGN(cmsg->cmsg_len));
size_t len = reinterpret_cast<char*>(ptr+1) - reinterpret_cast<char*>(msg->msg_control);
if (len > msg->msg_controllen) {
- return NULL;
+ return nullptr;
}
return ptr;
}
diff --git a/libc/bionic/__gnu_basename.cpp b/libc/bionic/__gnu_basename.cpp
index 1eb3f65..f9f87a6 100644
--- a/libc/bionic/__gnu_basename.cpp
+++ b/libc/bionic/__gnu_basename.cpp
@@ -31,5 +31,5 @@
extern "C" const char* __gnu_basename(const char* path) {
const char* last_slash = strrchr(path, '/');
- return (last_slash != NULL) ? last_slash + 1 : path;
+ return (last_slash != nullptr) ? last_slash + 1 : path;
}
diff --git a/libc/bionic/atof.cpp b/libc/bionic/atof.cpp
index e77ccdd..c17deab 100644
--- a/libc/bionic/atof.cpp
+++ b/libc/bionic/atof.cpp
@@ -31,5 +31,5 @@
double atof(const char* s) {
// Despite the 'f' in the name, this returns a double and is
// specified to be equivalent to strtod.
- return strtod(s, NULL);
+ return strtod(s, nullptr);
}
diff --git a/libc/bionic/brk.cpp b/libc/bionic/brk.cpp
index e1a4b05..566c33a 100644
--- a/libc/bionic/brk.cpp
+++ b/libc/bionic/brk.cpp
@@ -48,8 +48,8 @@
void* sbrk(ptrdiff_t increment) {
// Initialize __bionic_brk if necessary.
- if (__bionic_brk == NULL) {
- __bionic_brk = __brk(NULL);
+ if (__bionic_brk == nullptr) {
+ __bionic_brk = __brk(nullptr);
}
// Don't ask the kernel if we already know the answer.
diff --git a/libc/bionic/c16rtomb.cpp b/libc/bionic/c16rtomb.cpp
index 93749c6..2d6ae93 100644
--- a/libc/bionic/c16rtomb.cpp
+++ b/libc/bionic/c16rtomb.cpp
@@ -42,7 +42,7 @@
size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
if (mbsinit(state)) {
if (is_high_surrogate(c16)) {
char32_t c32 = (c16 & ~0xd800) << 10;
@@ -62,6 +62,6 @@
char32_t c32 = ((mbstate_get_byte(state, 3) << 16) |
(mbstate_get_byte(state, 2) << 8) |
(c16 & ~0xdc00)) + 0x10000;
- return mbstate_reset_and_return(c32rtomb(s, c32, NULL), state);
+ return mbstate_reset_and_return(c32rtomb(s, c32, nullptr), state);
}
}
diff --git a/libc/bionic/c32rtomb.cpp b/libc/bionic/c32rtomb.cpp
index ebe9cd3..2909d8b 100644
--- a/libc/bionic/c32rtomb.cpp
+++ b/libc/bionic/c32rtomb.cpp
@@ -34,9 +34,9 @@
size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
- if (s == NULL) {
+ if (s == nullptr) {
// Equivalent to c32rtomb(buf, U'\0', ps).
return mbstate_reset_and_return(1, state);
}
diff --git a/libc/bionic/clearenv.cpp b/libc/bionic/clearenv.cpp
index c70cc3e..01c9c39 100644
--- a/libc/bionic/clearenv.cpp
+++ b/libc/bionic/clearenv.cpp
@@ -31,9 +31,9 @@
int clearenv() {
char** e = environ;
- if (e != NULL) {
+ if (e != nullptr) {
for (; *e; ++e) {
- *e = NULL;
+ *e = nullptr;
}
}
return 0;
diff --git a/libc/bionic/dirent.cpp b/libc/bionic/dirent.cpp
index 153e56a..8921ca0 100644
--- a/libc/bionic/dirent.cpp
+++ b/libc/bionic/dirent.cpp
@@ -68,15 +68,15 @@
static DIR* __allocate_DIR(int fd) {
DIR* d = reinterpret_cast<DIR*>(malloc(sizeof(DIR)));
- if (d == NULL) {
- return NULL;
+ if (d == nullptr) {
+ return nullptr;
}
d->fd_ = fd;
android_fdsan_exchange_owner_tag(fd, 0, __get_dir_tag(d));
d->available_bytes_ = 0;
- d->next_ = NULL;
+ d->next_ = nullptr;
d->current_pos_ = 0L;
- pthread_mutex_init(&d->mutex_, NULL);
+ pthread_mutex_init(&d->mutex_, nullptr);
return d;
}
@@ -89,11 +89,11 @@
// Is 'fd' actually a directory?
struct stat sb;
if (fstat(fd, &sb) == -1) {
- return NULL;
+ return nullptr;
}
if (!S_ISDIR(sb.st_mode)) {
errno = ENOTDIR;
- return NULL;
+ return nullptr;
}
return __allocate_DIR(fd);
@@ -101,7 +101,7 @@
DIR* opendir(const char* path) {
int fd = open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY);
- return (fd != -1) ? __allocate_DIR(fd) : NULL;
+ return (fd != -1) ? __allocate_DIR(fd) : nullptr;
}
static bool __fill_DIR(DIR* d) {
@@ -117,7 +117,7 @@
static dirent* __readdir_locked(DIR* d) {
if (d->available_bytes_ == 0 && !__fill_DIR(d)) {
- return NULL;
+ return nullptr;
}
dirent* entry = d->next_;
@@ -141,17 +141,17 @@
ErrnoRestorer errno_restorer;
- *result = NULL;
+ *result = nullptr;
errno = 0;
ScopedPthreadMutexLocker locker(&d->mutex_);
dirent* next = __readdir_locked(d);
- if (errno != 0 && next == NULL) {
+ if (errno != 0 && next == nullptr) {
return errno;
}
- if (next != NULL) {
+ if (next != nullptr) {
memcpy(entry, next, next->d_reclen);
*result = entry;
}
@@ -160,7 +160,7 @@
__strong_alias(readdir64_r, readdir_r);
int closedir(DIR* d) {
- if (d == NULL) {
+ if (d == nullptr) {
errno = EINVAL;
return -1;
}
diff --git a/libc/bionic/error.cpp b/libc/bionic/error.cpp
index e8df0e0..a8adc1b 100644
--- a/libc/bionic/error.cpp
+++ b/libc/bionic/error.cpp
@@ -34,13 +34,13 @@
#include <string.h>
unsigned int error_message_count = 0;
-void (*error_print_progname)(void) = NULL;
+void (*error_print_progname)(void) = nullptr;
int error_one_per_line = 0;
static void __error_head() {
++error_message_count;
- if (error_print_progname != NULL) {
+ if (error_print_progname != nullptr) {
error_print_progname();
} else {
fflush(stdout);
@@ -77,7 +77,7 @@
if (error_one_per_line) {
static const char* last_file;
static unsigned int last_line;
- if (last_line == line && last_file != NULL && strcmp(last_file, file) == 0) {
+ if (last_line == line && last_file != nullptr && strcmp(last_file, file) == 0) {
return;
}
last_file = file;
diff --git a/libc/bionic/fortify.cpp b/libc/bionic/fortify.cpp
index 3bd9e68..4b94573 100644
--- a/libc/bionic/fortify.cpp
+++ b/libc/bionic/fortify.cpp
@@ -290,7 +290,7 @@
return const_cast<char*>(p);
}
if (*p == '\0') {
- return NULL;
+ return nullptr;
}
}
}
@@ -387,7 +387,7 @@
}
char* __strrchr_chk(const char* p, int ch, size_t s_len) {
- for (const char* save = NULL;; ++p, s_len--) {
+ for (const char* save = nullptr;; ++p, s_len--) {
if (s_len == 0) {
__fortify_fatal("strrchr: prevented read past end of buffer");
}
diff --git a/libc/bionic/futimens.cpp b/libc/bionic/futimens.cpp
index 1ca8eb5..03f7e38 100644
--- a/libc/bionic/futimens.cpp
+++ b/libc/bionic/futimens.cpp
@@ -30,5 +30,5 @@
#include <sys/stat.h>
int futimens(int fd, const struct timespec times[2]) {
- return utimensat(fd, NULL, times, 0);
+ return utimensat(fd, nullptr, times, 0);
}
diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp
index 22922b9..607e89c 100644
--- a/libc/bionic/getauxval.cpp
+++ b/libc/bionic/getauxval.cpp
@@ -33,7 +33,7 @@
#include <elf.h>
#include <errno.h>
-__LIBC_HIDDEN__ ElfW(auxv_t)* __libc_auxv = NULL;
+__LIBC_HIDDEN__ ElfW(auxv_t)* __libc_auxv = nullptr;
extern "C" unsigned long int getauxval(unsigned long int type) {
for (ElfW(auxv_t)* v = __libc_auxv; v->a_type != AT_NULL; ++v) {
diff --git a/libc/bionic/getcwd.cpp b/libc/bionic/getcwd.cpp
index 8ead91f..c42d4d5 100644
--- a/libc/bionic/getcwd.cpp
+++ b/libc/bionic/getcwd.cpp
@@ -35,23 +35,23 @@
char* getcwd(char* buf, size_t size) {
// You can't specify size 0 unless you're asking us to allocate for you.
- if (buf != NULL && size == 0) {
+ if (buf != nullptr && size == 0) {
errno = EINVAL;
- return NULL;
+ return nullptr;
}
// Allocate a buffer if necessary.
- char* allocated_buf = NULL;
+ char* allocated_buf = nullptr;
size_t allocated_size = size;
- if (buf == NULL) {
+ if (buf == nullptr) {
if (size == 0) {
// The Linux kernel won't return more than a page, so translate size 0 to 4KiB.
// TODO: if we need to support paths longer than that, we'll have to walk the tree ourselves.
allocated_size = getpagesize();
}
buf = allocated_buf = static_cast<char*>(malloc(allocated_size));
- if (buf == NULL) {
- return NULL;
+ if (buf == nullptr) {
+ return nullptr;
}
}
@@ -60,11 +60,11 @@
if (rc == -1) {
free(allocated_buf);
// __getcwd set errno.
- return NULL;
+ return nullptr;
}
// If we allocated a whole page, only return as large an allocation as necessary.
- if (allocated_buf != NULL) {
+ if (allocated_buf != nullptr) {
if (size == 0) {
buf = strdup(allocated_buf);
free(allocated_buf);
diff --git a/libc/bionic/grp_pwd.cpp b/libc/bionic/grp_pwd.cpp
index 1de8fc5..136a098 100644
--- a/libc/bionic/grp_pwd.cpp
+++ b/libc/bionic/grp_pwd.cpp
@@ -83,7 +83,7 @@
// getpwnam_r and getpwuid_r don't modify errno, but library calls we
// make might.
ErrnoRestorer errno_restorer;
- *result = NULL;
+ *result = nullptr;
// Our implementation of getpwnam(3) and getpwuid(3) use thread-local
// storage, so we can call them as long as we copy everything out
@@ -92,7 +92,7 @@
// POSIX allows failure to find a match to be considered a non-error.
// Reporting success (0) but with *result NULL is glibc's behavior.
- if (src == NULL) {
+ if (src == nullptr) {
return (errno == ENOENT) ? 0 : errno;
}
@@ -114,9 +114,9 @@
// pw_passwd and pw_gecos are non-POSIX and unused (always NULL) in bionic.
// Note: On LP32, we define pw_gecos to pw_passwd since they're both NULL.
- dst->pw_passwd = NULL;
+ dst->pw_passwd = nullptr;
#if defined(__LP64__)
- dst->pw_gecos = NULL;
+ dst->pw_gecos = nullptr;
#endif
// Copy the integral fields.
@@ -134,7 +134,7 @@
int getpwuid_r(uid_t uid, passwd* pwd,
char* buf, size_t byte_count, passwd** result) {
- return do_getpw_r(0, NULL, uid, pwd, buf, byte_count, result);
+ return do_getpw_r(0, nullptr, uid, pwd, buf, byte_count, result);
}
static passwd* android_iinfo_to_passwd(passwd_state_t* state,
@@ -169,7 +169,7 @@
return android_iinfo_to_passwd(state, android_ids + n);
}
}
- return NULL;
+ return nullptr;
}
static passwd* android_name_to_passwd(passwd_state_t* state, const char* name) {
@@ -178,7 +178,7 @@
return android_iinfo_to_passwd(state, android_ids + n);
}
}
- return NULL;
+ return nullptr;
}
static group* android_id_to_group(group_state_t* state, unsigned id) {
@@ -187,7 +187,7 @@
return android_iinfo_to_group(state, android_ids + n);
}
}
- return NULL;
+ return nullptr;
}
static group* android_name_to_group(group_state_t* state, const char* name) {
@@ -196,7 +196,7 @@
return android_iinfo_to_group(state, android_ids + n);
}
}
- return NULL;
+ return nullptr;
}
// These are a list of the reserved app ranges, and should never contain anything below
@@ -474,7 +474,7 @@
static passwd* app_id_to_passwd(uid_t uid, passwd_state_t* state) {
if (uid < AID_APP_START || !is_valid_app_id(uid)) {
errno = ENOENT;
- return NULL;
+ return nullptr;
}
print_app_name_from_uid(uid, state->name_buffer_, sizeof(state->name_buffer_));
@@ -502,7 +502,7 @@
static group* app_id_to_group(gid_t gid, group_state_t* state) {
if (gid < AID_APP_START || !is_valid_app_id(gid)) {
errno = ENOENT;
- return NULL;
+ return nullptr;
}
print_app_name_from_gid(gid, state->group_name_buffer_, sizeof(state->group_name_buffer_));
@@ -516,17 +516,17 @@
passwd* getpwuid(uid_t uid) { // NOLINT: implementing bad function.
passwd_state_t* state = get_passwd_tls_buffer();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
passwd* pw = android_id_to_passwd(state, uid);
- if (pw != NULL) {
+ if (pw != nullptr) {
return pw;
}
// Handle OEM range.
pw = oem_id_to_passwd(uid, state);
- if (pw != NULL) {
+ if (pw != nullptr) {
return pw;
}
return app_id_to_passwd(uid, state);
@@ -534,12 +534,12 @@
passwd* getpwnam(const char* login) { // NOLINT: implementing bad function.
passwd_state_t* state = get_passwd_tls_buffer();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
passwd* pw = android_name_to_passwd(state, login);
- if (pw != NULL) {
+ if (pw != nullptr) {
return pw;
}
@@ -551,7 +551,7 @@
// Handle OEM range.
pw = oem_id_to_passwd(oem_id_from_name(login), state);
- if (pw != NULL) {
+ if (pw != nullptr) {
return pw;
}
return app_id_to_passwd(app_id_from_name(login, false), state);
@@ -594,11 +594,11 @@
passwd* getpwent() {
passwd_state_t* state = get_passwd_tls_buffer();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
if (state->getpwent_idx < 0) {
- return NULL;
+ return nullptr;
}
size_t start = 0;
@@ -630,17 +630,17 @@
}
// We are not reporting u1_a* and higher or we will be here forever
- return NULL;
+ return nullptr;
}
static group* getgrgid_internal(gid_t gid, group_state_t* state) {
group* grp = android_id_to_group(state, gid);
- if (grp != NULL) {
+ if (grp != nullptr) {
return grp;
}
// Handle OEM range.
grp = oem_id_to_group(gid, state);
- if (grp != NULL) {
+ if (grp != nullptr) {
return grp;
}
return app_id_to_group(gid, state);
@@ -648,15 +648,15 @@
group* getgrgid(gid_t gid) { // NOLINT: implementing bad function.
group_state_t* state = __group_state();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
return getgrgid_internal(gid, state);
}
static group* getgrnam_internal(const char* name, group_state_t* state) {
group* grp = android_name_to_group(state, name);
- if (grp != NULL) {
+ if (grp != nullptr) {
return grp;
}
@@ -668,7 +668,7 @@
// Handle OEM range.
grp = oem_id_to_group(oem_id_from_name(name), state);
- if (grp != NULL) {
+ if (grp != nullptr) {
return grp;
}
return app_id_to_group(app_id_from_name(name, true), state);
@@ -676,8 +676,8 @@
group* getgrnam(const char* name) { // NOLINT: implementing bad function.
group_state_t* state = __group_state();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
return getgrnam_internal(name, state);
}
@@ -685,7 +685,7 @@
static int getgroup_r(bool by_name, const char* name, gid_t gid, struct group* grp, char* buf,
size_t buflen, struct group** result) {
ErrnoRestorer errno_restorer;
- *result = NULL;
+ *result = nullptr;
char* p = reinterpret_cast<char*>(
__BIONIC_ALIGN(reinterpret_cast<uintptr_t>(buf), sizeof(uintptr_t)));
if (p + sizeof(group_state_t) > buf + buflen) {
@@ -694,7 +694,7 @@
group_state_t* state = reinterpret_cast<group_state_t*>(p);
init_group_state(state);
group* retval = (by_name ? getgrnam_internal(name, state) : getgrgid_internal(gid, state));
- if (retval != NULL) {
+ if (retval != nullptr) {
*grp = *retval;
*result = grp;
return 0;
@@ -703,7 +703,7 @@
}
int getgrgid_r(gid_t gid, struct group* grp, char* buf, size_t buflen, struct group** result) {
- return getgroup_r(false, NULL, gid, grp, buf, buflen, result);
+ return getgroup_r(false, nullptr, gid, grp, buf, buflen, result);
}
int getgrnam_r(const char* name, struct group* grp, char* buf, size_t buflen,
@@ -724,11 +724,11 @@
group* getgrent() {
group_state_t* state = get_group_tls_buffer();
- if (state == NULL) {
- return NULL;
+ if (state == nullptr) {
+ return nullptr;
}
if (state->getgrent_idx < 0) {
- return NULL;
+ return nullptr;
}
size_t start = 0;
@@ -766,5 +766,5 @@
}
// We are not reporting u1_a* and higher or we will be here forever
- return NULL;
+ return nullptr;
}
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp
index 19081a4..812884c 100644
--- a/libc/bionic/jemalloc_wrapper.cpp
+++ b/libc/bionic/jemalloc_wrapper.cpp
@@ -25,7 +25,7 @@
size_t pagesize = getpagesize();
size_t size = __BIONIC_ALIGN(bytes, pagesize);
if (size < bytes) {
- return NULL;
+ return nullptr;
}
return je_memalign(pagesize, size);
}
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index ba59e8e..2de1bc7 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -104,12 +104,12 @@
// There is no getrlimit64 system call, so we need to use prlimit64.
int getrlimit64(int resource, rlimit64* limits64) {
- return prlimit64(0, resource, NULL, limits64);
+ return prlimit64(0, resource, nullptr, limits64);
}
// There is no setrlimit64 system call, so we need to use prlimit64.
int setrlimit64(int resource, const rlimit64* limits64) {
- return prlimit64(0, resource, limits64, NULL);
+ return prlimit64(0, resource, limits64, nullptr);
}
// There is no prlimit system call, so we need to use prlimit64.
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 5c54341..f943402 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -346,7 +346,7 @@
const Dtor minus1 = reinterpret_cast<Dtor>(static_cast<uintptr_t>(-1));
// Sanity check - first entry must be -1.
- if (array == NULL || fini_array[0] != minus1) {
+ if (array == nullptr || fini_array[0] != minus1) {
return;
}
@@ -355,7 +355,7 @@
// Count the number of destructors.
int count = 0;
- while (fini_array[count] != NULL) {
+ while (fini_array[count] != nullptr) {
++count;
}
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index c5606fb..0def359 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -130,7 +130,7 @@
// so we need to ensure that these are called when the program exits
// normally.
if (structors->fini_array) {
- __cxa_atexit(__libc_fini,structors->fini_array,NULL);
+ __cxa_atexit(__libc_fini,structors->fini_array,nullptr);
}
exit(slingshot(args.argc, args.argv, args.envp));
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index 3828def..9eb574a 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -117,8 +117,8 @@
// The executable may have its own destructors listed in its .fini_array
// so we need to ensure that these are called when the program exits
// normally.
- if (structors->fini_array != NULL) {
- __cxa_atexit(__libc_fini,structors->fini_array,NULL);
+ if (structors->fini_array != nullptr) {
+ __cxa_atexit(__libc_fini,structors->fini_array,nullptr);
}
exit(slingshot(args.argc, args.argv, args.envp));
diff --git a/libc/bionic/libgen.cpp b/libc/bionic/libgen.cpp
index 33b46a1..b952822 100644
--- a/libc/bionic/libgen.cpp
+++ b/libc/bionic/libgen.cpp
@@ -37,13 +37,13 @@
#include "bionic/pthread_internal.h"
static int __basename_r(const char* path, char* buffer, size_t buffer_size) {
- const char* startp = NULL;
- const char* endp = NULL;
+ const char* startp = nullptr;
+ const char* endp = nullptr;
int len;
int result;
// Empty or NULL string gets treated as ".".
- if (path == NULL || *path == '\0') {
+ if (path == nullptr || *path == '\0') {
startp = ".";
len = 1;
goto Exit;
@@ -72,7 +72,7 @@
Exit:
result = len;
- if (buffer == NULL) {
+ if (buffer == nullptr) {
return result;
}
if (len > static_cast<int>(buffer_size) - 1) {
@@ -94,12 +94,12 @@
}
static int __dirname_r(const char* path, char* buffer, size_t buffer_size) {
- const char* endp = NULL;
+ const char* endp = nullptr;
int len;
int result;
// Empty or NULL string gets treated as ".".
- if (path == NULL || *path == '\0') {
+ if (path == nullptr || *path == '\0') {
path = ".";
len = 1;
goto Exit;
@@ -135,7 +135,7 @@
errno = ENAMETOOLONG;
return -1;
}
- if (buffer == NULL) {
+ if (buffer == nullptr) {
return result;
}
@@ -160,11 +160,11 @@
char* basename(const char* path) {
char* buf = __get_bionic_tls().basename_buf;
int rc = __basename_r(path, buf, sizeof(__get_bionic_tls().basename_buf));
- return (rc < 0) ? NULL : buf;
+ return (rc < 0) ? nullptr : buf;
}
char* dirname(const char* path) {
char* buf = __get_bionic_tls().dirname_buf;
int rc = __dirname_r(path, buf, sizeof(__get_bionic_tls().dirname_buf));
- return (rc < 0) ? NULL : buf;
+ return (rc < 0) ? nullptr : buf;
}
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp
index 08c9401..2a5bcab 100644
--- a/libc/bionic/locale.cpp
+++ b/libc/bionic/locale.cpp
@@ -70,7 +70,7 @@
};
size_t __ctype_get_mb_cur_max() {
- locale_t l = uselocale(NULL);
+ locale_t l = uselocale(nullptr);
if (l == LC_GLOBAL_LOCALE) {
return __bionic_current_locale_is_utf8 ? 4 : 1;
} else {
@@ -142,14 +142,14 @@
locale_t newlocale(int category_mask, const char* locale_name, locale_t /*base*/) {
// Are 'category_mask' and 'locale_name' valid?
- if ((category_mask & ~LC_ALL_MASK) != 0 || locale_name == NULL) {
+ if ((category_mask & ~LC_ALL_MASK) != 0 || locale_name == nullptr) {
errno = EINVAL;
- return NULL;
+ return nullptr;
}
if (!__is_supported_locale(locale_name)) {
errno = ENOENT;
- return NULL;
+ return nullptr;
}
return new __locale_t(__is_utf8_locale(locale_name) ? 4 : 1);
@@ -159,15 +159,15 @@
// Is 'category' valid?
if (category < LC_CTYPE || category > LC_IDENTIFICATION) {
errno = EINVAL;
- return NULL;
+ return nullptr;
}
// Caller wants to set the locale rather than just query?
- if (locale_name != NULL) {
+ if (locale_name != nullptr) {
if (!__is_supported_locale(locale_name)) {
// We don't support this locale.
errno = ENOENT;
- return NULL;
+ return nullptr;
}
__bionic_current_locale_is_utf8 = __is_utf8_locale(locale_name);
}
@@ -187,11 +187,11 @@
locale_t old_locale = *get_current_locale_ptr();
// If this is the first call to uselocale(3) on this thread, we return LC_GLOBAL_LOCALE.
- if (old_locale == NULL) {
+ if (old_locale == nullptr) {
old_locale = LC_GLOBAL_LOCALE;
}
- if (new_locale != NULL) {
+ if (new_locale != nullptr) {
*get_current_locale_ptr() = new_locale;
}
diff --git a/libc/bionic/mbrtoc16.cpp b/libc/bionic/mbrtoc16.cpp
index 2180516..acea426 100644
--- a/libc/bionic/mbrtoc16.cpp
+++ b/libc/bionic/mbrtoc16.cpp
@@ -60,10 +60,10 @@
size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
char16_t __private_pc16;
- if (pc16 == NULL) {
+ if (pc16 == nullptr) {
pc16 = &__private_pc16;
}
diff --git a/libc/bionic/mbrtoc32.cpp b/libc/bionic/mbrtoc32.cpp
index 88a077c..644e542 100644
--- a/libc/bionic/mbrtoc32.cpp
+++ b/libc/bionic/mbrtoc32.cpp
@@ -35,7 +35,7 @@
size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
// We should never get to a state which has all 4 bytes of the sequence set.
// Full state verification is done when decoding the sequence (after we have
@@ -44,10 +44,10 @@
return mbstate_reset_and_return_illegal(EINVAL, state);
}
- if (s == NULL) {
+ if (s == nullptr) {
s = "";
n = 1;
- pc32 = NULL;
+ pc32 = nullptr;
}
if (n == 0) {
@@ -57,7 +57,7 @@
uint8_t ch;
if (mbsinit(state) && (((ch = static_cast<uint8_t>(*s)) & ~0x7f) == 0)) {
// Fast path for plain ASCII characters.
- if (pc32 != NULL) {
+ if (pc32 != nullptr) {
*pc32 = ch;
}
return (ch != '\0' ? 1 : 0);
@@ -131,7 +131,7 @@
// Malformed input; invalid code points.
return mbstate_reset_and_return_illegal(EILSEQ, state);
}
- if (pc32 != NULL) {
+ if (pc32 != nullptr) {
*pc32 = c32;
}
return mbstate_reset_and_return(c32 == U'\0' ? 0 : bytes_wanted, state);
diff --git a/libc/bionic/mntent.cpp b/libc/bionic/mntent.cpp
index 92284ce..6a12e78 100644
--- a/libc/bionic/mntent.cpp
+++ b/libc/bionic/mntent.cpp
@@ -38,7 +38,7 @@
mntent* getmntent_r(FILE* fp, struct mntent* e, char* buf, int buf_len) {
memset(e, 0, sizeof(*e));
- while (fgets(buf, buf_len, fp) != NULL) {
+ while (fgets(buf, buf_len, fp) != nullptr) {
// Entries look like "proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0".
// That is: mnt_fsname mnt_dir mnt_type mnt_opts 0 0.
int fsname0, fsname1, dir0, dir1, type0, type1, opts0, opts1;
@@ -60,7 +60,7 @@
return e;
}
}
- return NULL;
+ return nullptr;
}
FILE* setmntent(const char* path, const char* mode) {
@@ -68,7 +68,7 @@
}
int endmntent(FILE* fp) {
- if (fp != NULL) {
+ if (fp != nullptr) {
fclose(fp);
}
return 1;
diff --git a/libc/bionic/new.cpp b/libc/bionic/new.cpp
index 9499ff5..a0da2fb 100644
--- a/libc/bionic/new.cpp
+++ b/libc/bionic/new.cpp
@@ -25,7 +25,7 @@
void* operator new(std::size_t size) {
void* p = malloc(size);
- if (p == NULL) {
+ if (p == nullptr) {
async_safe_fatal("new failed to allocate %zu bytes", size);
}
return p;
@@ -33,7 +33,7 @@
void* operator new[](std::size_t size) {
void* p = malloc(size);
- if (p == NULL) {
+ if (p == nullptr) {
async_safe_fatal("new[] failed to allocate %zu bytes", size);
}
return p;
diff --git a/libc/bionic/posix_timers.cpp b/libc/bionic/posix_timers.cpp
index 47d6db0..f522516 100644
--- a/libc/bionic/posix_timers.cpp
+++ b/libc/bionic/posix_timers.cpp
@@ -92,7 +92,7 @@
} else if (si.si_code == SI_TKILL) {
// This signal was sent because someone wants us to exit.
free(timer);
- return NULL;
+ return nullptr;
}
}
}
@@ -105,11 +105,11 @@
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html
int timer_create(clockid_t clock_id, sigevent* evp, timer_t* timer_id) {
PosixTimer* timer = reinterpret_cast<PosixTimer*>(malloc(sizeof(PosixTimer)));
- if (timer == NULL) {
+ if (timer == nullptr) {
return -1;
}
- timer->sigev_notify = (evp == NULL) ? SIGEV_SIGNAL : evp->sigev_notify;
+ timer->sigev_notify = (evp == nullptr) ? SIGEV_SIGNAL : evp->sigev_notify;
// If not a SIGEV_THREAD timer, the kernel can handle it without our help.
if (timer->sigev_notify != SIGEV_THREAD) {
@@ -128,7 +128,7 @@
atomic_init(&timer->deleted, false);
// Check arguments that the kernel doesn't care about but we do.
- if (timer->callback == NULL) {
+ if (timer->callback == nullptr) {
free(timer);
errno = EINVAL;
return -1;
@@ -136,7 +136,7 @@
// Create this timer's thread.
pthread_attr_t thread_attributes;
- if (evp->sigev_notify_attributes == NULL) {
+ if (evp->sigev_notify_attributes == nullptr) {
pthread_attr_init(&thread_attributes);
} else {
thread_attributes = *reinterpret_cast<pthread_attr_t*>(evp->sigev_notify_attributes);
diff --git a/libc/bionic/pthread_attr.cpp b/libc/bionic/pthread_attr.cpp
index 93177f1..3c4b169 100644
--- a/libc/bionic/pthread_attr.cpp
+++ b/libc/bionic/pthread_attr.cpp
@@ -43,7 +43,7 @@
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int pthread_attr_init(pthread_attr_t* attr) {
attr->flags = 0;
- attr->stack_base = NULL;
+ attr->stack_base = nullptr;
attr->stack_size = PTHREAD_STACK_SIZE_DEFAULT;
attr->guard_size = PTHREAD_GUARD_SIZE;
attr->sched_policy = SCHED_NORMAL;
@@ -206,7 +206,7 @@
async_safe_fatal("couldn't open /proc/self/maps: %s", strerror(errno));
}
char line[BUFSIZ];
- while (fgets(line, sizeof(line), fp) != NULL) {
+ while (fgets(line, sizeof(line), fp) != nullptr) {
uintptr_t lo, hi;
if (sscanf(line, "%" SCNxPTR "-%" SCNxPTR, &lo, &hi) == 2) {
if (lo <= startstack && startstack <= hi) {
diff --git a/libc/bionic/pthread_cond.cpp b/libc/bionic/pthread_cond.cpp
index a42506a..9f0f8fa 100644
--- a/libc/bionic/pthread_cond.cpp
+++ b/libc/bionic/pthread_cond.cpp
@@ -136,7 +136,7 @@
pthread_cond_internal_t* cond = __get_internal_cond(cond_interface);
unsigned int init_state = 0;
- if (attr != NULL) {
+ if (attr != nullptr) {
init_state = (*attr & COND_FLAGS_MASK);
}
atomic_init(&cond->state, init_state);
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 21a707b..c95d400 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -88,7 +88,7 @@
void __init_alternate_signal_stack(pthread_internal_t* thread) {
// Create and set an alternate signal stack.
- void* stack_base = mmap(NULL, SIGNAL_STACK_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ void* stack_base = mmap(nullptr, SIGNAL_STACK_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (stack_base != MAP_FAILED) {
// Create a guard to catch stack overflows in signal handlers.
if (mprotect(stack_base, PTHREAD_GUARD_SIZE, PROT_NONE) == -1) {
@@ -99,7 +99,7 @@
ss.ss_sp = reinterpret_cast<uint8_t*>(stack_base) + PTHREAD_GUARD_SIZE;
ss.ss_size = SIGNAL_STACK_SIZE - PTHREAD_GUARD_SIZE;
ss.ss_flags = 0;
- sigaltstack(&ss, NULL);
+ sigaltstack(&ss, nullptr);
thread->alternate_signal_stack = stack_base;
// We can only use const static allocated string for mapped region name, as Android kernel
@@ -166,13 +166,13 @@
// Create a new private anonymous map.
int prot = PROT_READ | PROT_WRITE;
int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
- void* space = mmap(NULL, mmap_size, prot, flags, -1, 0);
+ void* space = mmap(nullptr, mmap_size, prot, flags, -1, 0);
if (space == MAP_FAILED) {
async_safe_format_log(ANDROID_LOG_WARN,
"libc",
"pthread_create failed: couldn't allocate %zu-bytes mapped space: %s",
mmap_size, strerror(errno));
- return NULL;
+ return nullptr;
}
// Stack is at the lower end of mapped space, stack guard region is at the lower end of stack.
@@ -182,7 +182,7 @@
"pthread_create failed: couldn't mprotect PROT_NONE %zu-byte stack guard region: %s",
stack_guard_size, strerror(errno));
munmap(space, mmap_size);
- return NULL;
+ return nullptr;
}
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, space, stack_guard_size, "thread stack guard");
@@ -193,7 +193,7 @@
size_t mmap_size;
uint8_t* stack_top;
- if (attr->stack_base == NULL) {
+ if (attr->stack_base == nullptr) {
// The caller didn't provide a stack, so allocate one.
// Make sure the stack size and guard size are multiples of PAGE_SIZE.
if (__builtin_add_overflow(attr->stack_size, attr->guard_size, &mmap_size)) return EAGAIN;
@@ -201,7 +201,7 @@
mmap_size = __BIONIC_ALIGN(mmap_size, PAGE_SIZE);
attr->guard_size = __BIONIC_ALIGN(attr->guard_size, PAGE_SIZE);
attr->stack_base = __create_thread_mapped_space(mmap_size, attr->guard_size);
- if (attr->stack_base == NULL) {
+ if (attr->stack_base == nullptr) {
return EAGAIN;
}
stack_top = reinterpret_cast<uint8_t*>(attr->stack_base) + mmap_size;
@@ -261,7 +261,7 @@
// going to run user code on it. We swap out the user's start routine for this and take advantage
// of the regular thread teardown to free up resources.
static void* __do_nothing(void*) {
- return NULL;
+ return nullptr;
}
@@ -271,15 +271,15 @@
ErrnoRestorer errno_restorer;
pthread_attr_t thread_attr;
- if (attr == NULL) {
+ if (attr == nullptr) {
pthread_attr_init(&thread_attr);
} else {
thread_attr = *attr;
- attr = NULL; // Prevent misuse below.
+ attr = nullptr; // Prevent misuse below.
}
- pthread_internal_t* thread = NULL;
- void* child_stack = NULL;
+ pthread_internal_t* thread = nullptr;
+ void* child_stack = nullptr;
int result = __allocate_thread(&thread_attr, &thread, &child_stack);
if (result != 0) {
return result;
diff --git a/libc/bionic/pthread_detach.cpp b/libc/bionic/pthread_detach.cpp
index 011e6c6..c2e4127 100644
--- a/libc/bionic/pthread_detach.cpp
+++ b/libc/bionic/pthread_detach.cpp
@@ -35,7 +35,7 @@
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int pthread_detach(pthread_t t) {
pthread_internal_t* thread = __pthread_internal_find(t);
- if (thread == NULL) {
+ if (thread == nullptr) {
return ESRCH;
}
@@ -48,7 +48,7 @@
return 0;
} else if (old_state == THREAD_EXITED_NOT_JOINED) {
// Use pthread_join to clean it up.
- return pthread_join(t, NULL);
+ return pthread_join(t, nullptr);
}
return EINVAL;
}
diff --git a/libc/bionic/pthread_exit.cpp b/libc/bionic/pthread_exit.cpp
index f1b65fd..ac5d429 100644
--- a/libc/bionic/pthread_exit.cpp
+++ b/libc/bionic/pthread_exit.cpp
@@ -91,16 +91,16 @@
// space (see pthread_key_delete).
pthread_key_clean_all();
- if (thread->alternate_signal_stack != NULL) {
+ if (thread->alternate_signal_stack != nullptr) {
// Tell the kernel to stop using the alternate signal stack.
stack_t ss;
memset(&ss, 0, sizeof(ss));
ss.ss_flags = SS_DISABLE;
- sigaltstack(&ss, NULL);
+ sigaltstack(&ss, nullptr);
// Free it.
munmap(thread->alternate_signal_stack, SIGNAL_STACK_SIZE);
- thread->alternate_signal_stack = NULL;
+ thread->alternate_signal_stack = nullptr;
}
ThreadJoinState old_state = THREAD_NOT_JOINED;
@@ -113,7 +113,7 @@
// So we can free mapped space, which includes pthread_internal_t and thread stack.
// First make sure that the kernel does not try to clear the tid field
// because we'll have freed the memory before the thread actually exits.
- __set_tid_address(NULL);
+ __set_tid_address(nullptr);
// pthread_internal_t is freed below with stack, not here.
__pthread_internal_remove(thread);
diff --git a/libc/bionic/pthread_join.cpp b/libc/bionic/pthread_join.cpp
index be76c20..9aad458 100644
--- a/libc/bionic/pthread_join.cpp
+++ b/libc/bionic/pthread_join.cpp
@@ -39,7 +39,7 @@
}
pthread_internal_t* thread = __pthread_internal_find(t);
- if (thread == NULL) {
+ if (thread == nullptr) {
return ESRCH;
}
@@ -60,7 +60,7 @@
// Wait for the thread to actually exit, if it hasn't already.
while (*tid_ptr != 0) {
- __futex_wait(tid_ptr, tid, NULL);
+ __futex_wait(tid_ptr, tid, nullptr);
}
if (return_value) {
diff --git a/libc/bionic/pthread_key.cpp b/libc/bionic/pthread_key.cpp
index baff9cc..f3878a6 100644
--- a/libc/bionic/pthread_key.cpp
+++ b/libc/bionic/pthread_key.cpp
@@ -79,7 +79,7 @@
size_t called_destructor_count = 0;
for (size_t i = 0; i < BIONIC_PTHREAD_KEY_COUNT; ++i) {
uintptr_t seq = atomic_load_explicit(&key_map[i].seq, memory_order_relaxed);
- if (SeqOfKeyInUse(seq) && seq == key_data[i].seq && key_data[i].data != NULL) {
+ if (SeqOfKeyInUse(seq) && seq == key_data[i].seq && key_data[i].data != nullptr) {
// Other threads may be calling pthread_key_delete/pthread_key_create while current thread
// is exiting. So we need to ensure we read the right key_destructor.
// We can rely on a user-established happens-before relationship between the creation and
@@ -89,7 +89,7 @@
// right key_destructor, or the sequence number must have changed when we reread it below.
key_destructor_t key_destructor = reinterpret_cast<key_destructor_t>(
atomic_load_explicit(&key_map[i].key_destructor, memory_order_relaxed));
- if (key_destructor == NULL) {
+ if (key_destructor == nullptr) {
continue;
}
atomic_thread_fence(memory_order_acquire);
@@ -102,7 +102,7 @@
// We don't do this if 'key_destructor == NULL' just in case another destructor
// function is responsible for manually releasing the corresponding data.
void* data = key_data[i].data;
- key_data[i].data = NULL;
+ key_data[i].data = nullptr;
(*key_destructor)(data);
++called_destructor_count;
@@ -154,7 +154,7 @@
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
void* pthread_getspecific(pthread_key_t key) {
if (__predict_false(!KeyInValidRange(key))) {
- return NULL;
+ return nullptr;
}
key &= ~KEY_VALID_FLAG;
uintptr_t seq = atomic_load_explicit(&key_map[key].seq, memory_order_relaxed);
@@ -166,8 +166,8 @@
}
// We arrive here when current thread holds the seq of an deleted pthread key. So the
// data is for the deleted pthread key, and should be cleared.
- data->data = NULL;
- return NULL;
+ data->data = nullptr;
+ return nullptr;
}
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index 7f48972..fda0b93 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -502,7 +502,7 @@
memset(mutex, 0, sizeof(pthread_mutex_internal_t));
- if (__predict_true(attr == NULL)) {
+ if (__predict_true(attr == nullptr)) {
atomic_init(&mutex->state, MUTEX_TYPE_BITS_NORMAL);
return 0;
}
@@ -800,7 +800,7 @@
// Some apps depend on being able to pass NULL as a mutex and get EINVAL
// back. Don't need to worry about it for LP64 since the ABI is brand new,
// but keep compatibility for LP32. http://b/19995172.
- if (mutex_interface == NULL) {
+ if (mutex_interface == nullptr) {
return EINVAL;
}
#endif
@@ -834,7 +834,7 @@
// Some apps depend on being able to pass NULL as a mutex and get EINVAL
// back. Don't need to worry about it for LP64 since the ABI is brand new,
// but keep compatibility for LP32. http://b/19995172.
- if (mutex_interface == NULL) {
+ if (mutex_interface == nullptr) {
return EINVAL;
}
#endif
diff --git a/libc/bionic/pthread_rwlock.cpp b/libc/bionic/pthread_rwlock.cpp
index 4f4c461..2b9be98 100644
--- a/libc/bionic/pthread_rwlock.cpp
+++ b/libc/bionic/pthread_rwlock.cpp
@@ -228,7 +228,7 @@
memset(rwlock, 0, sizeof(pthread_rwlock_internal_t));
- if (__predict_false(attr != NULL)) {
+ if (__predict_false(attr != nullptr)) {
rwlock->pshared = __rwlockattr_getpshared(attr);
int kind = __rwlockattr_getkind(attr);
switch (kind) {
diff --git a/libc/bionic/pty.cpp b/libc/bionic/pty.cpp
index 599cbd2..71e14d9 100644
--- a/libc/bionic/pty.cpp
+++ b/libc/bionic/pty.cpp
@@ -55,11 +55,11 @@
bionic_tls& tls = __get_bionic_tls();
char* buf = tls.ptsname_buf;
int error = ptsname_r(fd, buf, sizeof(tls.ptsname_buf));
- return (error == 0) ? buf : NULL;
+ return (error == 0) ? buf : nullptr;
}
int ptsname_r(int fd, char* buf, size_t len) {
- if (buf == NULL) {
+ if (buf == nullptr) {
errno = EINVAL;
return errno;
}
@@ -82,11 +82,11 @@
bionic_tls& tls = __get_bionic_tls();
char* buf = tls.ttyname_buf;
int error = ttyname_r(fd, buf, sizeof(tls.ttyname_buf));
- return (error == 0) ? buf : NULL;
+ return (error == 0) ? buf : nullptr;
}
int ttyname_r(int fd, char* buf, size_t len) {
- if (buf == NULL) {
+ if (buf == nullptr) {
errno = EINVAL;
return errno;
}
@@ -124,7 +124,7 @@
}
char buf[32];
- if (name == NULL) {
+ if (name == nullptr) {
name = buf;
}
if (ptsname_r(*master, name, sizeof(buf)) != 0) {
@@ -138,10 +138,10 @@
return -1;
}
- if (t != NULL) {
+ if (t != nullptr) {
tcsetattr(*slave, TCSAFLUSH, t);
}
- if (ws != NULL) {
+ if (ws != nullptr) {
ioctl(*slave, TIOCSWINSZ, ws);
}
@@ -181,7 +181,7 @@
int login_tty(int fd) {
setsid();
- if (ioctl(fd, TIOCSCTTY, NULL) == -1) {
+ if (ioctl(fd, TIOCSCTTY, nullptr) == -1) {
return -1;
}
diff --git a/libc/bionic/reboot.cpp b/libc/bionic/reboot.cpp
index 9cf4411..b0a1f97 100644
--- a/libc/bionic/reboot.cpp
+++ b/libc/bionic/reboot.cpp
@@ -32,5 +32,5 @@
extern "C" int __reboot(int, int, int, void*);
int reboot(int mode) {
- return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, mode, NULL);
+ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, mode, nullptr);
}
diff --git a/libc/bionic/recv.cpp b/libc/bionic/recv.cpp
index 60f264d..32a7a72 100644
--- a/libc/bionic/recv.cpp
+++ b/libc/bionic/recv.cpp
@@ -29,5 +29,5 @@
#include <sys/socket.h>
ssize_t recv(int socket, void *buf, size_t len, int flags) {
- return recvfrom(socket, buf, len, flags, NULL, 0);
+ return recvfrom(socket, buf, len, flags, nullptr, nullptr);
}
diff --git a/libc/bionic/sched_getcpu.cpp b/libc/bionic/sched_getcpu.cpp
index 1f92e54..f245fba 100644
--- a/libc/bionic/sched_getcpu.cpp
+++ b/libc/bionic/sched_getcpu.cpp
@@ -33,7 +33,7 @@
int sched_getcpu() {
unsigned cpu;
- int rc = __getcpu(&cpu, NULL, NULL);
+ int rc = __getcpu(&cpu, nullptr, nullptr);
if (rc == -1) {
return -1; // errno is already set.
}
diff --git a/libc/bionic/send.cpp b/libc/bionic/send.cpp
index 2e5d457..7106c43 100644
--- a/libc/bionic/send.cpp
+++ b/libc/bionic/send.cpp
@@ -29,5 +29,5 @@
#include <sys/socket.h>
ssize_t send(int socket, const void* buf, size_t len, int flags) {
- return sendto(socket, buf, len, flags, NULL, 0);
+ return sendto(socket, buf, len, flags, nullptr, 0);
}
diff --git a/libc/bionic/sigaction.cpp b/libc/bionic/sigaction.cpp
index 41923cf..fb57d1c 100644
--- a/libc/bionic/sigaction.cpp
+++ b/libc/bionic/sigaction.cpp
@@ -40,7 +40,7 @@
int sigaction(int signal, const struct sigaction* bionic_new_action, struct sigaction* bionic_old_action) {
__kernel_sigaction kernel_new_action;
- if (bionic_new_action != NULL) {
+ if (bionic_new_action != nullptr) {
kernel_new_action.sa_flags = bionic_new_action->sa_flags;
kernel_new_action.sa_handler = bionic_new_action->sa_handler;
kernel_new_action.sa_mask = filter_reserved_signals(bionic_new_action->sa_mask);
@@ -62,11 +62,11 @@
__kernel_sigaction kernel_old_action;
int result = __rt_sigaction(signal,
- (bionic_new_action != NULL) ? &kernel_new_action : NULL,
- (bionic_old_action != NULL) ? &kernel_old_action : NULL,
+ (bionic_new_action != nullptr) ? &kernel_new_action : nullptr,
+ (bionic_old_action != nullptr) ? &kernel_old_action : nullptr,
sizeof(sigset_t));
- if (bionic_old_action != NULL) {
+ if (bionic_old_action != nullptr) {
bionic_old_action->sa_flags = kernel_old_action.sa_flags;
bionic_old_action->sa_handler = kernel_old_action.sa_handler;
bionic_old_action->sa_mask = kernel_old_action.sa_mask;
diff --git a/libc/bionic/strerror_r.cpp b/libc/bionic/strerror_r.cpp
index dad3fb3..1cf2abc 100644
--- a/libc/bionic/strerror_r.cpp
+++ b/libc/bionic/strerror_r.cpp
@@ -22,18 +22,18 @@
};
static const char* __code_string_lookup(const Pair* strings, int code) {
- for (size_t i = 0; strings[i].msg != NULL; ++i) {
+ for (size_t i = 0; strings[i].msg != nullptr; ++i) {
if (strings[i].code == code) {
return strings[i].msg;
}
}
- return NULL;
+ return nullptr;
}
static const Pair _sys_error_strings[] = {
#define __BIONIC_ERRDEF(x,y,z) { x, z },
#include "private/bionic_errdefs.h"
- { 0, NULL }
+ { 0, nullptr }
};
extern "C" __LIBC_HIDDEN__ const char* __strerror_lookup(int error_number) {
@@ -43,7 +43,7 @@
static const Pair _sys_signal_strings[] = {
#define __BIONIC_SIGDEF(signal_number, signal_description) { signal_number, signal_description },
#include "private/bionic_sigdefs.h"
- { 0, NULL }
+ { 0, nullptr }
};
extern "C" __LIBC_HIDDEN__ const char* __strsignal_lookup(int signal_number) {
@@ -55,7 +55,7 @@
size_t length;
const char* error_name = __strerror_lookup(error_number);
- if (error_name != NULL) {
+ if (error_name != nullptr) {
length = strlcpy(buf, error_name, buf_len);
} else {
length = async_safe_format_buffer(buf, buf_len, "Unknown error %d", error_number);
@@ -76,7 +76,7 @@
extern "C" __LIBC_HIDDEN__ const char* __strsignal(int signal_number, char* buf, size_t buf_len) {
const char* signal_name = __strsignal_lookup(signal_number);
- if (signal_name != NULL) {
+ if (signal_name != nullptr) {
return signal_name;
}
@@ -87,7 +87,7 @@
}
size_t length = snprintf(buf, buf_len, "%s signal %d", prefix, signal_number);
if (length >= buf_len) {
- return NULL;
+ return nullptr;
}
return buf;
}
diff --git a/libc/bionic/strsignal.cpp b/libc/bionic/strsignal.cpp
index 81a8f95..1cdfec1 100644
--- a/libc/bionic/strsignal.cpp
+++ b/libc/bionic/strsignal.cpp
@@ -36,7 +36,7 @@
char* strsignal(int signal_number) {
// Just return the original constant in the easy cases.
char* result = const_cast<char*>(__strsignal_lookup(signal_number));
- if (result != NULL) {
+ if (result != nullptr) {
return result;
}
diff --git a/libc/bionic/sysinfo.cpp b/libc/bionic/sysinfo.cpp
index 947de95..1d1070e 100644
--- a/libc/bionic/sysinfo.cpp
+++ b/libc/bionic/sysinfo.cpp
@@ -53,7 +53,7 @@
int result = 0;
dirent* entry;
- while ((entry = reader.ReadEntry()) != NULL) {
+ while ((entry = reader.ReadEntry()) != nullptr) {
if (entry->d_type == DT_DIR && __matches_cpuN(entry->d_name)) {
++result;
}
diff --git a/libc/bionic/syslog.cpp b/libc/bionic/syslog.cpp
index 9424573..d1a0c5b 100644
--- a/libc/bionic/syslog.cpp
+++ b/libc/bionic/syslog.cpp
@@ -21,11 +21,11 @@
#include <async_safe/log.h>
-static const char* syslog_log_tag = NULL;
+static const char* syslog_log_tag = nullptr;
static int syslog_priority_mask = 0xff;
void closelog() {
- syslog_log_tag = NULL;
+ syslog_log_tag = nullptr;
}
void openlog(const char* log_tag, int /*options*/, int /*facility*/) {
@@ -58,7 +58,7 @@
// What's our log tag?
const char* log_tag = syslog_log_tag;
- if (log_tag == NULL) {
+ if (log_tag == nullptr) {
log_tag = getprogname();
}
@@ -78,7 +78,7 @@
// glibc's printf family support %m directly, but our BSD-based one doesn't.
// If the format string seems to contain "%m", rewrite it.
const char* log_fmt = fmt;
- if (strstr(fmt, "%m") != NULL) {
+ if (strstr(fmt, "%m") != nullptr) {
size_t dst_len = 1024;
char* dst = reinterpret_cast<char*>(malloc(dst_len));
log_fmt = dst;
diff --git a/libc/bionic/tdestroy.cpp b/libc/bionic/tdestroy.cpp
index 2968ff9..6606c56 100644
--- a/libc/bionic/tdestroy.cpp
+++ b/libc/bionic/tdestroy.cpp
@@ -27,7 +27,7 @@
// This is a GNU extension, not available from BSD.
void tdestroy(void* root, void (*destroy_func)(void*)) {
node_t* root_node = reinterpret_cast<node_t*>(root);
- if (root_node == NULL) {
+ if (root_node == nullptr) {
return;
}
if (root_node->llink) {
diff --git a/libc/bionic/tmpfile.cpp b/libc/bionic/tmpfile.cpp
index bda3566..4378e84 100644
--- a/libc/bionic/tmpfile.cpp
+++ b/libc/bionic/tmpfile.cpp
@@ -42,9 +42,9 @@
#include "private/ScopedSignalBlocker.h"
static FILE* __tmpfile_dir(const char* tmp_dir) {
- char* path = NULL;
+ char* path = nullptr;
if (asprintf(&path, "%s/tmp.XXXXXXXXXX", tmp_dir) == -1) {
- return NULL;
+ return nullptr;
}
int fd;
@@ -53,7 +53,7 @@
fd = mkstemp(path);
if (fd == -1) {
free(path);
- return NULL;
+ return nullptr;
}
// Unlink the file now so that it's removed when closed.
@@ -67,20 +67,20 @@
if (rc == -1) {
ErrnoRestorer errno_restorer;
close(fd);
- return NULL;
+ return nullptr;
}
}
// Turn the file descriptor into a FILE*.
FILE* fp = fdopen(fd, "w+");
- if (fp != NULL) {
+ if (fp != nullptr) {
return fp;
}
// Failure. Clean up. We already unlinked, so we just need to close.
ErrnoRestorer errno_restorer;
close(fd);
- return NULL;
+ return nullptr;
}
FILE* tmpfile() {
@@ -90,7 +90,7 @@
// This means we can't do the usual trick of calling unlink before handing the file back.
FILE* fp = __tmpfile_dir("/data/local/tmp");
- if (fp == NULL) {
+ if (fp == nullptr) {
// P_tmpdir is "/tmp/", but POSIX explicitly says that tmpdir(3) should try P_tmpdir before
// giving up. This is potentially useful for bionic on the host anyway.
fp = __tmpfile_dir(P_tmpdir);
diff --git a/libc/bionic/wait.cpp b/libc/bionic/wait.cpp
index e5c93aa..3e59f51 100644
--- a/libc/bionic/wait.cpp
+++ b/libc/bionic/wait.cpp
@@ -32,14 +32,14 @@
extern "C" int __waitid(idtype_t which, id_t id, siginfo_t* info, int options, struct rusage* ru);
pid_t wait(int* status) {
- return wait4(-1, status, 0, NULL);
+ return wait4(-1, status, 0, nullptr);
}
pid_t waitpid(pid_t pid, int* status, int options) {
- return wait4(pid, status, options, NULL);
+ return wait4(pid, status, options, nullptr);
}
int waitid(idtype_t which, id_t id, siginfo_t* info, int options) {
// The system call takes an optional struct rusage that we don't need.
- return __waitid(which, id, info, options, NULL);
+ return __waitid(which, id, info, options, nullptr);
}
diff --git a/libc/bionic/wchar.cpp b/libc/bionic/wchar.cpp
index 62023d6..dabe824 100644
--- a/libc/bionic/wchar.cpp
+++ b/libc/bionic/wchar.cpp
@@ -54,12 +54,12 @@
//
int mbsinit(const mbstate_t* ps) {
- return (ps == NULL || (*(reinterpret_cast<const uint32_t*>(ps->__seq)) == 0));
+ return (ps == nullptr || (*(reinterpret_cast<const uint32_t*>(ps->__seq)) == 0));
}
size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
// Our wchar_t is UTF-32.
return mbrtoc32(reinterpret_cast<char32_t*>(pwc), s, n, state);
@@ -67,7 +67,7 @@
size_t mbsnrtowcs(wchar_t* dst, const char** src, size_t nmc, size_t len, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
size_t i, o, r;
// The fast paths in the loops below are not safe if an ASCII
@@ -78,7 +78,7 @@
}
// Measure only?
- if (dst == NULL) {
+ if (dst == nullptr) {
for (i = o = 0; i < nmc; i += r, o++) {
if (static_cast<uint8_t>((*src)[i]) < 0x80) {
// Fast path for plain ASCII characters.
@@ -87,7 +87,7 @@
}
r = 1;
} else {
- r = mbrtowc(NULL, *src + i, nmc - i, state);
+ r = mbrtowc(nullptr, *src + i, nmc - i, state);
if (r == __MB_ERR_ILLEGAL_SEQUENCE) {
return mbstate_reset_and_return_illegal(EILSEQ, state);
}
@@ -123,7 +123,7 @@
return mbstate_reset_and_return_illegal(EILSEQ, state);
}
if (r == 0) {
- *src = NULL;
+ *src = nullptr;
return mbstate_reset_and_return(o, state);
}
}
@@ -138,7 +138,7 @@
size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
// Our wchar_t is UTF-32.
return c32rtomb(s, static_cast<char32_t>(wc), state);
@@ -146,7 +146,7 @@
size_t wcsnrtombs(char* dst, const wchar_t** src, size_t nwc, size_t len, mbstate_t* ps) {
static mbstate_t __private_state;
- mbstate_t* state = (ps == NULL) ? &__private_state : ps;
+ mbstate_t* state = (ps == nullptr) ? &__private_state : ps;
if (!mbsinit(state)) {
return mbstate_reset_and_return_illegal(EILSEQ, state);
@@ -154,7 +154,7 @@
char buf[MB_LEN_MAX];
size_t i, o, r;
- if (dst == NULL) {
+ if (dst == nullptr) {
for (i = o = 0; i < nwc; i++, o += r) {
wchar_t wc = (*src)[i];
if (static_cast<uint32_t>(wc) < 0x80) {
@@ -179,7 +179,7 @@
// Fast path for plain ASCII characters.
dst[o] = wc;
if (wc == 0) {
- *src = NULL;
+ *src = nullptr;
return o;
}
r = 1;
diff --git a/libc/bionic/wcstod.cpp b/libc/bionic/wcstod.cpp
index 41a94fb..75a59f5 100644
--- a/libc/bionic/wcstod.cpp
+++ b/libc/bionic/wcstod.cpp
@@ -62,7 +62,7 @@
f._bf._base = f._p = reinterpret_cast<unsigned char*>(ascii_str);
f._bf._size = f._r = max_len;
f._read = [](void*, char*, int) { return 0; }; // aka `eofread`, aka "no more data".
- f._lb._base = NULL;
+ f._lb._base = nullptr;
// Ask `parsefloat` to look at the same data more carefully.
diff --git a/libc/bionic/wctype.cpp b/libc/bionic/wctype.cpp
index 05b6e19..6e33b6c 100644
--- a/libc/bionic/wctype.cpp
+++ b/libc/bionic/wctype.cpp
@@ -155,7 +155,7 @@
wctrans_t wctrans(const char* name) {
if (strcmp(name, "tolower") == 0) return wctrans_tolower;
if (strcmp(name, "toupper") == 0) return wctrans_toupper;
- return 0;
+ return nullptr;
}
wctrans_t wctrans_l(const char* name, locale_t) {
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 2e3a0a3..9075a9c 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -284,7 +284,7 @@
ScopedDisableDebugCalls disable;
// Verify the arguments.
- if (info == nullptr || overall_size == nullptr || info_size == NULL || total_memory == nullptr ||
+ if (info == nullptr || overall_size == nullptr || info_size == nullptr || total_memory == nullptr ||
backtrace_size == nullptr) {
error_log("get_malloc_leak_info: At least one invalid parameter.");
return;
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index 5b6b77f..e05ceb9 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -42,7 +42,7 @@
// Skip over all environment variable definitions to find the aux vector.
// The end of the environment block is marked by a NULL pointer.
char** p = envp;
- while (*p != NULL) {
+ while (*p != nullptr) {
++p;
}
++p; // Skip the NULL itself.
diff --git a/libc/private/ScopedReaddir.h b/libc/private/ScopedReaddir.h
index 3d77a40..1a59e1a 100644
--- a/libc/private/ScopedReaddir.h
+++ b/libc/private/ScopedReaddir.h
@@ -31,13 +31,13 @@
}
~ScopedReaddir() {
- if (dir_ != NULL) {
+ if (dir_ != nullptr) {
closedir(dir_);
}
}
bool IsBad() {
- return dir_ == NULL;
+ return dir_ == nullptr;
}
dirent* ReadEntry() {
diff --git a/libc/private/bionic_futex.h b/libc/private/bionic_futex.h
index fd68007..b340690 100644
--- a/libc/private/bionic_futex.h
+++ b/libc/private/bionic_futex.h
@@ -51,11 +51,11 @@
}
static inline int __futex_wake(volatile void* ftx, int count) {
- return __futex(ftx, FUTEX_WAKE, count, NULL, 0);
+ return __futex(ftx, FUTEX_WAKE, count, nullptr, 0);
}
static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) {
- return __futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL, 0);
+ return __futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, nullptr, 0);
}
static inline int __futex_wait(volatile void* ftx, int value, const timespec* timeout) {
diff --git a/libc/stdio/printf_common.h b/libc/stdio/printf_common.h
index 85c91de..9b7c329 100644
--- a/libc/stdio/printf_common.h
+++ b/libc/stdio/printf_common.h
@@ -535,7 +535,7 @@
*/
if (tablemax >= STATIC_ARG_TBL_SIZE) {
*argtablesiz = sizeof(union arg) * (tablemax + 1);
- *argtable = static_cast<arg*>(mmap(NULL, *argtablesiz,
+ *argtable = static_cast<arg*>(mmap(nullptr, *argtablesiz,
PROT_WRITE | PROT_READ,
MAP_ANON | MAP_PRIVATE, -1, 0));
if (*argtable == MAP_FAILED) return -1;
@@ -629,9 +629,9 @@
ret = -1;
finish:
- if (typetable != NULL && typetable != stattypetable) {
+ if (typetable != nullptr && typetable != stattypetable) {
munmap(typetable, *argtablesiz);
- typetable = NULL;
+ typetable = nullptr;
}
return (ret);
}
@@ -646,13 +646,13 @@
if (new_size < getpagesize()) new_size = getpagesize();
if (*tablesize == STATIC_ARG_TBL_SIZE) {
- *typetable = static_cast<unsigned char*>(mmap(NULL, new_size,
+ *typetable = static_cast<unsigned char*>(mmap(nullptr, new_size,
PROT_WRITE | PROT_READ,
MAP_ANON | MAP_PRIVATE, -1, 0));
if (*typetable == MAP_FAILED) return -1;
bcopy(old_table, *typetable, *tablesize);
} else {
- unsigned char* new_table = static_cast<unsigned char*>(mmap(NULL, new_size,
+ unsigned char* new_table = static_cast<unsigned char*>(mmap(nullptr, new_size,
PROT_WRITE | PROT_READ,
MAP_ANON | MAP_PRIVATE, -1, 0));
if (new_table == MAP_FAILED) return -1;
@@ -695,8 +695,8 @@
if (prec < 0) {
memset(&mbs, 0, sizeof(mbs));
p = wcsarg;
- nbytes = wcsrtombs(NULL, (const wchar_t**)&p, 0, &mbs);
- if (nbytes == (size_t)-1) return NULL;
+ nbytes = wcsrtombs(nullptr, (const wchar_t**)&p, 0, &mbs);
+ if (nbytes == (size_t)-1) return nullptr;
} else {
// Optimisation: if the output precision is small enough,
// just allocate enough memory for the maximum instead of
@@ -712,17 +712,17 @@
if (clen == 0 || clen == (size_t)-1 || nbytes + clen > (size_t)prec) break;
nbytes += clen;
}
- if (clen == (size_t)-1) return NULL;
+ if (clen == (size_t)-1) return nullptr;
}
}
- if ((convbuf = static_cast<char*>(malloc(nbytes + 1))) == NULL) return NULL;
+ if ((convbuf = static_cast<char*>(malloc(nbytes + 1))) == nullptr) return nullptr;
// Fill the output buffer.
p = wcsarg;
memset(&mbs, 0, sizeof(mbs));
if ((nbytes = wcsrtombs(convbuf, (const wchar_t**)&p, nbytes, &mbs)) == (size_t)-1) {
free(convbuf);
- return NULL;
+ return nullptr;
}
convbuf[nbytes] = '\0';
return convbuf;
@@ -764,7 +764,7 @@
const char* p;
size_t insize, nchars, nconv;
- if (mbsarg == NULL) return NULL;
+ if (mbsarg == nullptr) return nullptr;
// Supplied argument is a multibyte string; convert it to wide characters first.
if (prec >= 0) {
@@ -779,7 +779,7 @@
nchars++;
insize += nconv;
}
- if (nconv == (size_t)-1 || nconv == (size_t)-2) return (NULL);
+ if (nconv == (size_t)-1 || nconv == (size_t)-2) return (nullptr);
} else {
insize = strlen(mbsarg);
}
@@ -788,7 +788,7 @@
// converting at most `size' bytes of the input multibyte string to
// wide characters for printing.
wchar_t* convbuf = static_cast<wchar_t*>(calloc(insize + 1, sizeof(*convbuf)));
- if (convbuf == NULL) return NULL;
+ if (convbuf == nullptr) return nullptr;
wchar_t* wcp = convbuf;
p = mbsarg;
bzero(&mbs, sizeof(mbs));
@@ -802,7 +802,7 @@
}
if (nconv == (size_t)-1 || nconv == (size_t)-2) {
free(convbuf);
- return NULL;
+ return nullptr;
}
*wcp = '\0';
diff --git a/libc/stdio/stdio_ext.cpp b/libc/stdio/stdio_ext.cpp
index e17b62a..945813e 100644
--- a/libc/stdio/stdio_ext.cpp
+++ b/libc/stdio/stdio_ext.cpp
@@ -69,7 +69,7 @@
void _flushlbf() {
// If we flush all streams, we know we've flushed all the line-buffered streams.
- fflush(NULL);
+ fflush(nullptr);
}
void __fseterr(FILE* fp) {
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index 17e4372..7a67868 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -64,7 +64,7 @@
* D: expchar holds this character; '\0' if no exponent, e.g. %f
* F: at least two digits for decimal, at least one digit for hex
*/
- char* decimal_point = NULL;
+ char* decimal_point = nullptr;
int signflag; /* true if float is negative */
union { /* floating point arguments %[aAeEfFgG] */
double dbl;
@@ -77,7 +77,7 @@
int lead; /* sig figs before decimal or group sep */
int ndig; /* actual number of digits returned by dtoa */
CHAR_TYPE expstr[MAXEXPDIG + 2]; /* buffer for exponent string: e+ZZZ */
- char* dtoaresult = NULL;
+ char* dtoaresult = nullptr;
uintmax_t _umax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */
@@ -146,14 +146,14 @@
}
CHAR_TYPE* fmt = const_cast<CHAR_TYPE*>(fmt0);
- argtable = NULL;
+ argtable = nullptr;
nextarg = 1;
va_copy(orgap, ap);
uio.uio_iov = iovp = iov;
uio.uio_resid = 0;
uio.uio_iovcnt = 0;
ret = 0;
- convbuf = NULL;
+ convbuf = nullptr;
/*
* Scan the format for conversions (`%' character).
@@ -226,7 +226,7 @@
}
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -261,7 +261,7 @@
} while (is_digit(ch));
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -353,14 +353,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = cp = __hldtoa(fparg.ldbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp = __hdtoa(fparg.dbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -390,14 +390,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = cp = __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp = __dtoa(fparg.dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -479,18 +479,18 @@
wchar_t* wcp;
free(convbuf);
- convbuf = NULL;
- if ((wcp = GETARG(wchar_t*)) == NULL) {
+ convbuf = nullptr;
+ if ((wcp = GETARG(wchar_t*)) == nullptr) {
cp = const_cast<char*>("(null)");
} else {
convbuf = helpers::wcsconv(wcp, prec);
- if (convbuf == NULL) {
+ if (convbuf == nullptr) {
ret = -1;
goto error;
}
cp = convbuf;
}
- } else if ((cp = GETARG(char*)) == NULL) {
+ } else if ((cp = GETARG(char*)) == nullptr) {
cp = const_cast<char*>("(null)");
}
if (prec >= 0) {
@@ -625,7 +625,7 @@
if ((flags & FPT) == 0) {
PRINT(cp, size);
} else { /* glue together f_p fragments */
- if (decimal_point == NULL) decimal_point = nl_langinfo(RADIXCHAR);
+ if (decimal_point == nullptr) decimal_point = nl_langinfo(RADIXCHAR);
if (!expchar) { /* %[fF] or sufficiently short %[gG] */
if (expt <= 0) {
PRINT(zeroes, 1);
@@ -676,9 +676,9 @@
finish:
free(convbuf);
if (dtoaresult) __freedtoa(dtoaresult);
- if (argtable != NULL && argtable != statargtable) {
+ if (argtable != nullptr && argtable != statargtable) {
munmap(argtable, argtablesiz);
- argtable = NULL;
+ argtable = nullptr;
}
return (ret);
}
diff --git a/libc/stdio/vfscanf.cpp b/libc/stdio/vfscanf.cpp
index 49d6bf6..0fcdbed 100644
--- a/libc/stdio/vfscanf.cpp
+++ b/libc/stdio/vfscanf.cpp
@@ -97,7 +97,7 @@
char buf[BUF]; /* buffer for numeric conversions */
size_t nconv; /* length of multibyte sequence converted */
mbstate_t mbs;
- void* allocation = NULL; // Allocated but unassigned result for %mc/%ms/%m[.
+ void* allocation = nullptr; // Allocated but unassigned result for %mc/%ms/%m[.
size_t capacity = 0; // Number of char/wchar_t units allocated in `allocation`.
/* `basefix' is used to avoid `if' tests in the integer scanner */
@@ -334,9 +334,9 @@
if (flags & LONG) {
if (flags & ALLOCATE) {
allocation = wcp = reinterpret_cast<wchar_t*>(malloc(width * sizeof(wchar_t)));
- if (allocation == NULL) goto allocation_failure;
+ if (allocation == nullptr) goto allocation_failure;
} else if (flags & SUPPRESS) {
- wcp = NULL;
+ wcp = nullptr;
} else {
wcp = va_arg(ap, wchar_t*);
}
@@ -370,9 +370,9 @@
break;
}
}
- if (allocation != NULL) {
+ if (allocation != nullptr) {
*va_arg(ap, wchar_t**) = reinterpret_cast<wchar_t*>(allocation);
- allocation = NULL;
+ allocation = nullptr;
}
if (!(flags & SUPPRESS)) nassigned++;
} else if (flags & SUPPRESS) {
@@ -397,15 +397,15 @@
} else {
if (flags & ALLOCATE) {
allocation = p = reinterpret_cast<char*>(malloc(width));
- if (allocation == NULL) goto allocation_failure;
+ if (allocation == nullptr) goto allocation_failure;
} else {
p = va_arg(ap, char*);
}
size_t r = fread(p, 1, width, fp);
if (r == 0) goto input_failure;
- if (allocation != NULL) {
+ if (allocation != nullptr) {
*va_arg(ap, char**) = reinterpret_cast<char*>(allocation);
- allocation = NULL;
+ allocation = nullptr;
}
nread += r;
nassigned++;
@@ -423,9 +423,9 @@
if (flags & ALLOCATE) {
capacity = MIN(width, 32);
allocation = wcp = reinterpret_cast<wchar_t*>(malloc(sizeof(wchar_t) * capacity));
- if (allocation == NULL) goto allocation_failure;
+ if (allocation == nullptr) goto allocation_failure;
} else if (flags & SUPPRESS) {
- wcp = NULL;
+ wcp = nullptr;
} else {
wcp = va_arg(ap, wchar_t*);
}
@@ -455,11 +455,11 @@
}
if (wcp) wcp[n] = wc;
n++;
- if (allocation != NULL && n == capacity) {
+ if (allocation != nullptr && n == capacity) {
capacity *= 2;
wchar_t* new_allocation =
reinterpret_cast<wchar_t*>(realloc(allocation, sizeof(wchar_t) * capacity));
- if (new_allocation == NULL) goto allocation_failure;
+ if (new_allocation == nullptr) goto allocation_failure;
allocation = wcp = new_allocation;
}
nread += bytes;
@@ -478,9 +478,9 @@
fp->_flags |= __SERR;
goto input_failure;
}
- if (allocation != NULL) {
+ if (allocation != nullptr) {
*va_arg(ap, wchar_t**) = reinterpret_cast<wchar_t*>(allocation);
- allocation = NULL;
+ allocation = nullptr;
}
} else if (flags & SUPPRESS) {
n = 0;
@@ -497,7 +497,7 @@
if (flags & ALLOCATE) {
capacity = MIN(width, 32);
allocation = p = reinterpret_cast<char*>(malloc(capacity));
- if (allocation == NULL) goto allocation_failure;
+ if (allocation == nullptr) goto allocation_failure;
} else {
p = va_arg(ap, char*);
}
@@ -505,10 +505,10 @@
while (ccltab[*fp->_p]) {
fp->_r--;
p[n++] = *fp->_p++;
- if (allocation != NULL && n == capacity) {
+ if (allocation != nullptr && n == capacity) {
capacity *= 2;
char* new_allocation = reinterpret_cast<char*>(realloc(allocation, capacity));
- if (new_allocation == NULL) goto allocation_failure;
+ if (new_allocation == nullptr) goto allocation_failure;
allocation = p = new_allocation;
}
if (--width == 0) break;
@@ -518,9 +518,9 @@
}
}
nread += n;
- if (allocation != NULL) {
+ if (allocation != nullptr) {
*va_arg(ap, char**) = reinterpret_cast<char*>(allocation);
- allocation = NULL;
+ allocation = nullptr;
}
}
if (c == CT_CCL && n == 0) goto match_failure;
@@ -671,9 +671,9 @@
*p = '\0';
if (flags & UNSIGNED) {
- res = strtoumax(buf, NULL, base);
+ res = strtoumax(buf, nullptr, base);
} else {
- res = strtoimax(buf, NULL, base);
+ res = strtoimax(buf, nullptr, base);
}
if (flags & POINTER) {
*va_arg(ap, void**) = (void*)(uintptr_t)res;
diff --git a/libc/stdio/vfwprintf.cpp b/libc/stdio/vfwprintf.cpp
index 46b6233..ae0b62f 100644
--- a/libc/stdio/vfwprintf.cpp
+++ b/libc/stdio/vfwprintf.cpp
@@ -64,7 +64,7 @@
* D: expchar holds this character; '\0' if no exponent, e.g. %f
* F: at least two digits for decimal, at least one digit for hex
*/
- char* decimal_point = NULL;
+ char* decimal_point = nullptr;
int signflag; /* true if float is negative */
union { /* floating point arguments %[aAeEfFgG] */
double dbl;
@@ -77,7 +77,7 @@
int lead; /* sig figs before decimal or group sep */
int ndig; /* actual number of digits returned by dtoa */
CHAR_TYPE expstr[MAXEXPDIG + 2]; /* buffer for exponent string: e+ZZZ */
- char* dtoaresult = NULL;
+ char* dtoaresult = nullptr;
uintmax_t _umax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */
@@ -135,14 +135,14 @@
}
CHAR_TYPE* fmt = const_cast<CHAR_TYPE*>(fmt0);
- argtable = NULL;
+ argtable = nullptr;
nextarg = 1;
va_copy(orgap, ap);
uio.uio_iov = iovp = iov;
uio.uio_resid = 0;
uio.uio_iovcnt = 0;
ret = 0;
- convbuf = NULL;
+ convbuf = nullptr;
/*
* Scan the format for conversions (`%' character).
@@ -215,7 +215,7 @@
}
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -250,7 +250,7 @@
} while (is_digit(ch));
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -331,14 +331,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = __hldtoa(fparg.ldbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = __hdtoa(fparg.dbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -347,7 +347,7 @@
if (expt == INT_MAX) ox[1] = '\0';
free(convbuf);
cp = convbuf = helpers::mbsconv(dtoaresult, -1);
- if (cp == NULL) goto error;
+ if (cp == nullptr) goto error;
ndig = dtoaend - dtoaresult;
goto fp_common;
case 'e':
@@ -372,14 +372,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = __dtoa(fparg.dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -387,7 +387,7 @@
}
free(convbuf);
cp = convbuf = helpers::mbsconv(dtoaresult, -1);
- if (cp == NULL) goto error;
+ if (cp == nullptr) goto error;
ndig = dtoaend - dtoaresult;
fp_common:
if (signflag) sign = '-';
@@ -461,13 +461,13 @@
/*FALLTHROUGH*/
case 's':
if (flags & LONGINT) {
- if ((cp = GETARG(wchar_t*)) == NULL) cp = const_cast<wchar_t*>(L"(null)");
+ if ((cp = GETARG(wchar_t*)) == nullptr) cp = const_cast<wchar_t*>(L"(null)");
} else {
char* mbsarg;
- if ((mbsarg = GETARG(char*)) == NULL) mbsarg = const_cast<char*>("(null)");
+ if ((mbsarg = GETARG(char*)) == nullptr) mbsarg = const_cast<char*>("(null)");
free(convbuf);
convbuf = helpers::mbsconv(mbsarg, prec);
- if (convbuf == NULL) {
+ if (convbuf == nullptr) {
fp->_flags |= __SERR;
goto error;
} else {
@@ -606,7 +606,7 @@
if ((flags & FPT) == 0) {
PRINT(cp, size);
} else { /* glue together f_p fragments */
- if (decimal_point == NULL) decimal_point = nl_langinfo(RADIXCHAR);
+ if (decimal_point == nullptr) decimal_point = nl_langinfo(RADIXCHAR);
if (!expchar) { /* %[fF] or sufficiently short %[gG] */
if (expt <= 0) {
PRINT(zeroes, 1);
@@ -654,9 +654,9 @@
finish:
free(convbuf);
if (dtoaresult) __freedtoa(dtoaresult);
- if (argtable != NULL && argtable != statargtable) {
+ if (argtable != nullptr && argtable != statargtable) {
munmap(argtable, argtablesiz);
- argtable = NULL;
+ argtable = nullptr;
}
return (ret);
}
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index d5c3647..d7c441b 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -214,7 +214,7 @@
int SystemProperties::Get(const char* name, char* value) {
const prop_info* pi = Find(name);
- if (pi != 0) {
+ if (pi != nullptr) {
return Read(pi, nullptr, value);
} else {
value[0] = 0;
diff --git a/linker/linker.cpp b/linker/linker.cpp
index cfa8c8f..94c318c 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3486,11 +3486,11 @@
"(new hash type from the future?)", get_realpath());
return false;
}
- if (strtab_ == 0) {
+ if (strtab_ == nullptr) {
DL_ERR("empty/missing DT_STRTAB in \"%s\"", get_realpath());
return false;
}
- if (symtab_ == 0) {
+ if (symtab_ == nullptr) {
DL_ERR("empty/missing DT_SYMTAB in \"%s\"", get_realpath());
return false;
}
diff --git a/tests/TemporaryFile.h b/tests/TemporaryFile.h
index 070b71a..8af92d4 100644
--- a/tests/TemporaryFile.h
+++ b/tests/TemporaryFile.h
@@ -80,7 +80,7 @@
private:
bool init(const char* tmp_dir) {
snprintf(dirname, sizeof(dirname), "%s/TemporaryDir-XXXXXX", tmp_dir);
- return (mkdtemp(dirname) != NULL);
+ return (mkdtemp(dirname) != nullptr);
}
DISALLOW_COPY_AND_ASSIGN(TemporaryDir);
diff --git a/tests/async_safe_test.cpp b/tests/async_safe_test.cpp
index e71ba7a..4940e3a 100644
--- a/tests/async_safe_test.cpp
+++ b/tests/async_safe_test.cpp
@@ -36,7 +36,7 @@
async_safe_format_buffer(buf, sizeof(buf), "a%sb", "01234");
EXPECT_STREQ("a01234b", buf);
- char* s = NULL;
+ char* s = nullptr;
async_safe_format_buffer(buf, sizeof(buf), "a%sb", s);
EXPECT_STREQ("a(null)b", buf);
@@ -97,7 +97,7 @@
async_safe_format_buffer(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5);
EXPECT_STREQ("a005:5:05z", buf);
- void* p = NULL;
+ void* p = nullptr;
async_safe_format_buffer(buf, sizeof(buf), "a%d,%pz", 5, p);
EXPECT_STREQ("a5,0x0z", buf);
diff --git a/tests/buffer_tests.h b/tests/buffer_tests.h
index 315083b..d496d51 100644
--- a/tests/buffer_tests.h
+++ b/tests/buffer_tests.h
@@ -22,16 +22,16 @@
void RunSingleBufferAlignTest(
size_t max_test_size, void (*test_func)(uint8_t*, size_t),
- size_t (*set_incr)(size_t) = NULL);
+ size_t (*set_incr)(size_t) = nullptr);
void RunSrcDstBufferAlignTest(
size_t max_test_size, void (*test_func)(uint8_t*, uint8_t*, size_t),
- size_t (*set_incr)(size_t) = NULL);
+ size_t (*set_incr)(size_t) = nullptr);
void RunCmpBufferAlignTest(
size_t max_test_size, void (*test_cmp_func)(uint8_t*, uint8_t*, size_t),
void (*test_miscmp_func)(uint8_t*, uint8_t*, size_t, size_t),
- size_t (*set_incr)(size_t) = NULL);
+ size_t (*set_incr)(size_t) = nullptr);
void RunSingleBufferOverreadTest(void (*test_func)(uint8_t*, size_t));
diff --git a/tests/bug_26110743_test.cpp b/tests/bug_26110743_test.cpp
index ef474a0..89c6dcc 100644
--- a/tests/bug_26110743_test.cpp
+++ b/tests/bug_26110743_test.cpp
@@ -42,15 +42,15 @@
static void* ProcSelfReadlink(void*) {
ProcSelfReadlinkBody();
- return NULL;
+ return nullptr;
}
TEST(bug_26110743, ProcSelfReadlink) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ProcSelfReadlink, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ProcSelfReadlink, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
TEST(bug_26110743, ProcSelfReadlink_NotDumpable) {
@@ -62,10 +62,10 @@
});
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ProcSelfReadlink, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ProcSelfReadlink, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
static void ProcTaskFdReadlinkBody() {
@@ -86,15 +86,15 @@
static void* ProcTaskFdReadlink(void*) {
ProcTaskFdReadlinkBody();
- return NULL;
+ return nullptr;
}
TEST(bug_26110743, ProcTaskFdReadlink) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ProcTaskFdReadlink, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ProcTaskFdReadlink, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
TEST(bug_26110743, ProcTaskFdReadlink_NotDumpable) {
@@ -106,8 +106,8 @@
});
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ProcTaskFdReadlink, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ProcTaskFdReadlink, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
diff --git a/tests/dirent_test.cpp b/tests/dirent_test.cpp
index fa05ca1..378aea4 100644
--- a/tests/dirent_test.cpp
+++ b/tests/dirent_test.cpp
@@ -51,11 +51,11 @@
TEST(dirent, scandir_scandir64) {
// Get everything from /proc/self...
dirent** entries;
- int entry_count = scandir("/proc/self", &entries, NULL, alphasort);
+ int entry_count = scandir("/proc/self", &entries, nullptr, alphasort);
ASSERT_GE(entry_count, 0);
dirent64** entries64;
- int entry_count64 = scandir64("/proc/self", &entries64, NULL, alphasort64);
+ int entry_count64 = scandir64("/proc/self", &entries64, nullptr, alphasort64);
ASSERT_EQ(entry_count, entry_count64);
// Turn the directory entries into a set and vector of the names.
@@ -84,18 +84,18 @@
TEST(dirent, scandirat_scandirat64) {
// Get everything from /proc/self...
dirent** entries;
- int entry_count = scandir("/proc/self", &entries, NULL, alphasort);
+ int entry_count = scandir("/proc/self", &entries, nullptr, alphasort);
ASSERT_GE(entry_count, 0);
int proc_fd = open("/proc", O_DIRECTORY);
ASSERT_NE(-1, proc_fd);
dirent** entries_at;
- int entry_count_at = scandirat(proc_fd, "self", &entries_at, NULL, alphasort);
+ int entry_count_at = scandirat(proc_fd, "self", &entries_at, nullptr, alphasort);
ASSERT_EQ(entry_count, entry_count_at);
dirent64** entries_at64;
- int entry_count_at64 = scandirat64(proc_fd, "self", &entries_at64, NULL, alphasort64);
+ int entry_count_at64 = scandirat64(proc_fd, "self", &entries_at64, nullptr, alphasort64);
ASSERT_EQ(entry_count, entry_count_at64);
close(proc_fd);
@@ -148,12 +148,12 @@
}
TEST(dirent, fdopendir_invalid) {
- ASSERT_TRUE(fdopendir(-1) == NULL);
+ ASSERT_TRUE(fdopendir(-1) == nullptr);
ASSERT_EQ(EBADF, errno);
int fd = open("/dev/null", O_RDONLY);
ASSERT_NE(fd, -1);
- ASSERT_TRUE(fdopendir(fd) == NULL);
+ ASSERT_TRUE(fdopendir(fd) == nullptr);
ASSERT_EQ(ENOTDIR, errno);
close(fd);
}
@@ -161,7 +161,7 @@
TEST(dirent, fdopendir) {
int fd = open("/proc/self", O_RDONLY);
DIR* d = fdopendir(fd);
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
dirent* e = readdir(d);
ASSERT_STREQ(e->d_name, ".");
ASSERT_EQ(closedir(d), 0);
@@ -172,40 +172,40 @@
}
TEST(dirent, opendir_invalid) {
- ASSERT_TRUE(opendir("/does/not/exist") == NULL);
+ ASSERT_TRUE(opendir("/does/not/exist") == nullptr);
ASSERT_EQ(ENOENT, errno);
- ASSERT_TRUE(opendir("/dev/null") == NULL);
+ ASSERT_TRUE(opendir("/dev/null") == nullptr);
ASSERT_EQ(ENOTDIR, errno);
}
TEST(dirent, opendir) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
dirent* e = readdir(d);
ASSERT_STREQ(e->d_name, ".");
ASSERT_EQ(closedir(d), 0);
}
TEST(dirent, closedir_invalid) {
- DIR* d = NULL;
+ DIR* d = nullptr;
ASSERT_EQ(closedir(d), -1);
ASSERT_EQ(EINVAL, errno);
}
TEST(dirent, closedir) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
ASSERT_EQ(closedir(d), 0);
}
TEST(dirent, readdir) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
std::set<std::string> name_set;
errno = 0;
dirent* e;
- while ((e = readdir(d)) != NULL) {
+ while ((e = readdir(d)) != nullptr) {
name_set.insert(e->d_name);
}
// Reading to the end of the directory is not an error.
@@ -218,11 +218,11 @@
TEST(dirent, readdir64) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
std::set<std::string> name_set;
errno = 0;
dirent64* e;
- while ((e = readdir64(d)) != NULL) {
+ while ((e = readdir64(d)) != nullptr) {
name_set.insert(e->d_name);
}
// Reading to the end of the directory is not an error.
@@ -235,12 +235,12 @@
TEST(dirent, readdir_r) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
std::set<std::string> name_set;
errno = 0;
dirent storage;
- dirent* e = NULL;
- while (readdir_r(d, &storage, &e) == 0 && e != NULL) {
+ dirent* e = nullptr;
+ while (readdir_r(d, &storage, &e) == 0 && e != nullptr) {
name_set.insert(e->d_name);
}
// Reading to the end of the directory is not an error.
@@ -253,12 +253,12 @@
TEST(dirent, readdir64_r) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
std::set<std::string> name_set;
errno = 0;
dirent64 storage;
- dirent64* e = NULL;
- while (readdir64_r(d, &storage, &e) == 0 && e != NULL) {
+ dirent64* e = nullptr;
+ while (readdir64_r(d, &storage, &e) == 0 && e != nullptr) {
name_set.insert(e->d_name);
}
// Reading to the end of the directory is not an error.
@@ -271,12 +271,12 @@
TEST(dirent, rewinddir) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
// Get all the names once...
std::vector<std::string> pass1;
dirent* e;
- while ((e = readdir(d)) != NULL) {
+ while ((e = readdir(d)) != nullptr) {
pass1.push_back(e->d_name);
}
@@ -285,7 +285,7 @@
// ...and get all the names again.
std::vector<std::string> pass2;
- while ((e = readdir(d)) != NULL) {
+ while ((e = readdir(d)) != nullptr) {
pass2.push_back(e->d_name);
}
@@ -300,15 +300,15 @@
TEST(dirent, seekdir_telldir) {
DIR* d = opendir("/proc/self");
- ASSERT_TRUE(d != NULL);
+ ASSERT_TRUE(d != nullptr);
std::vector<long> offset_list;
std::vector<std::string> name_list;
- dirent* e = NULL;
+ dirent* e = nullptr;
offset_list.push_back(telldir(d));
ASSERT_EQ(0L, offset_list.back());
- while ((e = readdir(d)) != NULL) {
+ while ((e = readdir(d)) != nullptr) {
name_list.push_back(e->d_name);
offset_list.push_back(telldir(d));
// Make sure telldir() point to the next entry.
@@ -324,14 +324,14 @@
seekdir(d, offset_list[i]);
ASSERT_EQ(offset_list[i], telldir(d));
e = readdir(d);
- ASSERT_TRUE(e != NULL);
+ ASSERT_TRUE(e != nullptr);
ASSERT_STREQ(name_list[i].c_str(), e->d_name);
}
for (int i = static_cast<int>(offset_list.size()) - 1; i >= 0; --i) {
seekdir(d, offset_list[i]);
ASSERT_EQ(offset_list[i], telldir(d));
e = readdir(d);
- ASSERT_TRUE(e != NULL);
+ ASSERT_TRUE(e != nullptr);
ASSERT_STREQ(name_list[i].c_str(), e->d_name);
}
@@ -339,7 +339,7 @@
seekdir(d, end_offset);
ASSERT_EQ(end_offset, telldir(d));
errno = 0;
- ASSERT_EQ(NULL, readdir(d));
+ ASSERT_EQ(nullptr, readdir(d));
ASSERT_EQ(0, errno);
ASSERT_EQ(0, closedir(d));
diff --git a/tests/error_test.cpp b/tests/error_test.cpp
index 5fee16f..e03c8d4 100644
--- a/tests/error_test.cpp
+++ b/tests/error_test.cpp
@@ -52,7 +52,7 @@
error_at_line(0, 0, "blah.c", 123, "hello %s", "world");
- error_print_progname = NULL;
+ error_print_progname = nullptr;
}
TEST(error_DeathTest, error_exit) {
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
index 0a83dff..da44fee 100644
--- a/tests/fcntl_test.cpp
+++ b/tests/fcntl_test.cpp
@@ -174,10 +174,10 @@
TemporaryFile tf;
- ssize_t bytes_read = splice(in, 0, pipe_fds[1], NULL, 8*1024, SPLICE_F_MORE | SPLICE_F_MOVE);
+ ssize_t bytes_read = splice(in, nullptr, pipe_fds[1], nullptr, 8*1024, SPLICE_F_MORE | SPLICE_F_MOVE);
ASSERT_NE(bytes_read, -1);
- ssize_t bytes_written = splice(pipe_fds[0], NULL, tf.fd, 0, bytes_read, SPLICE_F_MORE | SPLICE_F_MOVE);
+ ssize_t bytes_written = splice(pipe_fds[0], nullptr, tf.fd, nullptr, bytes_read, SPLICE_F_MORE | SPLICE_F_MOVE);
ASSERT_EQ(bytes_read, bytes_written);
close(pipe_fds[0]);
@@ -200,8 +200,8 @@
char buf[BUFSIZ];
FILE* fp = fdopen(pipe_fds[0], "r");
- ASSERT_TRUE(fp != NULL);
- ASSERT_TRUE(fgets(buf, sizeof(buf), fp) != NULL);
+ ASSERT_TRUE(fp != nullptr);
+ ASSERT_TRUE(fgets(buf, sizeof(buf), fp) != nullptr);
fclose(fp);
ASSERT_STREQ("hello world\n", buf);
}
@@ -209,8 +209,8 @@
TEST(fcntl, tee) {
char expected[BUFSIZ];
FILE* expected_fp = fopen("/proc/version", "r");
- ASSERT_TRUE(expected_fp != NULL);
- ASSERT_TRUE(fgets(expected, sizeof(expected), expected_fp) != NULL);
+ ASSERT_TRUE(expected_fp != nullptr);
+ ASSERT_TRUE(fgets(expected, sizeof(expected), expected_fp) != nullptr);
fclose(expected_fp);
int pipe1[2];
@@ -223,7 +223,7 @@
ASSERT_NE(in, -1);
// Write /proc/version into pipe1.
- ssize_t bytes_read = splice(in, 0, pipe1[1], NULL, 8*1024, SPLICE_F_MORE | SPLICE_F_MOVE);
+ ssize_t bytes_read = splice(in, nullptr, pipe1[1], nullptr, 8*1024, SPLICE_F_MORE | SPLICE_F_MOVE);
ASSERT_NE(bytes_read, -1);
close(pipe1[1]);
@@ -235,14 +235,14 @@
// The out fds of both pipe1 and pipe2 should now contain /proc/version.
char buf1[BUFSIZ];
FILE* fp1 = fdopen(pipe1[0], "r");
- ASSERT_TRUE(fp1 != NULL);
- ASSERT_TRUE(fgets(buf1, sizeof(buf1), fp1) != NULL);
+ ASSERT_TRUE(fp1 != nullptr);
+ ASSERT_TRUE(fgets(buf1, sizeof(buf1), fp1) != nullptr);
fclose(fp1);
char buf2[BUFSIZ];
FILE* fp2 = fdopen(pipe2[0], "r");
- ASSERT_TRUE(fp2 != NULL);
- ASSERT_TRUE(fgets(buf2, sizeof(buf2), fp2) != NULL);
+ ASSERT_TRUE(fp2 != nullptr);
+ ASSERT_TRUE(fgets(buf2, sizeof(buf2), fp2) != nullptr);
fclose(fp2);
ASSERT_STREQ(expected, buf1);
diff --git a/tests/fortify_filecheck_diagnostics_test.cpp b/tests/fortify_filecheck_diagnostics_test.cpp
index 375a156..5629408 100644
--- a/tests/fortify_filecheck_diagnostics_test.cpp
+++ b/tests/fortify_filecheck_diagnostics_test.cpp
@@ -211,7 +211,7 @@
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__recvfrom_error' declared with attribute error: 'recvfrom' called with size bigger than buffer
// CLANG: error: 'recvfrom' called with size bigger than buffer
- recvfrom(0, buf, 6, 0, reinterpret_cast<sockaddr*>(&addr), NULL);
+ recvfrom(0, buf, 6, 0, reinterpret_cast<sockaddr*>(&addr), nullptr);
}
void test_recv() {
@@ -398,9 +398,9 @@
realpath(".", buf);
// This is fine.
- realpath(".", NULL);
+ realpath(".", nullptr);
char bigbuf[PATH_MAX];
// CLANG: error: 'realpath': NULL path is never correct; flipped arguments?
- realpath(NULL, bigbuf);
+ realpath(nullptr, bigbuf);
}
diff --git a/tests/ftw_test.cpp b/tests/ftw_test.cpp
index 91e9fcf..22ab399 100644
--- a/tests/ftw_test.cpp
+++ b/tests/ftw_test.cpp
@@ -50,8 +50,8 @@
}
void sanity_check_ftw(const char* fpath, const struct stat* sb, int tflag) {
- ASSERT_TRUE(fpath != NULL);
- ASSERT_TRUE(sb != NULL);
+ ASSERT_TRUE(fpath != nullptr);
+ ASSERT_TRUE(sb != nullptr);
// Was it a case where the struct stat we're given is meaningless?
if (tflag == FTW_NS || tflag == FTW_SLN) {
diff --git a/tests/getcwd_test.cpp b/tests/getcwd_test.cpp
index b3b4136..f8f205e 100644
--- a/tests/getcwd_test.cpp
+++ b/tests/getcwd_test.cpp
@@ -23,8 +23,8 @@
TEST(getcwd, auto_full) {
// If we let the library do all the work, everything's fine.
errno = 0;
- char* cwd = getcwd(NULL, 0);
- ASSERT_TRUE(cwd != NULL);
+ char* cwd = getcwd(nullptr, 0);
+ ASSERT_TRUE(cwd != nullptr);
ASSERT_EQ(0, errno);
ASSERT_GE(strlen(cwd), 1U);
free(cwd);
@@ -33,8 +33,8 @@
TEST(getcwd, auto_reasonable) {
// If we ask the library to allocate a reasonable buffer, everything's fine.
errno = 0;
- char* cwd = getcwd(NULL, PATH_MAX);
- ASSERT_TRUE(cwd != NULL);
+ char* cwd = getcwd(nullptr, PATH_MAX);
+ ASSERT_TRUE(cwd != nullptr);
ASSERT_EQ(0, errno);
ASSERT_GE(strlen(cwd), 1U);
free(cwd);
@@ -43,16 +43,16 @@
TEST(getcwd, auto_too_small) {
// If we ask the library to allocate a too-small buffer, ERANGE.
errno = 0;
- char* cwd = getcwd(NULL, 1);
- ASSERT_TRUE(cwd == NULL);
+ char* cwd = getcwd(nullptr, 1);
+ ASSERT_TRUE(cwd == nullptr);
ASSERT_EQ(ERANGE, errno);
}
TEST(getcwd, auto_too_large) {
// If we ask the library to allocate an unreasonably large buffer, ERANGE.
errno = 0;
- char* cwd = getcwd(NULL, static_cast<size_t>(-1));
- ASSERT_TRUE(cwd == NULL);
+ char* cwd = getcwd(nullptr, static_cast<size_t>(-1));
+ ASSERT_TRUE(cwd == nullptr);
ASSERT_EQ(ENOMEM, errno);
}
@@ -61,7 +61,7 @@
char tiny_buf[1];
errno = 0;
char* cwd = getcwd(tiny_buf, sizeof(tiny_buf));
- ASSERT_TRUE(cwd == NULL);
+ ASSERT_TRUE(cwd == nullptr);
ASSERT_EQ(ERANGE, errno);
}
@@ -70,7 +70,7 @@
char tiny_buf[1];
errno = 0;
char* cwd = getcwd(tiny_buf, 0);
- ASSERT_TRUE(cwd == NULL);
+ ASSERT_TRUE(cwd == nullptr);
ASSERT_EQ(EINVAL, errno);
}
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 2df1ef0..68897ed 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -50,15 +50,15 @@
static void check_passwd(const passwd* pwd, const char* username, uid_t uid, uid_type_t uid_type,
bool check_username) {
- ASSERT_TRUE(pwd != NULL);
+ ASSERT_TRUE(pwd != nullptr);
if (check_username) {
EXPECT_STREQ(username, pwd->pw_name);
}
EXPECT_EQ(uid, pwd->pw_uid);
EXPECT_EQ(uid, pwd->pw_gid);
- EXPECT_EQ(NULL, pwd->pw_passwd);
+ EXPECT_EQ(nullptr, pwd->pw_passwd);
#ifdef __LP64__
- EXPECT_EQ(NULL, pwd->pw_gecos);
+ EXPECT_EQ(nullptr, pwd->pw_gecos);
#endif
if (uid_type == TYPE_SYSTEM) {
@@ -94,7 +94,7 @@
int result;
errno = 0;
- passwd* pwd = NULL;
+ passwd* pwd = nullptr;
result = getpwuid_r(uid, &pwd_storage, buf, sizeof(buf), &pwd);
ASSERT_EQ(0, result);
ASSERT_EQ(0, errno);
@@ -109,7 +109,7 @@
int result;
errno = 0;
- passwd* pwd = NULL;
+ passwd* pwd = nullptr;
result = getpwnam_r(username, &pwd_storage, buf, sizeof(buf), &pwd);
ASSERT_EQ(0, result);
ASSERT_EQ(0, errno);
@@ -264,15 +264,15 @@
std::set<uid_t> uids;
setpwent();
- while ((pwd = getpwent()) != NULL) {
- ASSERT_TRUE(NULL != pwd->pw_name);
+ while ((pwd = getpwent()) != nullptr) {
+ ASSERT_TRUE(nullptr != pwd->pw_name);
EXPECT_EQ(pwd->pw_gid, pwd->pw_uid) << "pwd->pw_uid: " << pwd->pw_uid;
- EXPECT_EQ(NULL, pwd->pw_passwd) << "pwd->pw_uid: " << pwd->pw_uid;
+ EXPECT_EQ(nullptr, pwd->pw_passwd) << "pwd->pw_uid: " << pwd->pw_uid;
#ifdef __LP64__
- EXPECT_TRUE(NULL == pwd->pw_gecos) << "pwd->pw_uid: " << pwd->pw_uid;
+ EXPECT_TRUE(nullptr == pwd->pw_gecos) << "pwd->pw_uid: " << pwd->pw_uid;
#endif
- EXPECT_TRUE(NULL != pwd->pw_shell);
+ EXPECT_TRUE(nullptr != pwd->pw_shell);
if (pwd->pw_uid < AID_APP_START || pwd->pw_uid == AID_OVERFLOWUID) {
EXPECT_STREQ("/", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid;
} else {
@@ -299,16 +299,16 @@
static void check_group(const group* grp, const char* group_name, gid_t gid,
bool check_groupname = true) {
- ASSERT_TRUE(grp != NULL);
+ ASSERT_TRUE(grp != nullptr);
if (check_groupname) {
EXPECT_STREQ(group_name, grp->gr_name);
}
EXPECT_EQ(gid, grp->gr_gid);
- ASSERT_TRUE(grp->gr_mem != NULL);
+ ASSERT_TRUE(grp->gr_mem != nullptr);
if (check_groupname) {
EXPECT_STREQ(group_name, grp->gr_mem[0]);
}
- EXPECT_TRUE(grp->gr_mem[1] == NULL);
+ EXPECT_TRUE(grp->gr_mem[1] == nullptr);
}
#if defined(__BIONIC__)
@@ -523,11 +523,11 @@
std::set<gid_t> gids;
setgrent();
- while ((grp = getgrent()) != NULL) {
- ASSERT_TRUE(grp->gr_name != NULL) << "grp->gr_gid: " << grp->gr_gid;
- ASSERT_TRUE(grp->gr_mem != NULL) << "grp->gr_gid: " << grp->gr_gid;
+ while ((grp = getgrent()) != nullptr) {
+ ASSERT_TRUE(grp->gr_name != nullptr) << "grp->gr_gid: " << grp->gr_gid;
+ ASSERT_TRUE(grp->gr_mem != nullptr) << "grp->gr_gid: " << grp->gr_gid;
EXPECT_STREQ(grp->gr_name, grp->gr_mem[0]) << "grp->gr_gid: " << grp->gr_gid;
- EXPECT_TRUE(grp->gr_mem[1] == NULL) << "grp->gr_gid: " << grp->gr_gid;
+ EXPECT_TRUE(grp->gr_mem[1] == nullptr) << "grp->gr_gid: " << grp->gr_gid;
// TODO(b/27999086): fix this check with the OEM range
// If OEMs add their own AIDs to private/android_filesystem_config.h, this check will fail.
diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp
index 8aa94bb..ba29825 100644
--- a/tests/gtest_main.cpp
+++ b/tests/gtest_main.cpp
@@ -263,7 +263,7 @@
class TestResultPrinter : public testing::EmptyTestEventListener {
public:
- TestResultPrinter() : pinfo_(NULL) {}
+ TestResultPrinter() : pinfo_(nullptr) {}
virtual void OnTestStart(const testing::TestInfo& test_info) {
pinfo_ = &test_info; // Record test_info for use in OnTestPartResult.
}
@@ -566,7 +566,7 @@
time_t epoch_iteration_start_time,
int64_t elapsed_time_ns) {
FILE* fp = fopen(xml_output_filename.c_str(), "we");
- if (fp == NULL) {
+ if (fp == nullptr) {
fprintf(stderr, "failed to open '%s': %s\n", xml_output_filename.c_str(), strerror(errno));
exit(1);
}
@@ -683,7 +683,7 @@
strcpy(filter_arg, "--gtest_filter=");
strcat(filter_arg, test_name.c_str());
new_argv[argc] = filter_arg;
- new_argv[argc + 1] = NULL;
+ new_argv[argc + 1] = nullptr;
int new_argc = argc + 1;
testing::InitGoogleTest(&new_argc, new_argv);
@@ -848,7 +848,7 @@
timespec sleep_time;
sleep_time.tv_sec = 0;
sleep_time.tv_nsec = 1000000;
- nanosleep(&sleep_time, NULL);
+ nanosleep(&sleep_time, nullptr);
}
}
@@ -922,7 +922,7 @@
++iteration) {
OnTestIterationStartPrint(testcase_list, iteration, iteration_count, job_count);
int64_t iteration_start_time_ns = NanoTime();
- time_t epoch_iteration_start_time = time(NULL);
+ time_t epoch_iteration_start_time = time(nullptr);
// Run up to job_count tests in parallel, each test in a child process.
std::vector<ChildProcInfo> child_proc_list;
@@ -1159,8 +1159,8 @@
}
// Make absolute path.
if (success && output[0] != '/') {
- char* cwd = getcwd(NULL, 0);
- if (cwd != NULL) {
+ char* cwd = getcwd(nullptr, 0);
+ if (cwd != nullptr) {
output = std::string(cwd) + "/" + output;
free(cwd);
} else {
@@ -1223,7 +1223,7 @@
std::vector<TestCase> testcase_list;
argc = static_cast<int>(arg_list.size());
- arg_list.push_back(NULL);
+ arg_list.push_back(nullptr);
if (EnumerateTests(argc, arg_list.data(), testcase_list) == false) {
return 1;
}
@@ -1232,7 +1232,7 @@
return all_test_passed ? 0 : 1;
} else {
argc = static_cast<int>(arg_list.size());
- arg_list.push_back(NULL);
+ arg_list.push_back(nullptr);
testing::InitGoogleTest(&argc, arg_list.data());
return RUN_ALL_TESTS();
}
diff --git a/tests/inttypes_test.cpp b/tests/inttypes_test.cpp
index 08258ac..f7dfdb5 100644
--- a/tests/inttypes_test.cpp
+++ b/tests/inttypes_test.cpp
@@ -123,13 +123,13 @@
TEST(inttypes, strtoimax_EINVAL) {
errno = 0;
- strtoimax("123", NULL, -1);
+ strtoimax("123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- strtoimax("123", NULL, 1);
+ strtoimax("123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- strtoimax("123", NULL, 37);
+ strtoimax("123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
@@ -153,37 +153,37 @@
TEST(inttypes, strtoumax_EINVAL) {
errno = 0;
- strtoumax("123", NULL, -1);
+ strtoumax("123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- strtoumax("123", NULL, 1);
+ strtoumax("123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- strtoumax("123", NULL, 37);
+ strtoumax("123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(inttypes, wcstoimax_EINVAL) {
errno = 0;
- wcstoimax(L"123", NULL, -1);
+ wcstoimax(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoimax(L"123", NULL, 1);
+ wcstoimax(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoimax(L"123", NULL, 37);
+ wcstoimax(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(inttypes, wcstoumax_EINVAL) {
errno = 0;
- wcstoumax(L"123", NULL, -1);
+ wcstoumax(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoumax(L"123", NULL, 1);
+ wcstoumax(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoumax(L"123", NULL, 37);
+ wcstoumax(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
diff --git a/tests/libgen_basename_test.cpp b/tests/libgen_basename_test.cpp
index d97e0da..91ae960 100644
--- a/tests/libgen_basename_test.cpp
+++ b/tests/libgen_basename_test.cpp
@@ -49,7 +49,7 @@
}
static void __TestPosixBasename(const char* in, const char* expected_out, int line) {
- char* writable_in = (in != NULL) ? strdup(in) : NULL;
+ char* writable_in = (in != nullptr) ? strdup(in) : nullptr;
errno = 0;
const char* out = posix_basename(&writable_in[0]);
ASSERT_STREQ(expected_out, out) << "(" << line << "): " << in << std::endl;
@@ -76,7 +76,7 @@
}
TEST(libgen_basename, posix_basename) {
- TestPosixBasename(NULL, ".");
+ TestPosixBasename(nullptr, ".");
TestPosixBasename("", ".");
TestPosixBasename("/usr/lib", "lib");
TestPosixBasename("/system/bin/sh/", "sh");
diff --git a/tests/libgen_test.cpp b/tests/libgen_test.cpp
index 8a37a3f..d5b5eb6 100644
--- a/tests/libgen_test.cpp
+++ b/tests/libgen_test.cpp
@@ -20,7 +20,7 @@
#include <gtest/gtest.h>
static void TestDirname(const char* in, const char* expected_out) {
- char* writable_in = (in != NULL) ? strdup(in) : NULL;
+ char* writable_in = (in != nullptr) ? strdup(in) : nullptr;
errno = 0;
const char* out = dirname(&writable_in[0]);
ASSERT_STREQ(expected_out, out) << in;
@@ -29,7 +29,7 @@
}
TEST(libgen, dirname) {
- TestDirname(NULL, ".");
+ TestDirname(nullptr, ".");
TestDirname("", ".");
TestDirname("/usr/lib", "/usr");
TestDirname("/usr/", "/");
@@ -45,7 +45,7 @@
errno = 0;
int rc = basename_r(in, buf, buf_size);
ASSERT_EQ(expected_rc, rc) << in;
- if (rc != -1 && buf != NULL) {
+ if (rc != -1 && buf != nullptr) {
ASSERT_STREQ(expected_out, buf) << in;
}
ASSERT_EQ(expected_errno, errno) << in;
@@ -56,7 +56,7 @@
errno = 0;
int rc = dirname_r(in, buf, buf_size);
ASSERT_EQ(expected_rc, rc) << in;
- if (rc != -1 && buf != NULL) {
+ if (rc != -1 && buf != nullptr) {
ASSERT_STREQ(expected_out, buf) << in;
}
ASSERT_EQ(expected_errno, errno) << in;
@@ -66,7 +66,7 @@
TEST(libgen, basename_r) {
#if defined(__BIONIC__) && !defined(__LP64__)
char buf[256];
- TestBasename("", ".", 1, NULL, 0, 0);
+ TestBasename("", ".", 1, nullptr, 0, 0);
TestBasename("", ".", -1, buf, 0, ERANGE);
TestBasename("", ".", -1, buf, 1, ERANGE);
TestBasename("", ".", 1, buf, 2, 0);
@@ -85,7 +85,7 @@
TEST(libgen, dirname_r) {
#if defined(__BIONIC__) && !defined(__LP64__)
char buf[256];
- TestDirname("", ".", 1, NULL, 0, 0);
+ TestDirname("", ".", 1, nullptr, 0, 0);
TestDirname("", ".", -1, buf, 0, ERANGE);
TestDirname("", ".", -1, buf, 1, ERANGE);
TestDirname("", ".", 1, buf, 2, 0);
diff --git a/tests/libs/dlopen_testlib_ifunc.cpp b/tests/libs/dlopen_testlib_ifunc.cpp
index f8acba7..f2e0025 100644
--- a/tests/libs/dlopen_testlib_ifunc.cpp
+++ b/tests/libs/dlopen_testlib_ifunc.cpp
@@ -61,7 +61,7 @@
extern "C" fn_ptr foo_ifunc() {
char* choice = getenv("IFUNC_CHOICE");
- return choice == NULL ? f1 : f2;
+ return choice == nullptr ? f1 : f2;
}
extern "C" const char* foo_library() {
diff --git a/tests/libs/dlopen_testlib_ifunc_variable_impl.cpp b/tests/libs/dlopen_testlib_ifunc_variable_impl.cpp
index a550fef..4b13eba 100644
--- a/tests/libs/dlopen_testlib_ifunc_variable_impl.cpp
+++ b/tests/libs/dlopen_testlib_ifunc_variable_impl.cpp
@@ -49,5 +49,5 @@
extern "C" void* foo_ifunc() {
char* choice = getenv("IFUNC_CHOICE");
- return choice == NULL ? &v1 : &v2;
+ return choice == nullptr ? &v1 : &v2;
}
diff --git a/tests/locale_test.cpp b/tests/locale_test.cpp
index 8b38c40..b4da6de 100644
--- a/tests/locale_test.cpp
+++ b/tests/locale_test.cpp
@@ -48,14 +48,14 @@
}
TEST(locale, setlocale) {
- EXPECT_STREQ("C.UTF-8", setlocale(LC_ALL, NULL));
- EXPECT_STREQ("C.UTF-8", setlocale(LC_CTYPE, NULL));
+ EXPECT_STREQ("C.UTF-8", setlocale(LC_ALL, nullptr));
+ EXPECT_STREQ("C.UTF-8", setlocale(LC_CTYPE, nullptr));
errno = 0;
- EXPECT_EQ(NULL, setlocale(-1, NULL));
+ EXPECT_EQ(nullptr, setlocale(-1, nullptr));
EXPECT_EQ(EINVAL, errno);
errno = 0;
- EXPECT_EQ(NULL, setlocale(13, NULL));
+ EXPECT_EQ(nullptr, setlocale(13, nullptr));
EXPECT_EQ(EINVAL, errno);
#if defined(__BIONIC__)
@@ -68,53 +68,53 @@
EXPECT_STREQ("C", setlocale(LC_ALL, "POSIX"));
errno = 0;
- EXPECT_EQ(NULL, setlocale(LC_ALL, "this-is-not-a-locale"));
+ EXPECT_EQ(nullptr, setlocale(LC_ALL, "this-is-not-a-locale"));
EXPECT_EQ(ENOENT, errno); // POSIX specified, not an implementation detail!
}
TEST(locale, newlocale_invalid_category_mask) {
errno = 0;
- EXPECT_EQ(0, newlocale(1 << 20, "C", 0));
+ EXPECT_EQ(nullptr, newlocale(1 << 20, "C", nullptr));
EXPECT_EQ(EINVAL, errno);
}
TEST(locale, newlocale_NULL_locale_name) {
errno = 0;
- EXPECT_EQ(0, newlocale(LC_ALL, NULL, 0));
+ EXPECT_EQ(nullptr, newlocale(LC_ALL, nullptr, nullptr));
EXPECT_EQ(EINVAL, errno);
}
TEST(locale, newlocale_bad_locale_name) {
errno = 0;
- EXPECT_EQ(0, newlocale(LC_ALL, "this-is-not-a-locale", 0));
+ EXPECT_EQ(nullptr, newlocale(LC_ALL, "this-is-not-a-locale", nullptr));
EXPECT_EQ(ENOENT, errno); // POSIX specified, not an implementation detail!
}
TEST(locale, newlocale) {
- locale_t l = newlocale(LC_ALL, "C", 0);
- ASSERT_TRUE(l != NULL);
+ locale_t l = newlocale(LC_ALL, "C", nullptr);
+ ASSERT_TRUE(l != nullptr);
freelocale(l);
}
TEST(locale, duplocale) {
locale_t cloned_global = duplocale(LC_GLOBAL_LOCALE);
- ASSERT_TRUE(cloned_global != NULL);
+ ASSERT_TRUE(cloned_global != nullptr);
freelocale(cloned_global);
}
TEST(locale, uselocale) {
- locale_t original = uselocale(NULL);
- EXPECT_FALSE(original == 0);
+ locale_t original = uselocale(nullptr);
+ EXPECT_FALSE(original == nullptr);
EXPECT_EQ(LC_GLOBAL_LOCALE, original);
- locale_t n = newlocale(LC_ALL, "C", 0);
- EXPECT_FALSE(n == 0);
+ locale_t n = newlocale(LC_ALL, "C", nullptr);
+ EXPECT_FALSE(n == nullptr);
EXPECT_FALSE(n == original);
locale_t old = uselocale(n);
EXPECT_TRUE(old == original);
- EXPECT_EQ(n, uselocale(NULL));
+ EXPECT_EQ(n, uselocale(nullptr));
}
TEST(locale, mb_cur_max) {
@@ -122,8 +122,8 @@
// initial program conditions because (unless we're the only test that was
// run), another test has almost certainly called uselocale(3) in this thread.
// See b/16685652.
- locale_t cloc = newlocale(LC_ALL, "C", 0);
- locale_t cloc_utf8 = newlocale(LC_ALL, "C.UTF-8", 0);
+ locale_t cloc = newlocale(LC_ALL, "C", nullptr);
+ locale_t cloc_utf8 = newlocale(LC_ALL, "C.UTF-8", nullptr);
locale_t old_locale = uselocale(cloc);
ASSERT_EQ(1U, MB_CUR_MAX);
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index ddd78b0..4161c90 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -29,14 +29,14 @@
TEST(malloc, malloc_std) {
// Simple malloc test.
void *ptr = malloc(100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
free(ptr);
}
TEST(malloc, malloc_overflow) {
errno = 0;
- ASSERT_EQ(NULL, malloc(SIZE_MAX));
+ ASSERT_EQ(nullptr, malloc(SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
}
@@ -44,7 +44,7 @@
// Simple calloc test.
size_t alloc_len = 100;
char *ptr = (char *)calloc(1, alloc_len);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(alloc_len, malloc_usable_size(ptr));
for (size_t i = 0; i < alloc_len; i++) {
ASSERT_EQ(0, ptr[i]);
@@ -54,22 +54,22 @@
TEST(malloc, calloc_illegal) {
errno = 0;
- ASSERT_EQ(NULL, calloc(-1, 100));
+ ASSERT_EQ(nullptr, calloc(-1, 100));
ASSERT_EQ(ENOMEM, errno);
}
TEST(malloc, calloc_overflow) {
errno = 0;
- ASSERT_EQ(NULL, calloc(1, SIZE_MAX));
+ ASSERT_EQ(nullptr, calloc(1, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
errno = 0;
- ASSERT_EQ(NULL, calloc(SIZE_MAX, SIZE_MAX));
+ ASSERT_EQ(nullptr, calloc(SIZE_MAX, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
errno = 0;
- ASSERT_EQ(NULL, calloc(2, SIZE_MAX));
+ ASSERT_EQ(nullptr, calloc(2, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
errno = 0;
- ASSERT_EQ(NULL, calloc(SIZE_MAX, 2));
+ ASSERT_EQ(nullptr, calloc(SIZE_MAX, 2));
ASSERT_EQ(ENOMEM, errno);
}
@@ -78,7 +78,7 @@
for (size_t i = 0; i <= 12; i++) {
for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) {
char *ptr = reinterpret_cast<char*>(memalign(alignment, 100));
- ASSERT_TRUE(ptr != NULL) << "Failed at alignment " << alignment;
+ ASSERT_TRUE(ptr != nullptr) << "Failed at alignment " << alignment;
ASSERT_LE(100U, malloc_usable_size(ptr)) << "Failed at alignment " << alignment;
ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr) % ((1U << i)))
<< "Failed at alignment " << alignment;
@@ -88,14 +88,14 @@
}
TEST(malloc, memalign_overflow) {
- ASSERT_EQ(NULL, memalign(4096, SIZE_MAX));
+ ASSERT_EQ(nullptr, memalign(4096, SIZE_MAX));
}
TEST(malloc, memalign_non_power2) {
void* ptr;
for (size_t align = 0; align <= 256; align++) {
ptr = memalign(align, 1024);
- ASSERT_TRUE(ptr != NULL) << "Failed at align " << align;
+ ASSERT_TRUE(ptr != nullptr) << "Failed at align " << align;
free(ptr);
}
}
@@ -104,22 +104,22 @@
// Memalign and then realloc the pointer a couple of times.
for (size_t alignment = 1; alignment <= 4096; alignment <<= 1) {
char *ptr = (char*)memalign(alignment, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
ASSERT_EQ(0U, (intptr_t)ptr % alignment);
memset(ptr, 0x23, 100);
ptr = (char*)realloc(ptr, 200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(0x23, ptr[i]);
}
memset(ptr, 0x45, 200);
ptr = (char*)realloc(ptr, 300);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(300U, malloc_usable_size(ptr));
for (size_t i = 0; i < 200; i++) {
ASSERT_EQ(0x45, ptr[i]);
@@ -127,7 +127,7 @@
memset(ptr, 0x67, 300);
ptr = (char*)realloc(ptr, 250);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(250U, malloc_usable_size(ptr));
for (size_t i = 0; i < 250; i++) {
ASSERT_EQ(0x67, ptr[i]);
@@ -139,12 +139,12 @@
TEST(malloc, malloc_realloc_larger) {
// Realloc to a larger size, malloc is used for the original allocation.
char *ptr = (char *)malloc(100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
memset(ptr, 67, 100);
ptr = (char *)realloc(ptr, 200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(67, ptr[i]);
@@ -155,12 +155,12 @@
TEST(malloc, malloc_realloc_smaller) {
// Realloc to a smaller size, malloc is used for the original allocation.
char *ptr = (char *)malloc(200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
memset(ptr, 67, 200);
ptr = (char *)realloc(ptr, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(67, ptr[i]);
@@ -171,26 +171,26 @@
TEST(malloc, malloc_multiple_realloc) {
// Multiple reallocs, malloc is used for the original allocation.
char *ptr = (char *)malloc(200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
memset(ptr, 0x23, 200);
ptr = (char *)realloc(ptr, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(0x23, ptr[i]);
}
ptr = (char*)realloc(ptr, 50);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(50U, malloc_usable_size(ptr));
for (size_t i = 0; i < 50; i++) {
ASSERT_EQ(0x23, ptr[i]);
}
ptr = (char*)realloc(ptr, 150);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(150U, malloc_usable_size(ptr));
for (size_t i = 0; i < 50; i++) {
ASSERT_EQ(0x23, ptr[i]);
@@ -198,7 +198,7 @@
memset(ptr, 0x23, 150);
ptr = (char*)realloc(ptr, 425);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(425U, malloc_usable_size(ptr));
for (size_t i = 0; i < 150; i++) {
ASSERT_EQ(0x23, ptr[i]);
@@ -209,11 +209,11 @@
TEST(malloc, calloc_realloc_larger) {
// Realloc to a larger size, calloc is used for the original allocation.
char *ptr = (char *)calloc(1, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
ptr = (char *)realloc(ptr, 200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(0, ptr[i]);
@@ -224,11 +224,11 @@
TEST(malloc, calloc_realloc_smaller) {
// Realloc to a smaller size, calloc is used for the original allocation.
char *ptr = (char *)calloc(1, 200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
ptr = (char *)realloc(ptr, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(0, ptr[i]);
@@ -239,25 +239,25 @@
TEST(malloc, calloc_multiple_realloc) {
// Multiple reallocs, calloc is used for the original allocation.
char *ptr = (char *)calloc(1, 200);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(200U, malloc_usable_size(ptr));
ptr = (char *)realloc(ptr, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(100U, malloc_usable_size(ptr));
for (size_t i = 0; i < 100; i++) {
ASSERT_EQ(0, ptr[i]);
}
ptr = (char*)realloc(ptr, 50);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(50U, malloc_usable_size(ptr));
for (size_t i = 0; i < 50; i++) {
ASSERT_EQ(0, ptr[i]);
}
ptr = (char*)realloc(ptr, 150);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(150U, malloc_usable_size(ptr));
for (size_t i = 0; i < 50; i++) {
ASSERT_EQ(0, ptr[i]);
@@ -265,7 +265,7 @@
memset(ptr, 0, 150);
ptr = (char*)realloc(ptr, 425);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_LE(425U, malloc_usable_size(ptr));
for (size_t i = 0; i < 150; i++) {
ASSERT_EQ(0, ptr[i]);
@@ -275,12 +275,12 @@
TEST(malloc, realloc_overflow) {
errno = 0;
- ASSERT_EQ(NULL, realloc(NULL, SIZE_MAX));
+ ASSERT_EQ(nullptr, realloc(nullptr, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
void* ptr = malloc(100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
errno = 0;
- ASSERT_EQ(NULL, realloc(ptr, SIZE_MAX));
+ ASSERT_EQ(nullptr, realloc(ptr, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
free(ptr);
}
@@ -292,26 +292,26 @@
TEST(malloc, pvalloc_std) {
size_t pagesize = sysconf(_SC_PAGESIZE);
void* ptr = pvalloc(100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_TRUE((reinterpret_cast<uintptr_t>(ptr) & (pagesize-1)) == 0);
ASSERT_LE(pagesize, malloc_usable_size(ptr));
free(ptr);
}
TEST(malloc, pvalloc_overflow) {
- ASSERT_EQ(NULL, pvalloc(SIZE_MAX));
+ ASSERT_EQ(nullptr, pvalloc(SIZE_MAX));
}
TEST(malloc, valloc_std) {
size_t pagesize = sysconf(_SC_PAGESIZE);
void* ptr = pvalloc(100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != nullptr);
ASSERT_TRUE((reinterpret_cast<uintptr_t>(ptr) & (pagesize-1)) == 0);
free(ptr);
}
TEST(malloc, valloc_overflow) {
- ASSERT_EQ(NULL, valloc(SIZE_MAX));
+ ASSERT_EQ(nullptr, valloc(SIZE_MAX));
}
#endif
diff --git a/tests/mntent_test.cpp b/tests/mntent_test.cpp
index 3fb2f86..b86af9f 100644
--- a/tests/mntent_test.cpp
+++ b/tests/mntent_test.cpp
@@ -20,15 +20,15 @@
TEST(mntent, mntent_smoke) {
FILE* fp = setmntent("/proc/mounts", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
- ASSERT_TRUE(getmntent(fp) != NULL);
+ ASSERT_TRUE(getmntent(fp) != nullptr);
bool saw_proc = false;
struct mntent entry;
char buf[BUFSIZ];
- while (getmntent_r(fp, &entry, buf, sizeof(buf)) != NULL) {
+ while (getmntent_r(fp, &entry, buf, sizeof(buf)) != nullptr) {
if (strcmp(entry.mnt_fsname, "proc") == 0 && strcmp(entry.mnt_dir, "/proc") == 0) {
saw_proc = true;
}
diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp
index a624138..a805693 100644
--- a/tests/netdb_test.cpp
+++ b/tests/netdb_test.cpp
@@ -26,13 +26,13 @@
// https://code.google.com/p/android/issues/detail?id=13228
TEST(netdb, freeaddrinfo_NULL) {
- freeaddrinfo(NULL);
+ freeaddrinfo(nullptr);
}
TEST(netdb, getaddrinfo_NULL_host) {
// It's okay for the host argument to be NULL, as long as service isn't.
- addrinfo* ai = NULL;
- ASSERT_EQ(0, getaddrinfo(NULL, "smtp", NULL, &ai));
+ addrinfo* ai = nullptr;
+ ASSERT_EQ(0, getaddrinfo(nullptr, "smtp", nullptr, &ai));
// (sockaddr_in::sin_port and sockaddr_in6::sin6_port overlap.)
ASSERT_EQ(25U, ntohs(reinterpret_cast<sockaddr_in*>(ai->ai_addr)->sin_port));
freeaddrinfo(ai);
@@ -40,19 +40,19 @@
TEST(netdb, getaddrinfo_NULL_service) {
// It's okay for the service argument to be NULL, as long as host isn't.
- addrinfo* ai = NULL;
- ASSERT_EQ(0, getaddrinfo("localhost", NULL, NULL, &ai));
- ASSERT_TRUE(ai != NULL);
+ addrinfo* ai = nullptr;
+ ASSERT_EQ(0, getaddrinfo("localhost", nullptr, nullptr, &ai));
+ ASSERT_TRUE(ai != nullptr);
freeaddrinfo(ai);
}
TEST(netdb, getaddrinfo_NULL_hints) {
- addrinfo* ai = NULL;
- ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai));
+ addrinfo* ai = nullptr;
+ ASSERT_EQ(0, getaddrinfo("localhost", "9999", nullptr, &ai));
bool saw_tcp = false;
bool saw_udp = false;
- for (addrinfo* p = ai; p != NULL; p = p->ai_next) {
+ for (addrinfo* p = ai; p != nullptr; p = p->ai_next) {
ASSERT_TRUE(p->ai_family == AF_INET || p->ai_family == AF_INET6);
if (p->ai_socktype == SOCK_STREAM) {
ASSERT_EQ(IPPROTO_TCP, p->ai_protocol);
@@ -69,8 +69,8 @@
}
TEST(netdb, getaddrinfo_service_lookup) {
- addrinfo* ai = NULL;
- ASSERT_EQ(0, getaddrinfo("localhost", "smtp", NULL, &ai));
+ addrinfo* ai = nullptr;
+ ASSERT_EQ(0, getaddrinfo("localhost", "smtp", nullptr, &ai));
ASSERT_EQ(SOCK_STREAM, ai->ai_socktype);
ASSERT_EQ(IPPROTO_TCP, ai->ai_protocol);
ASSERT_EQ(25, ntohs(reinterpret_cast<sockaddr_in*>(ai->ai_addr)->sin_port));
@@ -84,13 +84,13 @@
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
- addrinfo* ai = NULL;
+ addrinfo* ai = nullptr;
ASSERT_EQ(0, getaddrinfo( "localhost", "9999", &hints, &ai));
- ASSERT_TRUE(ai != NULL);
+ ASSERT_TRUE(ai != nullptr);
// In glibc, getaddrinfo() converts ::1 to 127.0.0.1 for localhost,
// so one or two addrinfo may be returned.
addrinfo* tai = ai;
- while (tai != NULL) {
+ while (tai != nullptr) {
ASSERT_EQ(AF_INET, tai->ai_family);
ASSERT_EQ(SOCK_STREAM, tai->ai_socktype);
ASSERT_EQ(IPPROTO_TCP, tai->ai_protocol);
@@ -100,11 +100,11 @@
}
TEST(netdb, getaddrinfo_ip6_localhost) {
- addrinfo* ai = NULL;
- ASSERT_EQ(0, getaddrinfo("ip6-localhost", NULL, NULL, &ai));
- ASSERT_TRUE(ai != NULL);
+ addrinfo* ai = nullptr;
+ ASSERT_EQ(0, getaddrinfo("ip6-localhost", nullptr, nullptr, &ai));
+ ASSERT_TRUE(ai != nullptr);
ASSERT_GE(ai->ai_addrlen, static_cast<socklen_t>(sizeof(sockaddr_in6)));
- ASSERT_TRUE(ai->ai_addr != NULL);
+ ASSERT_TRUE(ai->ai_addr != nullptr);
sockaddr_in6 *addr = reinterpret_cast<sockaddr_in6*>(ai->ai_addr);
ASSERT_EQ(addr->sin6_family, AF_INET6);
ASSERT_EQ(0, memcmp(&addr->sin6_addr, &in6addr_loopback, sizeof(in6_addr)));
@@ -122,22 +122,22 @@
socklen_t just_right = sizeof(sockaddr_in);
socklen_t too_little = sizeof(sockaddr_in) - 1;
- ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
ASSERT_STREQ("0.0.0.0", tmp);
- ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
ASSERT_STREQ("0.0.0.0", tmp);
- ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
ss.ss_family = AF_INET6;
just_right = sizeof(sockaddr_in6);
too_little = sizeof(sockaddr_in6) - 1;
too_much = just_right + 1;
- ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
ASSERT_STREQ("::", tmp);
- ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
ASSERT_STREQ("::", tmp);
- ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+ ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), nullptr, 0, NI_NUMERICHOST));
}
TEST(netdb, getnameinfo_localhost) {
@@ -147,7 +147,7 @@
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(0x7f000001);
ASSERT_EQ(0, getnameinfo(reinterpret_cast<sockaddr*>(&addr), sizeof(addr),
- host, sizeof(host), NULL, 0, 0));
+ host, sizeof(host), nullptr, 0, 0));
ASSERT_STREQ(host, "localhost");
}
@@ -165,14 +165,14 @@
addr.sin6_family = AF_INET6;
addr.sin6_addr = in6addr_loopback;
ASSERT_EQ(0, getnameinfo(reinterpret_cast<sockaddr*>(&addr), sizeof(addr),
- host, sizeof(host), NULL, 0, 0));
+ host, sizeof(host), nullptr, 0, 0));
VerifyLocalhostName(host);
}
static void VerifyLocalhost(hostent *hent) {
- ASSERT_TRUE(hent != NULL);
+ ASSERT_TRUE(hent != nullptr);
VerifyLocalhostName(hent->h_name);
- for (size_t i = 0; hent->h_aliases[i] != NULL; ++i) {
+ for (size_t i = 0; hent->h_aliases[i] != nullptr; ++i) {
VerifyLocalhostName(hent->h_aliases[i]);
}
ASSERT_EQ(hent->h_addrtype, AF_INET);
@@ -273,7 +273,7 @@
int result = gethostbyname_r("localhost", &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(NETDB_INTERNAL, err);
EXPECT_EQ(ERANGE, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, gethostbyname2_r_ERANGE) {
@@ -284,7 +284,7 @@
int result = gethostbyname2_r("localhost", AF_INET, &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(NETDB_INTERNAL, err);
EXPECT_EQ(ERANGE, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, gethostbyaddr_r_ERANGE) {
@@ -296,7 +296,7 @@
int result = gethostbyaddr_r(&addr, sizeof(addr), AF_INET, &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(NETDB_INTERNAL, err);
EXPECT_EQ(ERANGE, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, gethostbyname_r_HOST_NOT_FOUND) {
@@ -307,7 +307,7 @@
int result = gethostbyname_r("does.not.exist.google.com", &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(HOST_NOT_FOUND, err);
EXPECT_EQ(0, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, gethostbyname2_r_HOST_NOT_FOUND) {
@@ -318,7 +318,7 @@
int result = gethostbyname2_r("does.not.exist.google.com", AF_INET, &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(HOST_NOT_FOUND, err);
EXPECT_EQ(0, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, gethostbyaddr_r_HOST_NOT_FOUND) {
@@ -330,7 +330,7 @@
int result = gethostbyaddr_r(&addr, sizeof(addr), AF_INET, &hent, buf, sizeof(buf), &hp, &err);
EXPECT_EQ(HOST_NOT_FOUND, err);
EXPECT_EQ(0, result);
- EXPECT_EQ(NULL, hp);
+ EXPECT_EQ(nullptr, hp);
}
TEST(netdb, getservbyname) {
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index f2f6e01..fc8945c 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -45,7 +45,7 @@
TEST(pthread, pthread_key_create) {
pthread_key_t key;
- ASSERT_EQ(0, pthread_key_create(&key, NULL));
+ ASSERT_EQ(0, pthread_key_create(&key, nullptr));
ASSERT_EQ(0, pthread_key_delete(key));
// Can't delete a key that's already been deleted.
ASSERT_EQ(EINVAL, pthread_key_delete(key));
@@ -76,7 +76,7 @@
for (int i = 0; i < nkeys; ++i) {
pthread_key_t key;
// If this fails, it's likely that LIBC_PTHREAD_KEY_RESERVED_COUNT is wrong.
- ASSERT_EQ(0, pthread_key_create(&key, NULL)) << i << " of " << nkeys;
+ ASSERT_EQ(0, pthread_key_create(&key, nullptr)) << i << " of " << nkeys;
keys.push_back(key);
ASSERT_EQ(0, pthread_setspecific(key, reinterpret_cast<void*>(i)));
}
@@ -97,7 +97,7 @@
// be more than we are allowed to allocate now.
for (int i = 0; i < PTHREAD_KEYS_MAX; i++) {
pthread_key_t key;
- rv = pthread_key_create(&key, NULL);
+ rv = pthread_key_create(&key, nullptr);
if (rv == EAGAIN) {
break;
}
@@ -119,12 +119,12 @@
TEST(pthread, pthread_key_delete) {
void* expected = reinterpret_cast<void*>(1234);
pthread_key_t key;
- ASSERT_EQ(0, pthread_key_create(&key, NULL));
+ ASSERT_EQ(0, pthread_key_create(&key, nullptr));
ASSERT_EQ(0, pthread_setspecific(key, expected));
ASSERT_EQ(expected, pthread_getspecific(key));
ASSERT_EQ(0, pthread_key_delete(key));
- // After deletion, pthread_getspecific returns NULL.
- ASSERT_EQ(NULL, pthread_getspecific(key));
+ // After deletion, pthread_getspecific returns nullptr.
+ ASSERT_EQ(nullptr, pthread_getspecific(key));
// And you can't use pthread_setspecific with the deleted key.
ASSERT_EQ(EINVAL, pthread_setspecific(key, expected));
}
@@ -132,7 +132,7 @@
TEST(pthread, pthread_key_fork) {
void* expected = reinterpret_cast<void*>(1234);
pthread_key_t key;
- ASSERT_EQ(0, pthread_key_create(&key, NULL));
+ ASSERT_EQ(0, pthread_key_create(&key, nullptr));
ASSERT_EQ(0, pthread_setspecific(key, expected));
ASSERT_EQ(expected, pthread_getspecific(key));
@@ -157,10 +157,10 @@
TEST(pthread, pthread_key_dirty) {
pthread_key_t key;
- ASSERT_EQ(0, pthread_key_create(&key, NULL));
+ ASSERT_EQ(0, pthread_key_create(&key, nullptr));
size_t stack_size = 640 * 1024;
- void* stack = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ void* stack = mmap(nullptr, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
ASSERT_NE(MAP_FAILED, stack);
memset(stack, 0xff, stack_size);
@@ -217,7 +217,7 @@
private:
static void* SpinFn(void*) {
while (spin_flag_) {}
- return NULL;
+ return nullptr;
}
static std::atomic<bool> spin_flag_;
};
@@ -228,7 +228,7 @@
std::atomic<bool> SpinFunctionHelper::spin_flag_;
static void* JoinFn(void* arg) {
- return reinterpret_cast<void*>(pthread_join(reinterpret_cast<pthread_t>(arg), NULL));
+ return reinterpret_cast<void*>(pthread_join(reinterpret_cast<pthread_t>(arg), nullptr));
}
static void AssertDetached(pthread_t t, bool is_detached) {
@@ -241,15 +241,15 @@
}
static void MakeDeadThread(pthread_t& t) {
- ASSERT_EQ(0, pthread_create(&t, NULL, IdFn, NULL));
- ASSERT_EQ(0, pthread_join(t, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, IdFn, nullptr));
+ ASSERT_EQ(0, pthread_join(t, nullptr));
}
TEST(pthread, pthread_create) {
void* expected_result = reinterpret_cast<void*>(123);
// Can we create a thread?
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, IdFn, expected_result));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, IdFn, expected_result));
// If we join, do we get the expected value back?
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
@@ -262,32 +262,32 @@
ASSERT_EQ(0, pthread_attr_setstacksize(&attributes, static_cast<size_t>(-1) & ~(getpagesize() - 1)));
pthread_t t;
- ASSERT_EQ(EAGAIN, pthread_create(&t, &attributes, IdFn, NULL));
+ ASSERT_EQ(EAGAIN, pthread_create(&t, &attributes, IdFn, nullptr));
}
TEST(pthread, pthread_no_join_after_detach) {
SpinFunctionHelper spin_helper;
pthread_t t1;
- ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
+ ASSERT_EQ(0, pthread_create(&t1, nullptr, spin_helper.GetFunction(), nullptr));
// After a pthread_detach...
ASSERT_EQ(0, pthread_detach(t1));
AssertDetached(t1, true);
// ...pthread_join should fail.
- ASSERT_EQ(EINVAL, pthread_join(t1, NULL));
+ ASSERT_EQ(EINVAL, pthread_join(t1, nullptr));
}
TEST(pthread, pthread_no_op_detach_after_join) {
SpinFunctionHelper spin_helper;
pthread_t t1;
- ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
+ ASSERT_EQ(0, pthread_create(&t1, nullptr, spin_helper.GetFunction(), nullptr));
// If thread 2 is already waiting to join thread 1...
pthread_t t2;
- ASSERT_EQ(0, pthread_create(&t2, NULL, JoinFn, reinterpret_cast<void*>(t1)));
+ ASSERT_EQ(0, pthread_create(&t2, nullptr, JoinFn, reinterpret_cast<void*>(t1)));
sleep(1); // (Give t2 a chance to call pthread_join.)
@@ -307,7 +307,7 @@
}
TEST(pthread, pthread_join_self) {
- ASSERT_EQ(EDEADLK, pthread_join(pthread_self(), NULL));
+ ASSERT_EQ(EDEADLK, pthread_join(pthread_self(), nullptr));
}
struct TestBug37410 {
@@ -317,18 +317,18 @@
static void main() {
TestBug37410 data;
data.main_thread = pthread_self();
- ASSERT_EQ(0, pthread_mutex_init(&data.mutex, NULL));
+ ASSERT_EQ(0, pthread_mutex_init(&data.mutex, nullptr));
ASSERT_EQ(0, pthread_mutex_lock(&data.mutex));
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, TestBug37410::thread_fn, reinterpret_cast<void*>(&data)));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, TestBug37410::thread_fn, reinterpret_cast<void*>(&data)));
// Wait for the thread to be running...
ASSERT_EQ(0, pthread_mutex_lock(&data.mutex));
ASSERT_EQ(0, pthread_mutex_unlock(&data.mutex));
// ...and exit.
- pthread_exit(NULL);
+ pthread_exit(nullptr);
}
private:
@@ -339,9 +339,9 @@
pthread_mutex_unlock(&data->mutex);
// And wait for the main thread to exit.
- pthread_join(data->main_thread, NULL);
+ pthread_join(data->main_thread, nullptr);
- return NULL;
+ return nullptr;
}
};
@@ -365,29 +365,29 @@
// Check that SIGUSR1 isn't blocked.
sigset_t original_set;
sigemptyset(&original_set);
- ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &original_set));
+ ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, nullptr, &original_set));
ASSERT_FALSE(sigismember(&original_set, SIGUSR1));
// Block SIGUSR1.
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
- ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL));
+ ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, nullptr));
// Check that SIGUSR1 is blocked.
sigset_t final_set;
sigemptyset(&final_set);
- ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &final_set));
+ ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, nullptr, &final_set));
ASSERT_TRUE(sigismember(&final_set, SIGUSR1));
// ...and that sigprocmask agrees with pthread_sigmask.
sigemptyset(&final_set);
- ASSERT_EQ(0, sigprocmask(SIG_BLOCK, NULL, &final_set));
+ ASSERT_EQ(0, sigprocmask(SIG_BLOCK, nullptr, &final_set));
ASSERT_TRUE(sigismember(&final_set, SIGUSR1));
// Spawn a thread that calls sigwait and tells us what it received.
pthread_t signal_thread;
int received_signal = -1;
- ASSERT_EQ(0, pthread_create(&signal_thread, NULL, SignalHandlerFn, &received_signal));
+ ASSERT_EQ(0, pthread_create(&signal_thread, nullptr, SignalHandlerFn, &received_signal));
// Send that thread SIGUSR1.
pthread_kill(signal_thread, SIGUSR1);
@@ -399,36 +399,36 @@
ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(join_result));
// Restore the original signal mask.
- ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
+ ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, nullptr));
}
TEST(pthread, pthread_sigmask64_SIGTRMIN) {
// Check that SIGRTMIN isn't blocked.
sigset64_t original_set;
sigemptyset64(&original_set);
- ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, NULL, &original_set));
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, nullptr, &original_set));
ASSERT_FALSE(sigismember64(&original_set, SIGRTMIN));
// Block SIGRTMIN.
sigset64_t set;
sigemptyset64(&set);
sigaddset64(&set, SIGRTMIN);
- ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, &set, NULL));
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, &set, nullptr));
// Check that SIGRTMIN is blocked.
sigset64_t final_set;
sigemptyset64(&final_set);
- ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, NULL, &final_set));
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, nullptr, &final_set));
ASSERT_TRUE(sigismember64(&final_set, SIGRTMIN));
// ...and that sigprocmask64 agrees with pthread_sigmask64.
sigemptyset64(&final_set);
- ASSERT_EQ(0, sigprocmask64(SIG_BLOCK, NULL, &final_set));
+ ASSERT_EQ(0, sigprocmask64(SIG_BLOCK, nullptr, &final_set));
ASSERT_TRUE(sigismember64(&final_set, SIGRTMIN));
// Spawn a thread that calls sigwait64 and tells us what it received.
pthread_t signal_thread;
int received_signal = -1;
- ASSERT_EQ(0, pthread_create(&signal_thread, NULL, SignalHandlerFn, &received_signal));
+ ASSERT_EQ(0, pthread_create(&signal_thread, nullptr, SignalHandlerFn, &received_signal));
// Send that thread SIGRTMIN.
pthread_kill(signal_thread, SIGRTMIN);
@@ -440,7 +440,7 @@
ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(join_result));
// Restore the original signal mask.
- ASSERT_EQ(0, pthread_sigmask64(SIG_SETMASK, &original_set, NULL));
+ ASSERT_EQ(0, pthread_sigmask64(SIG_SETMASK, &original_set, nullptr));
}
static void test_pthread_setname_np__pthread_getname_np(pthread_t t) {
@@ -555,7 +555,7 @@
SpinFunctionHelper spin_helper;
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, spin_helper.GetFunction(), NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, spin_helper.GetFunction(), nullptr));
clockid_t c;
ASSERT_EQ(0, pthread_getcpuclockid(t, &c));
@@ -627,12 +627,12 @@
pthread_t dead_thread;
MakeDeadThread(dead_thread);
- EXPECT_DEATH(pthread_join(dead_thread, NULL), "invalid pthread_t");
+ EXPECT_DEATH(pthread_join(dead_thread, nullptr), "invalid pthread_t");
}
TEST_F(pthread_DeathTest, pthread_join__null_thread) {
pthread_t null_thread = 0;
- EXPECT_EQ(ESRCH, pthread_join(null_thread, NULL));
+ EXPECT_EQ(ESRCH, pthread_join(null_thread, nullptr));
}
TEST_F(pthread_DeathTest, pthread_kill__no_such_thread) {
@@ -651,15 +651,15 @@
SpinFunctionHelper spin_helper;
pthread_t t1;
- ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
+ ASSERT_EQ(0, pthread_create(&t1, nullptr, spin_helper.GetFunction(), nullptr));
pthread_t t2;
- ASSERT_EQ(0, pthread_create(&t2, NULL, JoinFn, reinterpret_cast<void*>(t1)));
+ ASSERT_EQ(0, pthread_create(&t2, nullptr, JoinFn, reinterpret_cast<void*>(t1)));
sleep(1); // (Give t2 a chance to call pthread_join.)
// Multiple joins to the same thread should fail.
- ASSERT_EQ(EINVAL, pthread_join(t1, NULL));
+ ASSERT_EQ(EINVAL, pthread_join(t1, nullptr));
spin_helper.UnSpin();
@@ -674,15 +674,15 @@
// If the joiner unmapped the thread's stack, that could lead to SIGSEGV in the thread.
for (size_t i = 0; i < 1024; ++i) {
size_t stack_size = 640*1024;
- void* stack = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
+ void* stack = mmap(nullptr, stack_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
pthread_attr_t a;
pthread_attr_init(&a);
pthread_attr_setstack(&a, stack, stack_size);
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, &a, IdFn, NULL));
- ASSERT_EQ(0, pthread_join(t, NULL));
+ ASSERT_EQ(0, pthread_create(&t, &a, IdFn, nullptr));
+ ASSERT_EQ(0, pthread_join(t, nullptr));
ASSERT_EQ(0, munmap(stack, stack_size));
}
}
@@ -691,14 +691,14 @@
pthread_attr_t attributes;
pthread_getattr_np(pthread_self(), &attributes);
pthread_attr_getguardsize(&attributes, reinterpret_cast<size_t*>(arg));
- return NULL;
+ return nullptr;
}
static size_t GetActualGuardSize(const pthread_attr_t& attributes) {
size_t result;
pthread_t t;
pthread_create(&t, &attributes, GetActualGuardSizeFn, &result);
- pthread_join(t, NULL);
+ pthread_join(t, nullptr);
return result;
}
@@ -706,14 +706,14 @@
pthread_attr_t attributes;
pthread_getattr_np(pthread_self(), &attributes);
pthread_attr_getstacksize(&attributes, reinterpret_cast<size_t*>(arg));
- return NULL;
+ return nullptr;
}
static size_t GetActualStackSize(const pthread_attr_t& attributes) {
size_t result;
pthread_t t;
pthread_create(&t, &attributes, GetActualStackSizeFn, &result);
- pthread_join(t, NULL);
+ pthread_join(t, nullptr);
return result;
}
@@ -827,13 +827,13 @@
TEST(pthread, pthread_rwlock_init_same_as_PTHREAD_RWLOCK_INITIALIZER) {
pthread_rwlock_t lock1 = PTHREAD_RWLOCK_INITIALIZER;
pthread_rwlock_t lock2;
- ASSERT_EQ(0, pthread_rwlock_init(&lock2, NULL));
+ ASSERT_EQ(0, pthread_rwlock_init(&lock2, nullptr));
ASSERT_EQ(0, memcmp(&lock1, &lock2, sizeof(lock1)));
}
TEST(pthread, pthread_rwlock_smoke) {
pthread_rwlock_t l;
- ASSERT_EQ(0, pthread_rwlock_init(&l, NULL));
+ ASSERT_EQ(0, pthread_rwlock_init(&l, nullptr));
// Single read lock
ASSERT_EQ(0, pthread_rwlock_rdlock(&l));
@@ -911,7 +911,7 @@
static void test_pthread_rwlock_reader_wakeup_writer(std::function<int (pthread_rwlock_t*)> lock_function) {
RwlockWakeupHelperArg wakeup_arg;
- ASSERT_EQ(0, pthread_rwlock_init(&wakeup_arg.lock, NULL));
+ ASSERT_EQ(0, pthread_rwlock_init(&wakeup_arg.lock, nullptr));
ASSERT_EQ(0, pthread_rwlock_rdlock(&wakeup_arg.lock));
wakeup_arg.progress = RwlockWakeupHelperArg::LOCK_INITIALIZED;
wakeup_arg.tid = 0;
@@ -919,7 +919,7 @@
wakeup_arg.lock_function = lock_function;
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(pthread_rwlock_wakeup_helper), &wakeup_arg));
WaitUntilThreadSleep(wakeup_arg.tid);
ASSERT_EQ(RwlockWakeupHelperArg::LOCK_WAITING, wakeup_arg.progress);
@@ -927,7 +927,7 @@
wakeup_arg.progress = RwlockWakeupHelperArg::LOCK_RELEASED;
ASSERT_EQ(0, pthread_rwlock_unlock(&wakeup_arg.lock));
- ASSERT_EQ(0, pthread_join(thread, NULL));
+ ASSERT_EQ(0, pthread_join(thread, nullptr));
ASSERT_EQ(RwlockWakeupHelperArg::LOCK_ACCESSED, wakeup_arg.progress);
ASSERT_EQ(0, pthread_rwlock_destroy(&wakeup_arg.lock));
}
@@ -960,7 +960,7 @@
static void test_pthread_rwlock_writer_wakeup_reader(std::function<int (pthread_rwlock_t*)> lock_function) {
RwlockWakeupHelperArg wakeup_arg;
- ASSERT_EQ(0, pthread_rwlock_init(&wakeup_arg.lock, NULL));
+ ASSERT_EQ(0, pthread_rwlock_init(&wakeup_arg.lock, nullptr));
ASSERT_EQ(0, pthread_rwlock_wrlock(&wakeup_arg.lock));
wakeup_arg.progress = RwlockWakeupHelperArg::LOCK_INITIALIZED;
wakeup_arg.tid = 0;
@@ -968,7 +968,7 @@
wakeup_arg.lock_function = lock_function;
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(pthread_rwlock_wakeup_helper), &wakeup_arg));
WaitUntilThreadSleep(wakeup_arg.tid);
ASSERT_EQ(RwlockWakeupHelperArg::LOCK_WAITING, wakeup_arg.progress);
@@ -976,7 +976,7 @@
wakeup_arg.progress = RwlockWakeupHelperArg::LOCK_RELEASED;
ASSERT_EQ(0, pthread_rwlock_unlock(&wakeup_arg.lock));
- ASSERT_EQ(0, pthread_join(thread, NULL));
+ ASSERT_EQ(0, pthread_join(thread, nullptr));
ASSERT_EQ(RwlockWakeupHelperArg::LOCK_ACCESSED, wakeup_arg.progress);
ASSERT_EQ(0, pthread_rwlock_destroy(&wakeup_arg.lock));
}
@@ -1130,14 +1130,14 @@
void CreateWriterThread(pthread_t& thread, std::atomic<pid_t>& tid) {
tid = 0;
ThreadArg* arg = new ThreadArg(this, tid);
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(WriterThreadFn), arg));
}
void CreateReaderThread(pthread_t& thread, std::atomic<pid_t>& tid) {
tid = 0;
ThreadArg* arg = new ThreadArg(this, tid);
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(ReaderThreadFn), arg));
}
@@ -1185,10 +1185,10 @@
pthread_t reader_thread;
std::atomic<pid_t> reader_tid;
helper.CreateReaderThread(reader_thread, reader_tid);
- ASSERT_EQ(0, pthread_join(reader_thread, NULL));
+ ASSERT_EQ(0, pthread_join(reader_thread, nullptr));
ASSERT_EQ(0, pthread_rwlock_unlock(&helper.lock));
- ASSERT_EQ(0, pthread_join(writer_thread, NULL));
+ ASSERT_EQ(0, pthread_join(writer_thread, nullptr));
}
TEST(pthread, pthread_rwlock_kind_PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) {
@@ -1206,8 +1206,8 @@
WaitUntilThreadSleep(reader_tid);
ASSERT_EQ(0, pthread_rwlock_unlock(&helper.lock));
- ASSERT_EQ(0, pthread_join(writer_thread, NULL));
- ASSERT_EQ(0, pthread_join(reader_thread, NULL));
+ ASSERT_EQ(0, pthread_join(writer_thread, nullptr));
+ ASSERT_EQ(0, pthread_join(reader_thread, nullptr));
}
static int g_once_fn_call_count = 0;
@@ -1366,7 +1366,7 @@
void StartWaitingThread(std::function<int (pthread_cond_t* cond, pthread_mutex_t* mutex)> wait_function) {
progress = INITIALIZED;
this->wait_function = wait_function;
- ASSERT_EQ(0, pthread_create(&thread, NULL, reinterpret_cast<void* (*)(void*)>(WaitThreadFn), this));
+ ASSERT_EQ(0, pthread_create(&thread, nullptr, reinterpret_cast<void* (*)(void*)>(WaitThreadFn), this));
while (progress != WAITING) {
usleep(5000);
}
@@ -1517,7 +1517,7 @@
// We do not use "[stack]" label because in native-bridge environment it is not
// guaranteed to point to the right stack. A native bridge implementation may
// keep separate stack for the guest code.
- void* maps_stack_hi = NULL;
+ void* maps_stack_hi = nullptr;
std::vector<map_record> maps;
ASSERT_TRUE(Maps::parse_maps(&maps));
uintptr_t stack_address = reinterpret_cast<uintptr_t>(&maps_stack_hi);
@@ -1621,7 +1621,7 @@
ASSERT_EQ(getpid(), syscall(__NR_gettid));
const size_t sig_stack_size = 16 * 1024;
- void* sig_stack = mmap(NULL, sig_stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
+ void* sig_stack = mmap(nullptr, sig_stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
ASSERT_NE(MAP_FAILED, sig_stack);
stack_t ss;
@@ -1667,10 +1667,10 @@
// [stack_base, stack_base + stack_size). see b/18908062.
TEST(pthread, pthread_attr_getstack_18908062) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL,
+ ASSERT_EQ(0, pthread_create(&t, nullptr,
reinterpret_cast<void* (*)(void*)>(pthread_attr_getstack_18908062_helper),
- NULL));
- ASSERT_EQ(0, pthread_join(t, NULL));
+ nullptr));
+ ASSERT_EQ(0, pthread_join(t, nullptr));
}
#if defined(__BIONIC__)
@@ -1682,7 +1682,7 @@
// Wait for our parent to call pthread_gettid_np on us before exiting.
pthread_mutex_lock(&pthread_gettid_np_mutex);
pthread_mutex_unlock(&pthread_gettid_np_mutex);
- return NULL;
+ return nullptr;
}
#endif
@@ -1696,13 +1696,13 @@
pid_t t_gettid_result;
pthread_t t;
- pthread_create(&t, NULL, pthread_gettid_np_helper, &t_gettid_result);
+ pthread_create(&t, nullptr, pthread_gettid_np_helper, &t_gettid_result);
pid_t t_pthread_gettid_np_result = pthread_gettid_np(t);
// Release the other thread and wait for it to exit.
pthread_mutex_unlock(&pthread_gettid_np_mutex);
- ASSERT_EQ(0, pthread_join(t, NULL));
+ ASSERT_EQ(0, pthread_join(t, nullptr));
ASSERT_EQ(t_gettid_result, t_pthread_gettid_np_result);
#else
@@ -1721,15 +1721,15 @@
}
static void PthreadCleanupTester() {
- pthread_cleanup_push(CountCleanupRoutine, NULL);
- pthread_cleanup_push(CountCleanupRoutine, NULL);
- pthread_cleanup_push(AbortCleanupRoutine, NULL);
+ pthread_cleanup_push(CountCleanupRoutine, nullptr);
+ pthread_cleanup_push(CountCleanupRoutine, nullptr);
+ pthread_cleanup_push(AbortCleanupRoutine, nullptr);
pthread_cleanup_pop(0); // Pop the abort without executing it.
pthread_cleanup_pop(1); // Pop one count while executing it.
ASSERT_EQ(1U, cleanup_counter);
// Exit while the other count is still on the cleanup stack.
- pthread_exit(NULL);
+ pthread_exit(nullptr);
// Calls to pthread_cleanup_pop/pthread_cleanup_push must always be balanced.
pthread_cleanup_pop(0);
@@ -1737,13 +1737,13 @@
static void* PthreadCleanupStartRoutine(void*) {
PthreadCleanupTester();
- return NULL;
+ return nullptr;
}
TEST(pthread, pthread_cleanup_push__pthread_cleanup_pop) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, PthreadCleanupStartRoutine, NULL));
- ASSERT_EQ(0, pthread_join(t, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, PthreadCleanupStartRoutine, nullptr));
+ ASSERT_EQ(0, pthread_join(t, nullptr));
ASSERT_EQ(2U, cleanup_counter);
}
@@ -1956,7 +1956,7 @@
tid = 0;
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(MutexWakeupHelper::thread_fn), this));
WaitUntilThreadSleep(tid);
@@ -1965,7 +1965,7 @@
progress = LOCK_RELEASED;
ASSERT_EQ(0, pthread_mutex_unlock(&m.lock));
- ASSERT_EQ(0, pthread_join(thread, NULL));
+ ASSERT_EQ(0, pthread_join(thread, nullptr));
ASSERT_EQ(LOCK_ACCESSED, progress);
}
};
@@ -2054,7 +2054,7 @@
child_tid = 0;
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL,
+ ASSERT_EQ(0, pthread_create(&thread, nullptr,
reinterpret_cast<void* (*)(void*)>(PIMutexWakeupHelper::thread_fn), this));
WaitUntilThreadSleep(child_tid);
@@ -2081,7 +2081,7 @@
TEST(pthread, pthread_mutex_owner_tid_limit) {
#if defined(__BIONIC__) && !defined(__LP64__)
FILE* fp = fopen("/proc/sys/kernel/pid_max", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
long pid_max;
ASSERT_EQ(1, fscanf(fp, "%ld", &pid_max));
fclose(fp);
@@ -2168,7 +2168,7 @@
};
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL, ThreadFn, &thread_args));
+ ASSERT_EQ(0, pthread_create(&thread, nullptr, ThreadFn, &thread_args));
void* result;
ASSERT_EQ(0, pthread_join(thread, &result));
ASSERT_EQ(ETIMEDOUT, reinterpret_cast<intptr_t>(result));
@@ -2242,21 +2242,21 @@
StrictAlignmentAllocator allocator;
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(
allocator.allocate(sizeof(pthread_mutex_t), 4));
- ASSERT_EQ(0, pthread_mutex_init(mutex, NULL));
+ ASSERT_EQ(0, pthread_mutex_init(mutex, nullptr));
ASSERT_EQ(0, pthread_mutex_lock(mutex));
ASSERT_EQ(0, pthread_mutex_unlock(mutex));
ASSERT_EQ(0, pthread_mutex_destroy(mutex));
pthread_cond_t* cond = reinterpret_cast<pthread_cond_t*>(
allocator.allocate(sizeof(pthread_cond_t), 4));
- ASSERT_EQ(0, pthread_cond_init(cond, NULL));
+ ASSERT_EQ(0, pthread_cond_init(cond, nullptr));
ASSERT_EQ(0, pthread_cond_signal(cond));
ASSERT_EQ(0, pthread_cond_broadcast(cond));
ASSERT_EQ(0, pthread_cond_destroy(cond));
pthread_rwlock_t* rwlock = reinterpret_cast<pthread_rwlock_t*>(
allocator.allocate(sizeof(pthread_rwlock_t), 4));
- ASSERT_EQ(0, pthread_rwlock_init(rwlock, NULL));
+ ASSERT_EQ(0, pthread_rwlock_init(rwlock, nullptr));
ASSERT_EQ(0, pthread_rwlock_rdlock(rwlock));
ASSERT_EQ(0, pthread_rwlock_unlock(rwlock));
ASSERT_EQ(0, pthread_rwlock_wrlock(rwlock));
diff --git a/tests/pty_test.cpp b/tests/pty_test.cpp
index 609f2dc..75f228c 100644
--- a/tests/pty_test.cpp
+++ b/tests/pty_test.cpp
@@ -31,7 +31,7 @@
int master, slave;
char name[32];
struct winsize w = { 123, 456, 9999, 999 };
- ASSERT_EQ(0, openpty(&master, &slave, name, NULL, &w));
+ ASSERT_EQ(0, openpty(&master, &slave, name, nullptr, &w));
ASSERT_NE(-1, master);
ASSERT_NE(-1, slave);
ASSERT_NE(master, slave);
@@ -55,7 +55,7 @@
pid_t sid = getsid(0);
int master;
- pid_t pid = forkpty(&master, NULL, NULL, NULL);
+ pid_t pid = forkpty(&master, nullptr, nullptr, nullptr);
ASSERT_NE(-1, pid);
if (pid == 0) {
diff --git a/tests/regex_test.cpp b/tests/regex_test.cpp
index 0e7f8dd..0d88261 100644
--- a/tests/regex_test.cpp
+++ b/tests/regex_test.cpp
@@ -23,8 +23,8 @@
// A quick test of all the regex functions.
regex_t re;
ASSERT_EQ(0, regcomp(&re, "ab*c", 0));
- ASSERT_EQ(0, regexec(&re, "abbbc", 0, NULL, 0));
- ASSERT_EQ(REG_NOMATCH, regexec(&re, "foo", 0, NULL, 0));
+ ASSERT_EQ(0, regexec(&re, "abbbc", 0, nullptr, 0));
+ ASSERT_EQ(REG_NOMATCH, regexec(&re, "foo", 0, nullptr, 0));
char buf[80];
regerror(REG_NOMATCH, &re, buf, sizeof(buf));
diff --git a/tests/sched_test.cpp b/tests/sched_test.cpp
index e70528e..9184026 100644
--- a/tests/sched_test.cpp
+++ b/tests/sched_test.cpp
@@ -56,7 +56,7 @@
uintptr_t fake_child_stack[16];
errno = 0;
// If CLONE_THREAD is set, CLONE_SIGHAND must be set too.
- ASSERT_EQ(-1, clone(child_fn, &fake_child_stack[16], CLONE_THREAD, NULL));
+ ASSERT_EQ(-1, clone(child_fn, &fake_child_stack[16], CLONE_THREAD, nullptr));
ASSERT_EQ(EINVAL, errno);
}
diff --git a/tests/search_test.cpp b/tests/search_test.cpp
index d5ab67c..1509199 100644
--- a/tests/search_test.cpp
+++ b/tests/search_test.cpp
@@ -151,18 +151,18 @@
// Linear (not circular).
- insque(&zero, NULL);
+ insque(&zero, nullptr);
insque(&one, &zero);
insque(&two, &one);
int expected = 0;
- for (q_node* q = &zero; q != NULL; q = q->next) {
+ for (q_node* q = &zero; q != nullptr; q = q->next) {
ASSERT_EQ(expected, q->i);
++expected;
}
ASSERT_EQ(3, expected);
- for (q_node* q = &two; q != NULL; q = q->prev) {
+ for (q_node* q = &two; q != nullptr; q = q->prev) {
--expected;
ASSERT_EQ(expected, q->i);
}
diff --git a/tests/semaphore_test.cpp b/tests/semaphore_test.cpp
index 607e37f..10d99ea 100644
--- a/tests/semaphore_test.cpp
+++ b/tests/semaphore_test.cpp
@@ -78,9 +78,9 @@
ASSERT_EQ(0, sem_init(&s, 0, 0));
pthread_t t1, t2, t3;
- ASSERT_EQ(0, pthread_create(&t1, NULL, SemWaitThreadFn, &s));
- ASSERT_EQ(0, pthread_create(&t2, NULL, SemWaitThreadFn, &s));
- ASSERT_EQ(0, pthread_create(&t3, NULL, SemWaitThreadFn, &s));
+ ASSERT_EQ(0, pthread_create(&t1, nullptr, SemWaitThreadFn, &s));
+ ASSERT_EQ(0, pthread_create(&t2, nullptr, SemWaitThreadFn, &s));
+ ASSERT_EQ(0, pthread_create(&t3, nullptr, SemWaitThreadFn, &s));
ASSERT_EQ(0, sem_post(&s));
ASSERT_EQ(0, sem_post(&s));
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index a49e910..05339a6 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -84,7 +84,7 @@
void AssertSigmaskEquals(const sigset64_t& expected) {
sigset64_t actual;
- sigprocmask64(SIG_SETMASK, NULL, &actual);
+ sigprocmask64(SIG_SETMASK, nullptr, &actual);
size_t end = sizeof(expected) * 8;
for (size_t i = 1; i <= end; ++i) {
EXPECT_EQ(sigismember64(&expected, i), sigismember64(&actual, i)) << i;
@@ -99,7 +99,7 @@
sigprocmask64(SIG_SETMASK, &ss.one, nullptr);
jmp_buf jb;
if (_setjmp(jb) == 0) {
- sigprocmask64(SIG_SETMASK, &ss.two, NULL);
+ sigprocmask64(SIG_SETMASK, &ss.two, nullptr);
_longjmp(jb, 1);
FAIL(); // Unreachable.
} else {
@@ -117,7 +117,7 @@
sigprocmask64(SIG_SETMASK, &ss.one, nullptr);
jmp_buf jb;
if (setjmp(jb) == 0) {
- sigprocmask64(SIG_SETMASK, &ss.two, NULL);
+ sigprocmask64(SIG_SETMASK, &ss.two, nullptr);
longjmp(jb, 1);
FAIL(); // Unreachable.
} else {
@@ -139,7 +139,7 @@
sigprocmask64(SIG_SETMASK, &ss.one, nullptr);
sigjmp_buf sjb;
if (sigsetjmp(sjb, 0) == 0) {
- sigprocmask64(SIG_SETMASK, &ss.two, NULL);
+ sigprocmask64(SIG_SETMASK, &ss.two, nullptr);
siglongjmp(sjb, 1);
FAIL(); // Unreachable.
} else {
@@ -155,7 +155,7 @@
sigprocmask64(SIG_SETMASK, &ss.one, nullptr);
sigjmp_buf sjb;
if (sigsetjmp(sjb, 1) == 0) {
- sigprocmask64(SIG_SETMASK, &ss.two, NULL);
+ sigprocmask64(SIG_SETMASK, &ss.two, nullptr);
siglongjmp(sjb, 1);
FAIL(); // Unreachable.
} else {
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index 53c91a2..cc95ef7 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -37,13 +37,13 @@
template <typename SigSetT>
static void TestSigSet1(int (fn)(SigSetT*)) {
- // NULL sigset_t*/sigset64_t*.
- SigSetT* set_ptr = NULL;
+ // nullptr sigset_t*/sigset64_t*.
+ SigSetT* set_ptr = nullptr;
errno = 0;
ASSERT_EQ(-1, fn(set_ptr));
ASSERT_EQ(EINVAL, errno);
- // Non-NULL.
+ // Non-nullptr.
SigSetT set = {};
errno = 0;
ASSERT_EQ(0, fn(&set));
@@ -52,8 +52,8 @@
template <typename SigSetT>
static void TestSigSet2(int (fn)(SigSetT*, int)) {
- // NULL sigset_t*/sigset64_t*.
- SigSetT* set_ptr = NULL;
+ // nullptr sigset_t*/sigset64_t*.
+ SigSetT* set_ptr = nullptr;
errno = 0;
ASSERT_EQ(-1, fn(set_ptr, SIGSEGV));
ASSERT_EQ(EINVAL, errno);
@@ -281,9 +281,9 @@
// See what's currently set for this signal.
SigActionT original_sa = {};
- ASSERT_EQ(0, sigaction_fn(sig, NULL, &original_sa));
- ASSERT_TRUE(original_sa.sa_handler == NULL);
- ASSERT_TRUE(original_sa.sa_sigaction == NULL);
+ ASSERT_EQ(0, sigaction_fn(sig, nullptr, &original_sa));
+ ASSERT_TRUE(original_sa.sa_handler == nullptr);
+ ASSERT_TRUE(original_sa.sa_sigaction == nullptr);
ASSERT_EQ(0U, original_sa.sa_flags & ~sa_restorer);
#ifdef SA_RESTORER
ASSERT_EQ(bool(original_sa.sa_flags & sa_restorer), bool(original_sa.sa_restorer));
@@ -295,11 +295,11 @@
sigaddset_fn(&sa.sa_mask, sig);
sa.sa_flags = SA_ONSTACK;
sa.sa_handler = no_op_signal_handler;
- ASSERT_EQ(0, sigaction_fn(sig, &sa, NULL));
+ ASSERT_EQ(0, sigaction_fn(sig, &sa, nullptr));
// Check that we can read it back.
sa = {};
- ASSERT_EQ(0, sigaction_fn(sig, NULL, &sa));
+ ASSERT_EQ(0, sigaction_fn(sig, nullptr, &sa));
ASSERT_TRUE(sa.sa_handler == no_op_signal_handler);
ASSERT_TRUE((void*) sa.sa_sigaction == (void*) sa.sa_handler);
ASSERT_EQ(static_cast<unsigned>(SA_ONSTACK), sa.sa_flags & ~sa_restorer);
@@ -313,11 +313,11 @@
sigaddset_fn(&sa.sa_mask, sig);
sa.sa_flags = SA_ONSTACK | SA_SIGINFO;
sa.sa_sigaction = no_op_sigaction;
- ASSERT_EQ(0, sigaction_fn(sig, &sa, NULL));
+ ASSERT_EQ(0, sigaction_fn(sig, &sa, nullptr));
// Check that we can read it back.
sa = {};
- ASSERT_EQ(0, sigaction_fn(sig, NULL, &sa));
+ ASSERT_EQ(0, sigaction_fn(sig, nullptr, &sa));
ASSERT_TRUE(sa.sa_sigaction == no_op_sigaction);
ASSERT_TRUE((void*) sa.sa_sigaction == (void*) sa.sa_handler);
ASSERT_EQ(static_cast<unsigned>(SA_ONSTACK | SA_SIGINFO), sa.sa_flags & ~sa_restorer);
@@ -326,7 +326,7 @@
#endif
// Put everything back how it was.
- ASSERT_EQ(0, sigaction_fn(sig, &original_sa, NULL));
+ ASSERT_EQ(0, sigaction_fn(sig, &original_sa, nullptr));
}
TEST(signal, sigaction) {
@@ -547,7 +547,7 @@
TEST(signal, sys_signame) {
#if defined(__BIONIC__)
- ASSERT_TRUE(sys_signame[0] == NULL);
+ ASSERT_TRUE(sys_signame[0] == nullptr);
ASSERT_STREQ("HUP", sys_signame[SIGHUP]);
#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
@@ -555,7 +555,7 @@
}
TEST(signal, sys_siglist) {
- ASSERT_TRUE(sys_siglist[0] == NULL);
+ ASSERT_TRUE(sys_siglist[0] == nullptr);
ASSERT_STREQ("Hangup", sys_siglist[SIGHUP]);
}
@@ -708,7 +708,7 @@
ASSERT_EQ(EAGAIN, errno);
ASSERT_GE(NanoTime() - start_time, 1000000);
- ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &original_set, NULL));
+ ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &original_set, nullptr));
}
#if defined(__BIONIC__)
@@ -806,7 +806,7 @@
// sighold(SIGALRM/SIGRTMIN) should add SIGALRM/SIGRTMIN to the signal mask ...
ASSERT_EQ(0, sighold(sig));
- ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+ ASSERT_EQ(0, sigprocmask(SIG_SETMASK, nullptr, &set));
EXPECT_TRUE(sigismember(&set, sig));
// ... preventing our SIGALRM/SIGRTMIN handler from running ...
@@ -819,12 +819,12 @@
if (sig >= SIGRTMIN && sizeof(void*) == 8) {
// But sigpause(SIGALRM/SIGRTMIN) shouldn't permanently unblock SIGALRM/SIGRTMIN.
- ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+ ASSERT_EQ(0, sigprocmask(SIG_SETMASK, nullptr, &set));
EXPECT_TRUE(sigismember(&set, sig));
// Whereas sigrelse(SIGALRM/SIGRTMIN) should.
ASSERT_EQ(0, sigrelse(sig));
- ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+ ASSERT_EQ(0, sigprocmask(SIG_SETMASK, nullptr, &set));
EXPECT_FALSE(sigismember(&set, sig));
} else {
// sigismember won't work for SIGRTMIN on LP32.
diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp
index 5f5a241..34e3c11 100644
--- a/tests/stack_protector_test.cpp
+++ b/tests/stack_protector_test.cpp
@@ -74,14 +74,14 @@
size_t thread_count = 9;
for (size_t i = 1; i < thread_count; ++i) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, [](void* arg) -> void* {
+ ASSERT_EQ(0, pthread_create(&t, nullptr, [](void* arg) -> void* {
stack_protector_checker* checker = reinterpret_cast<stack_protector_checker*>(arg);
checker->Check();
return nullptr;
}, &checker));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
ASSERT_EQ(thread_count, checker.tids.size());
diff --git a/tests/stdatomic_test.cpp b/tests/stdatomic_test.cpp
index 389b251..d122d2f 100644
--- a/tests/stdatomic_test.cpp
+++ b/tests/stdatomic_test.cpp
@@ -206,7 +206,7 @@
atomic_store_explicit(&a->z, i+1, memory_order_relaxed);
atomic_store_explicit(&a->y, i+1, memory_order_release);
}
- return 0;
+ return nullptr;
}
static void* reader(void* arg) {
@@ -224,13 +224,13 @@
// Cant just ASSERT, since we are in a non-void function.
ADD_FAILURE() << "acquire-release ordering violation: "
<< zval << " < " << yval << ", " << xval << "\n";
- return 0; // Only report once.
+ return nullptr; // Only report once.
}
if (xval < yval) {
// Cant just ASSERT, since we are in a non-void function.
ADD_FAILURE() << "acquire-release ordering violation: "
<< xval << " < " << yval << ", " << zval << "\n";
- return 0; // Only report once.
+ return nullptr; // Only report once.
}
if (repeat < repeat_limit) ++repeat;
}
@@ -238,7 +238,7 @@
// But if it fails to hold, this test was useless, and we have a
// serious scheduling issue that we should probably know about.
EXPECT_EQ(repeat, repeat_limit);
- return 0;
+ return nullptr;
}
TEST(stdatomic, ordering) {
@@ -249,12 +249,12 @@
atomic_init(&a.y, 0ul);
atomic_init(&a.z, 0ul);
pthread_t t1,t2;
- ASSERT_EQ(0, pthread_create(&t1, 0, reader, &a));
- ASSERT_EQ(0, pthread_create(&t2, 0, writer, &a));
+ ASSERT_EQ(0, pthread_create(&t1, nullptr, reader, &a));
+ ASSERT_EQ(0, pthread_create(&t2, nullptr, writer, &a));
ASSERT_EQ(0, pthread_join(t1, &result));
- EXPECT_EQ(0, result);
+ EXPECT_EQ(nullptr, result);
ASSERT_EQ(0, pthread_join(t2, &result));
- EXPECT_EQ(0, result);
+ EXPECT_EQ(nullptr, result);
EXPECT_EQ(atomic_load_explicit(&a.x, memory_order_consume), BIG + 1);
EXPECT_EQ(atomic_load_explicit(&a.y, memory_order_seq_cst), BIG + 1);
EXPECT_EQ(atomic_load(&a.z), BIG + 1);
diff --git a/tests/stdio_ext_test.cpp b/tests/stdio_ext_test.cpp
index 849bf0b..d4616ef 100644
--- a/tests/stdio_ext_test.cpp
+++ b/tests/stdio_ext_test.cpp
@@ -93,7 +93,7 @@
char buf[16];
char* s = fgets(buf, sizeof(buf), fp);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
ASSERT_STREQ("b\n", s);
fclose(fp);
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index d499ddb..844a9c0 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -95,7 +95,7 @@
TEST(STDIO_TEST, flockfile_18208568_regular) {
// We never had a bug for streams other than stdin/stdout/stderr, but test anyway.
FILE* fp = fopen("/dev/null", "w");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
flockfile(fp);
feof(fp);
funlockfile(fp);
@@ -104,7 +104,7 @@
TEST(STDIO_TEST, tmpfile_fileno_fprintf_rewind_fgets) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
int fd = fileno(fp);
ASSERT_NE(fd, -1);
@@ -135,7 +135,7 @@
lseek(tf.fd, 0, SEEK_SET);
FILE* tfile = fdopen(tf.fd, "r");
- ASSERT_TRUE(tfile != NULL);
+ ASSERT_TRUE(tfile != nullptr);
AssertFileIs(tfile, "hello\n");
fclose(tfile);
@@ -143,7 +143,7 @@
TEST(STDIO_TEST, getdelim) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
const char* line_written = "This is a test";
int rc = fprintf(fp, "%s", line_written);
@@ -151,7 +151,7 @@
rewind(fp);
- char* word_read = NULL;
+ char* word_read = nullptr;
size_t allocated_length = 0;
const char* expected[] = { "This ", " ", "is ", "a ", "test" };
@@ -178,26 +178,26 @@
TEST(STDIO_TEST, getdelim_invalid) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
- char* buffer = NULL;
+ char* buffer = nullptr;
size_t buffer_length = 0;
// The first argument can't be NULL.
errno = 0;
- ASSERT_EQ(getdelim(NULL, &buffer_length, ' ', fp), -1);
+ ASSERT_EQ(getdelim(nullptr, &buffer_length, ' ', fp), -1);
ASSERT_EQ(EINVAL, errno);
// The second argument can't be NULL.
errno = 0;
- ASSERT_EQ(getdelim(&buffer, NULL, ' ', fp), -1);
+ ASSERT_EQ(getdelim(&buffer, nullptr, ' ', fp), -1);
ASSERT_EQ(EINVAL, errno);
fclose(fp);
}
TEST(STDIO_TEST, getdelim_directory) {
FILE* fp = fopen("/proc", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
char* word_read;
size_t allocated_length;
ASSERT_EQ(-1, getdelim(&word_read, &allocated_length, ' ', fp));
@@ -206,7 +206,7 @@
TEST(STDIO_TEST, getline) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
const char* line_written = "This is a test for getline\n";
const size_t line_count = 5;
@@ -218,7 +218,7 @@
rewind(fp);
- char* line_read = NULL;
+ char* line_read = nullptr;
size_t allocated_length = 0;
size_t read_line_count = 0;
@@ -248,19 +248,19 @@
TEST(STDIO_TEST, getline_invalid) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
- char* buffer = NULL;
+ char* buffer = nullptr;
size_t buffer_length = 0;
// The first argument can't be NULL.
errno = 0;
- ASSERT_EQ(getline(NULL, &buffer_length, fp), -1);
+ ASSERT_EQ(getline(nullptr, &buffer_length, fp), -1);
ASSERT_EQ(EINVAL, errno);
// The second argument can't be NULL.
errno = 0;
- ASSERT_EQ(getline(&buffer, NULL, fp), -1);
+ ASSERT_EQ(getline(&buffer, nullptr, fp), -1);
ASSERT_EQ(EINVAL, errno);
fclose(fp);
}
@@ -300,7 +300,7 @@
TEST(STDIO_TEST, snprintf_ls) {
char buf[BUFSIZ];
- wchar_t* ws = NULL;
+ wchar_t* ws = nullptr;
EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%ls>", ws));
EXPECT_STREQ("<(null)>", buf);
@@ -312,7 +312,7 @@
TEST(STDIO_TEST, snprintf_S) { // Synonym for %ls.
char buf[BUFSIZ];
- wchar_t* ws = NULL;
+ wchar_t* ws = nullptr;
EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%S>", ws));
EXPECT_STREQ("<(null)>", buf);
@@ -348,7 +348,7 @@
snprintf(buf, sizeof(buf), "a%sb", "01234");
EXPECT_STREQ("a01234b", buf);
- char* s = NULL;
+ char* s = nullptr;
snprintf(buf, sizeof(buf), "a%sb", s);
EXPECT_STREQ("a(null)b", buf);
@@ -409,7 +409,7 @@
snprintf(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5);
EXPECT_STREQ("a005:5:05z", buf);
- void* p = NULL;
+ void* p = nullptr;
snprintf(buf, sizeof(buf), "a%d,%pz", 5, p);
#if defined(__BIONIC__)
EXPECT_STREQ("a5,0x0z", buf);
@@ -786,7 +786,7 @@
}
TEST(STDIO_TEST, snprintf_utf8_15439554) {
- locale_t cloc = newlocale(LC_ALL, "C.UTF-8", 0);
+ locale_t cloc = newlocale(LC_ALL, "C.UTF-8", nullptr);
locale_t old_locale = uselocale(cloc);
// http://b/15439554
@@ -862,7 +862,7 @@
// Unbuffered case where the fprintf(3) itself fails.
ASSERT_NE(nullptr, fp = tmpfile());
- setbuf(fp, NULL);
+ setbuf(fp, nullptr);
ASSERT_EQ(4, fprintf(fp, "epic"));
ASSERT_NE(-1, dup2(fd_rdonly, fileno(fp)));
ASSERT_EQ(-1, fprintf(fp, "fail"));
@@ -881,7 +881,7 @@
TEST(STDIO_TEST, popen_r) {
FILE* fp = popen("cat /proc/version", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
char buf[16];
char* s = fgets(buf, sizeof(buf), fp);
@@ -893,7 +893,7 @@
TEST(STDIO_TEST, popen_socketpair) {
FILE* fp = popen("cat", "r+");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
fputs("hello\nworld\n", fp);
fflush(fp);
@@ -909,7 +909,7 @@
TEST(STDIO_TEST, popen_socketpair_shutdown) {
FILE* fp = popen("uniq -c", "r+");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
fputs("a\na\na\na\nb\n", fp);
fflush(fp);
@@ -926,7 +926,7 @@
TEST(STDIO_TEST, popen_return_value_0) {
FILE* fp = popen("true", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
int status = pclose(fp);
EXPECT_TRUE(WIFEXITED(status));
EXPECT_EQ(0, WEXITSTATUS(status));
@@ -934,7 +934,7 @@
TEST(STDIO_TEST, popen_return_value_1) {
FILE* fp = popen("false", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
int status = pclose(fp);
EXPECT_TRUE(WIFEXITED(status));
EXPECT_EQ(1, WEXITSTATUS(status));
@@ -942,7 +942,7 @@
TEST(STDIO_TEST, popen_return_value_signal) {
FILE* fp = popen("kill -7 $$", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
int status = pclose(fp);
EXPECT_TRUE(WIFSIGNALED(status));
EXPECT_EQ(7, WTERMSIG(status));
@@ -950,7 +950,7 @@
TEST(STDIO_TEST, getc) {
FILE* fp = fopen("/proc/version", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
ASSERT_EQ('L', getc(fp));
ASSERT_EQ('i', getc(fp));
ASSERT_EQ('n', getc(fp));
@@ -961,7 +961,7 @@
TEST(STDIO_TEST, putc) {
FILE* fp = fopen("/proc/version", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
ASSERT_EQ(EOF, putc('x', fp));
fclose(fp);
}
@@ -1328,7 +1328,7 @@
uselocale(LC_GLOBAL_LOCALE);
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
wchar_t mb_one_bytes = L'h';
wchar_t mb_two_bytes = 0x00a2;
@@ -1398,7 +1398,7 @@
TemporaryFile tf;
FILE* fp = fdopen(tf.fd, "w+");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
wchar_t mb_two_bytes = 0x00a2;
wchar_t mb_three_bytes = 0x20ac;
@@ -1413,7 +1413,7 @@
fclose(fp);
fp = fopen(tf.filename, "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
// Store a valid position.
fpos_t mb_two_bytes_pos;
@@ -1900,7 +1900,7 @@
AssertCloseOnExec(fd, false);
FILE* fp = fdopen(fd, "re");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
// ...but the new one does.
AssertCloseOnExec(fileno(fp), true);
@@ -1910,7 +1910,7 @@
TEST(STDIO_TEST, freopen_CLOEXEC) {
FILE* fp = fopen("/proc/version", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
// This FILE* doesn't have O_CLOEXEC...
AssertCloseOnExec(fileno(fp), false);
@@ -1935,19 +1935,19 @@
// http://b/18556607
TEST(STDIO_TEST, fread_unbuffered_pathological_performance) {
FILE* fp = fopen("/dev/zero", "r");
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
// Make this stream unbuffered.
- setvbuf(fp, 0, _IONBF, 0);
+ setvbuf(fp, nullptr, _IONBF, 0);
char buf[65*1024];
memset(buf, 0xff, sizeof(buf));
- time_t t0 = time(NULL);
+ time_t t0 = time(nullptr);
for (size_t i = 0; i < 1024; ++i) {
ASSERT_EQ(1U, fread(buf, 64*1024, 1, fp));
}
- time_t t1 = time(NULL);
+ time_t t1 = time(nullptr);
fclose(fp);
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 2fbd937..6e41555 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -281,35 +281,35 @@
TEST(stdlib, realpath__NULL_filename) {
errno = 0;
// Work around the compile-time error generated by FORTIFY here.
- const char* path = NULL;
- char* p = realpath(path, NULL);
- ASSERT_TRUE(p == NULL);
+ const char* path = nullptr;
+ char* p = realpath(path, nullptr);
+ ASSERT_TRUE(p == nullptr);
ASSERT_EQ(EINVAL, errno);
}
TEST(stdlib, realpath__empty_filename) {
errno = 0;
- char* p = realpath("", NULL);
- ASSERT_TRUE(p == NULL);
+ char* p = realpath("", nullptr);
+ ASSERT_TRUE(p == nullptr);
ASSERT_EQ(ENOENT, errno);
}
TEST(stdlib, realpath__ENOENT) {
errno = 0;
- char* p = realpath("/this/directory/path/almost/certainly/does/not/exist", NULL);
- ASSERT_TRUE(p == NULL);
+ char* p = realpath("/this/directory/path/almost/certainly/does/not/exist", nullptr);
+ ASSERT_TRUE(p == nullptr);
ASSERT_EQ(ENOENT, errno);
}
TEST(stdlib, realpath__component_after_non_directory) {
errno = 0;
- char* p = realpath("/dev/null/.", NULL);
- ASSERT_TRUE(p == NULL);
+ char* p = realpath("/dev/null/.", nullptr);
+ ASSERT_TRUE(p == nullptr);
ASSERT_EQ(ENOTDIR, errno);
errno = 0;
- p = realpath("/dev/null/..", NULL);
- ASSERT_TRUE(p == NULL);
+ p = realpath("/dev/null/..", nullptr);
+ ASSERT_TRUE(p == nullptr);
ASSERT_EQ(ENOTDIR, errno);
}
@@ -324,7 +324,7 @@
char* p = realpath("/proc/self/exe", buf);
ASSERT_STREQ(executable_path, p);
- p = realpath("/proc/self/exe", NULL);
+ p = realpath("/proc/self/exe", nullptr);
ASSERT_STREQ(executable_path, p);
free(p);
}
@@ -354,18 +354,18 @@
static void* TestBug57421_child(void* arg) {
pthread_t main_thread = reinterpret_cast<pthread_t>(arg);
- pthread_join(main_thread, NULL);
+ pthread_join(main_thread, nullptr);
char* value = getenv("ENVIRONMENT_VARIABLE");
- if (value == NULL) {
+ if (value == nullptr) {
setenv("ENVIRONMENT_VARIABLE", "value", 1);
}
- return NULL;
+ return nullptr;
}
static void TestBug57421_main() {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, TestBug57421_child, reinterpret_cast<void*>(pthread_self())));
- pthread_exit(NULL);
+ ASSERT_EQ(0, pthread_create(&t, nullptr, TestBug57421_child, reinterpret_cast<void*>(pthread_self())));
+ pthread_exit(nullptr);
}
// Even though this isn't really a death test, we have to say "DeathTest" here so gtest knows to
@@ -483,20 +483,20 @@
}
TEST(stdlib, strtof_2206701) {
- ASSERT_EQ(0.0f, strtof("7.0064923216240853546186479164495e-46", NULL));
- ASSERT_EQ(1.4e-45f, strtof("7.0064923216240853546186479164496e-46", NULL));
+ ASSERT_EQ(0.0f, strtof("7.0064923216240853546186479164495e-46", nullptr));
+ ASSERT_EQ(1.4e-45f, strtof("7.0064923216240853546186479164496e-46", nullptr));
}
TEST(stdlib, strtod_largest_subnormal) {
// This value has been known to cause javac and java to infinite loop.
// http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
- ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-308", NULL));
- ASSERT_EQ(2.2250738585072014e-308, strtod("0.00022250738585072012e-304", NULL));
- ASSERT_EQ(2.2250738585072014e-308, strtod("00000002.2250738585072012e-308", NULL));
- ASSERT_EQ(2.2250738585072014e-308, strtod("2.225073858507201200000e-308", NULL));
- ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-00308", NULL));
- ASSERT_EQ(2.2250738585072014e-308, strtod("2.22507385850720129978001e-308", NULL));
- ASSERT_EQ(-2.2250738585072014e-308, strtod("-2.2250738585072012e-308", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-308", nullptr));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("0.00022250738585072012e-304", nullptr));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("00000002.2250738585072012e-308", nullptr));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.225073858507201200000e-308", nullptr));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-00308", nullptr));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.22507385850720129978001e-308", nullptr));
+ ASSERT_EQ(-2.2250738585072014e-308, strtod("-2.2250738585072012e-308", nullptr));
}
TEST(stdlib, quick_exit) {
@@ -584,7 +584,7 @@
int fd = getpt();
ASSERT_NE(-1, fd);
errno = 0;
- char* buf = NULL;
+ char* buf = nullptr;
ASSERT_EQ(EINVAL, ptsname_r(fd, buf, 128));
ASSERT_EQ(EINVAL, errno);
close(fd);
@@ -635,7 +635,7 @@
int fd = getpt();
ASSERT_NE(-1, fd);
errno = 0;
- char* buf = NULL;
+ char* buf = nullptr;
ASSERT_EQ(EINVAL, ttyname_r(fd, buf, 128));
ASSERT_EQ(EINVAL, errno);
close(fd);
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 0d42b05..8bfa964 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -78,7 +78,7 @@
ASSERT_STREQ("Unknown error 1001", strerror1001);
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ConcurrentStrErrorFn, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ConcurrentStrErrorFn, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
ASSERT_TRUE(static_cast<bool>(result));
@@ -144,7 +144,7 @@
ASSERT_STREQ("Unknown signal 1001", strsignal1001);
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ConcurrentStrSignalFn, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, ConcurrentStrSignalFn, nullptr));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
ASSERT_TRUE(static_cast<bool>(result));
@@ -451,7 +451,7 @@
if (seek_char == 0) {
expected = state.ptr1 + state.len[i] - 1;
} else {
- expected = NULL;
+ expected = nullptr;
}
} else {
state.ptr1[pos] = seek_char;
@@ -763,7 +763,7 @@
if (seek_char == 0) {
expected = state.ptr1 + state.len[i] - 1;
} else {
- expected = NULL;
+ expected = nullptr;
}
} else {
state.ptr1[pos] = seek_char;
@@ -785,7 +785,7 @@
size_t pos = random() % state.MAX_LEN;
char* expected;
if (pos >= state.len[i]) {
- expected = NULL;
+ expected = nullptr;
} else {
state.ptr1[pos] = seek_char;
expected = state.ptr1 + pos;
@@ -800,8 +800,8 @@
uint8_t* buffer;
ASSERT_EQ(0, posix_memalign(reinterpret_cast<void**>(&buffer), 64, 64));
memset(buffer, 10, 64);
- ASSERT_TRUE(NULL == memchr(buffer, 5, 0));
- ASSERT_TRUE(NULL == memchr(buffer, 10, 0));
+ ASSERT_TRUE(nullptr == memchr(buffer, 5, 0));
+ ASSERT_TRUE(nullptr == memchr(buffer, 10, 0));
}
TEST(STRING_TEST, memrchr) {
@@ -814,7 +814,7 @@
size_t pos = random() % state.MAX_LEN;
char* expected;
if (pos >= state.len[i]) {
- expected = NULL;
+ expected = nullptr;
} else {
state.ptr1[pos] = seek_char;
expected = state.ptr1 + pos;
@@ -935,9 +935,9 @@
char* glob_ptr2 = reinterpret_cast<char*>(malloc(2 * sizeof(char) * len + max_alignment));
size_t pos = 64;
- ASSERT_TRUE(ptr != NULL);
- ASSERT_TRUE(ptr1 != NULL);
- ASSERT_TRUE(glob_ptr2 != NULL);
+ ASSERT_TRUE(ptr != nullptr);
+ ASSERT_TRUE(ptr1 != nullptr);
+ ASSERT_TRUE(glob_ptr2 != nullptr);
for (int i = 0; i < 5; i++) {
char* ptr2 = glob_ptr2 + alignments[i];
@@ -966,10 +966,10 @@
TEST(STRING_TEST, memmove_check) {
char* buffer = reinterpret_cast<char*>(malloc(MEMMOVE_DATA_SIZE));
- ASSERT_TRUE(buffer != NULL);
+ ASSERT_TRUE(buffer != nullptr);
char* src_data = reinterpret_cast<char*>(malloc(MEMMOVE_DATA_SIZE));
- ASSERT_TRUE(src_data != NULL);
+ ASSERT_TRUE(src_data != nullptr);
// Initialize to a known pattern to copy into src for each test and
// to compare dst against.
for (size_t i = 0; i < MEMMOVE_DATA_SIZE; i++) {
diff --git a/tests/strings_test.cpp b/tests/strings_test.cpp
index 1716843..ac327d4 100644
--- a/tests/strings_test.cpp
+++ b/tests/strings_test.cpp
@@ -45,7 +45,7 @@
}
TEST(STRINGS_TEST, strcasecmp_l) {
- locale_t l = newlocale(LC_ALL, "C", 0);
+ locale_t l = newlocale(LC_ALL, "C", nullptr);
ASSERT_EQ(0, strcasecmp_l("hello", "HELLO", l));
ASSERT_LT(strcasecmp_l("hello1", "hello2", l), 0);
ASSERT_GT(strcasecmp_l("hello2", "hello1", l), 0);
@@ -60,7 +60,7 @@
}
TEST(STRINGS_TEST, strncasecmp_l) {
- locale_t l = newlocale(LC_ALL, "C", 0);
+ locale_t l = newlocale(LC_ALL, "C", nullptr);
ASSERT_EQ(0, strncasecmp_l("hello", "HELLO", 3, l));
ASSERT_EQ(0, strncasecmp_l("abcXX", "ABCYY", 3, l));
ASSERT_LT(strncasecmp_l("hello1", "hello2", 6, l), 0);
diff --git a/tests/sys_epoll_test.cpp b/tests/sys_epoll_test.cpp
index 7233ccc..18cf380 100644
--- a/tests/sys_epoll_test.cpp
+++ b/tests/sys_epoll_test.cpp
@@ -33,11 +33,11 @@
ASSERT_EQ(0, epoll_wait(epoll_fd, events, 1, 1));
// epoll_pwait without a sigset (which is equivalent to epoll_wait).
- ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, NULL));
+ ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, nullptr));
#if defined(__BIONIC__)
// epoll_pwait64 without a sigset (which is equivalent to epoll_wait).
- ASSERT_EQ(0, epoll_pwait64(epoll_fd, events, 1, 1, NULL));
+ ASSERT_EQ(0, epoll_pwait64(epoll_fd, events, 1, 1, nullptr));
#endif
// epoll_pwait with a sigset.
diff --git a/tests/sys_mman_test.cpp b/tests/sys_mman_test.cpp
index e44bfed..22dc383 100644
--- a/tests/sys_mman_test.cpp
+++ b/tests/sys_mman_test.cpp
@@ -24,13 +24,13 @@
#include "TemporaryFile.h"
TEST(sys_mman, mmap_std) {
- void* map = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ void* map = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
ASSERT_NE(MAP_FAILED, map);
ASSERT_EQ(0, munmap(map, 4096));
}
TEST(sys_mman, mmap64_std) {
- void* map = mmap64(NULL, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ void* map = mmap64(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
ASSERT_NE(MAP_FAILED, map);
ASSERT_EQ(0, munmap(map, 4096));
}
@@ -38,14 +38,14 @@
TEST(sys_mman, mmap_file_bad_offset) {
TemporaryFile tf;
- void* map = mmap(NULL, 100, PROT_READ, MAP_SHARED, tf.fd, 1);
+ void* map = mmap(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1);
ASSERT_EQ(MAP_FAILED, map);
}
TEST(sys_mman, mmap64_file_bad_offset) {
TemporaryFile tf;
- void* map = mmap64(NULL, 100, PROT_READ, MAP_SHARED, tf.fd, 1);
+ void* map = mmap64(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1);
ASSERT_EQ(MAP_FAILED, map);
}
@@ -59,7 +59,7 @@
ASSERT_EQ(STR_SSIZE(STRING_MSG), write(tf.fd, STRING_MSG, sizeof(STRING_MSG)));
- void* map = mmap(NULL, sizeof(STRING_MSG), PROT_READ, MAP_SHARED, tf.fd, 0);
+ void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_READ, MAP_SHARED, tf.fd, 0);
ASSERT_NE(MAP_FAILED, map);
char* data = reinterpret_cast<char*>(map);
@@ -74,7 +74,7 @@
ASSERT_EQ(STR_SSIZE(INITIAL_MSG), write(tf.fd, INITIAL_MSG, sizeof(INITIAL_MSG)));
lseek(tf.fd, 0, SEEK_SET);
- void* map = mmap(NULL, sizeof(STRING_MSG), PROT_WRITE, MAP_SHARED, tf.fd, 0);
+ void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_WRITE, MAP_SHARED, tf.fd, 0);
ASSERT_NE(MAP_FAILED, map);
close(tf.fd);
@@ -110,7 +110,7 @@
ASSERT_NE(-1, lseek(tf.fd, 0, SEEK_SET));
- void* map = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, tf.fd, pagesize);
+ void* map = mmap(nullptr, pagesize, PROT_READ, MAP_SHARED, tf.fd, pagesize);
ASSERT_NE(MAP_FAILED, map);
char* data = reinterpret_cast<char*>(map);
@@ -118,7 +118,7 @@
ASSERT_EQ(0, munmap(map, pagesize));
- map = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, tf.fd, 2 * pagesize);
+ map = mmap(nullptr, pagesize, PROT_READ, MAP_SHARED, tf.fd, 2 * pagesize);
ASSERT_NE(MAP_FAILED, map);
data = reinterpret_cast<char*>(map);
@@ -146,7 +146,7 @@
ASSERT_NE(-1, lseek(tf.fd, 0, SEEK_SET));
- void* map = mmap(NULL, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, pagesize);
+ void* map = mmap(nullptr, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, pagesize);
ASSERT_NE(MAP_FAILED, map);
close(tf.fd);
@@ -154,7 +154,7 @@
ASSERT_EQ(0, munmap(map, pagesize));
tf.reopen();
- map = mmap(NULL, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, 2 * pagesize);
+ map = mmap(nullptr, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, 2 * pagesize);
ASSERT_NE(MAP_FAILED, map);
close(tf.fd);
@@ -181,7 +181,7 @@
// Prepare environment.
ASSERT_EQ(static_cast<ssize_t>(pagesize), write(tempfile.fd, buf, pagesize));
- void* map = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, tempfile.fd, 0);
+ void* map = mmap(nullptr, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, tempfile.fd, 0);
ASSERT_NE(MAP_FAILED, map);
// Verify different options of posix_madvise.
@@ -199,7 +199,7 @@
TEST(sys_mman, posix_madvise_POSIX_MADV_DONTNEED) {
size_t pagesize = sysconf(_SC_PAGESIZE);
- void* map = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ void* map = mmap(nullptr, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
ASSERT_NE(MAP_FAILED, map);
int* int_ptr = reinterpret_cast<int*>(map);
diff --git a/tests/sys_msg_test.cpp b/tests/sys_msg_test.cpp
index 05ad01b..4eb5a14 100644
--- a/tests/sys_msg_test.cpp
+++ b/tests/sys_msg_test.cpp
@@ -71,7 +71,7 @@
ASSERT_STREQ("hello world", msg.data);
// Destroy the queue.
- ASSERT_EQ(0, msgctl(id, IPC_RMID, 0));
+ ASSERT_EQ(0, msgctl(id, IPC_RMID, nullptr));
}
TEST(sys_msg, msgctl_failure) {
diff --git a/tests/sys_select_test.cpp b/tests/sys_select_test.cpp
index 0eab876..5f019e2 100644
--- a/tests/sys_select_test.cpp
+++ b/tests/sys_select_test.cpp
@@ -89,10 +89,10 @@
int max = STDERR_FILENO + 1;
// Invalid max fd.
- ASSERT_EQ(-1, select(-1, &r, &w, &e, NULL));
+ ASSERT_EQ(-1, select(-1, &r, &w, &e, nullptr));
ASSERT_EQ(EINVAL, errno);
- int num_fds = select(max, &r, &w, &e, NULL);
+ int num_fds = select(max, &r, &w, &e, nullptr);
// If there is data to be read on STDIN, then the number of
// fds ready will be 3 instead of 2. Allow this case, but verify
// every fd that is set.
@@ -117,7 +117,7 @@
FD_ZERO(&r);
FD_SET(fd, &r);
- ASSERT_EQ(1, select(fd+1, &r, NULL, NULL, &tv));
+ ASSERT_EQ(1, select(fd+1, &r, nullptr, nullptr, &tv));
// Both tv_sec and tv_nsec should have been updated.
ASSERT_EQ(0, tv.tv_sec);
ASSERT_NE(0, tv.tv_usec);
@@ -144,13 +144,13 @@
int max = STDERR_FILENO + 1;
// Invalid max fd.
- ASSERT_EQ(-1, pselect(-1, &r, &w, &e, NULL, &ss));
+ ASSERT_EQ(-1, pselect(-1, &r, &w, &e, nullptr, &ss));
ASSERT_EQ(EINVAL, errno);
// If there is data to be read on STDIN, then the number of
// fds ready will be 3 instead of 2. Allow this case, but verify
// every fd that is set.
- int num_fds = pselect(max, &r, &w, &e, NULL, &ss);
+ int num_fds = pselect(max, &r, &w, &e, nullptr, &ss);
ASSERT_TRUE(num_fds == 2 || num_fds == 3) << "Num fds returned " << num_fds;
ASSERT_TRUE(FD_ISSET(STDOUT_FILENO, &w));
ASSERT_TRUE(FD_ISSET(STDERR_FILENO, &w));
@@ -172,7 +172,7 @@
FD_ZERO(&r);
FD_SET(fd, &r);
- ASSERT_EQ(1, pselect(fd+1, &r, NULL, NULL, &tv, NULL));
+ ASSERT_EQ(1, pselect(fd+1, &r, nullptr, nullptr, &tv, nullptr));
// Neither tv_sec nor tv_nsec should have been updated.
ASSERT_EQ(1, tv.tv_sec);
ASSERT_EQ(0, tv.tv_nsec);
diff --git a/tests/sys_shm_test.cpp b/tests/sys_shm_test.cpp
index cf7f3a5..ca2d01a 100644
--- a/tests/sys_shm_test.cpp
+++ b/tests/sys_shm_test.cpp
@@ -52,19 +52,19 @@
ASSERT_EQ(1234U, ds.shm_segsz);
// Attach.
- void* p = shmat(id, 0, SHM_RDONLY);
+ void* p = shmat(id, nullptr, SHM_RDONLY);
ASSERT_NE(p, nullptr);
// Detach.
ASSERT_EQ(0, shmdt(p));
// Destroy the segment.
- ASSERT_EQ(0, shmctl(id, IPC_RMID, 0));
+ ASSERT_EQ(0, shmctl(id, IPC_RMID, nullptr));
}
TEST(sys_shm, shmat_failure) {
errno = 0;
- ASSERT_EQ(reinterpret_cast<void*>(-1), shmat(-1, 0, SHM_RDONLY));
+ ASSERT_EQ(reinterpret_cast<void*>(-1), shmat(-1, nullptr, SHM_RDONLY));
ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
}
diff --git a/tests/sys_socket_test.cpp b/tests/sys_socket_test.cpp
index 506e01f..0342547 100644
--- a/tests/sys_socket_test.cpp
+++ b/tests/sys_socket_test.cpp
@@ -34,7 +34,7 @@
static void* ConnectFn(void* data) {
ConnectData* pdata = reinterpret_cast<ConnectData*>(data);
bool (*callback_fn)(int) = pdata->callback_fn;
- void* return_value = NULL;
+ void* return_value = nullptr;
int fd = socket(PF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (fd < 0) {
@@ -52,7 +52,7 @@
GTEST_LOG_(ERROR) << "connect call failed: " << strerror(errno);
return_value = reinterpret_cast<void*>(-1);
}
- else if (callback_fn != NULL && !callback_fn(fd)) {
+ else if (callback_fn != nullptr && !callback_fn(fd)) {
return_value = reinterpret_cast<void*>(-1);
}
@@ -79,7 +79,7 @@
ConnectData connect_data(callback_fn, sock_path);
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL, ConnectFn, &connect_data));
+ ASSERT_EQ(0, pthread_create(&thread, nullptr, ConnectFn, &connect_data));
fd_set read_set;
FD_ZERO(&read_set);
@@ -87,19 +87,19 @@
timeval tv;
tv.tv_sec = 5;
tv.tv_usec = 0;
- ASSERT_LT(0, select(fd+1, &read_set, NULL, NULL, &tv));
+ ASSERT_LT(0, select(fd+1, &read_set, nullptr, nullptr, &tv));
test_fn(&addr, fd);
void* ret_val;
ASSERT_EQ(0, pthread_join(thread, &ret_val));
- ASSERT_EQ(NULL, ret_val);
+ ASSERT_EQ(nullptr, ret_val);
close(fd);
}
TEST(sys_socket, accept4_error) {
- ASSERT_EQ(-1, accept4(-1, NULL, NULL, 0));
+ ASSERT_EQ(-1, accept4(-1, nullptr, nullptr, 0));
ASSERT_EQ(EBADF, errno);
}
@@ -115,7 +115,7 @@
}
TEST(sys_socket, accept4_smoke) {
- RunTest(TestAccept4, NULL, "test_accept");
+ RunTest(TestAccept4, nullptr, "test_accept");
}
const char* g_RecvMsgs[] = {
@@ -174,7 +174,7 @@
}
TEST(sys_socket, recvmmsg_error) {
- ASSERT_EQ(-1, recvmmsg(-1, NULL, 0, 0, NULL));
+ ASSERT_EQ(-1, recvmmsg(-1, nullptr, 0, 0, nullptr));
ASSERT_EQ(EBADF, errno);
}
@@ -217,7 +217,7 @@
timeval tv;
tv.tv_sec = 5;
tv.tv_usec = 0;
- ASSERT_LT(0, select(fd_acc+1, &read_set, NULL, NULL, &tv));
+ ASSERT_LT(0, select(fd_acc+1, &read_set, nullptr, nullptr, &tv));
char buffer[100];
ASSERT_EQ(strlen(g_SendMsgs[i]) + 1,
static_cast<size_t>(recv(fd_acc, buffer, sizeof(buffer), 0)));
@@ -232,6 +232,6 @@
}
TEST(sys_socket, sendmmsg_error) {
- ASSERT_EQ(-1, sendmmsg(-1, NULL, 0, 0));
+ ASSERT_EQ(-1, sendmmsg(-1, nullptr, 0, 0));
ASSERT_EQ(EBADF, errno);
}
diff --git a/tests/sys_stat_test.cpp b/tests/sys_stat_test.cpp
index 7c387ba..c0a576d 100644
--- a/tests/sys_stat_test.cpp
+++ b/tests/sys_stat_test.cpp
@@ -25,7 +25,7 @@
TEST(sys_stat, futimens) {
FILE* fp = tmpfile();
- ASSERT_TRUE(fp != NULL);
+ ASSERT_TRUE(fp != nullptr);
int fd = fileno(fp);
ASSERT_NE(fd, -1);
diff --git a/tests/sys_time_test.cpp b/tests/sys_time_test.cpp
index e041ba0..b3ec161 100644
--- a/tests/sys_time_test.cpp
+++ b/tests/sys_time_test.cpp
@@ -134,9 +134,9 @@
TEST(sys_time, gettimeofday) {
// Try to ensure that our vdso gettimeofday is working.
timeval tv1;
- ASSERT_EQ(0, gettimeofday(&tv1, NULL));
+ ASSERT_EQ(0, gettimeofday(&tv1, nullptr));
timeval tv2;
- ASSERT_EQ(0, syscall(__NR_gettimeofday, &tv2, NULL));
+ ASSERT_EQ(0, syscall(__NR_gettimeofday, &tv2, nullptr));
// What's the difference between the two?
tv2.tv_sec -= tv1.tv_sec;
diff --git a/tests/sys_xattr_test.cpp b/tests/sys_xattr_test.cpp
index 113ec26..006e840 100644
--- a/tests/sys_xattr_test.cpp
+++ b/tests/sys_xattr_test.cpp
@@ -107,7 +107,7 @@
ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "bar", 4, 0));
ssize_t result = flistxattr(tf.fd, buf, sizeof(buf));
ASSERT_TRUE(result >= 9);
- ASSERT_TRUE(memmem(buf, sizeof(buf), "user.foo", 9) != NULL);
+ ASSERT_TRUE(memmem(buf, sizeof(buf), "user.foo", 9) != nullptr);
}
TEST(sys_xattr, flistattr_opath) {
@@ -120,7 +120,7 @@
#if defined(__BIONIC__)
ASSERT_TRUE(res >= 9);
ASSERT_TRUE(static_cast<size_t>(res) <= sizeof(buf));
- ASSERT_TRUE(memmem(buf, res, "user.foo", 9) != NULL);
+ ASSERT_TRUE(memmem(buf, res, "user.foo", 9) != nullptr);
#else
ASSERT_EQ(-1, res);
ASSERT_EQ(EBADF, errno);
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 216f846..e82f15d 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -59,7 +59,7 @@
TEST(time, gmtime) {
time_t t = 0;
tm* broken_down = gmtime(&t);
- ASSERT_TRUE(broken_down != NULL);
+ ASSERT_TRUE(broken_down != nullptr);
ASSERT_EQ(0, broken_down->tm_sec);
ASSERT_EQ(0, broken_down->tm_min);
ASSERT_EQ(0, broken_down->tm_hour);
@@ -86,11 +86,11 @@
// Ensure we'll actually have to enter tzload by using a time zone that doesn't exist.
setenv("TZ", "gmtime_stack_overflow_14313703", 1);
tzset();
- if (original_tz != NULL) {
+ if (original_tz != nullptr) {
setenv("TZ", original_tz, 1);
}
tzset();
- return NULL;
+ return nullptr;
}
TEST(time, gmtime_no_stack_overflow_14313703) {
@@ -102,7 +102,7 @@
ASSERT_EQ(0, pthread_attr_setstacksize(&a, PTHREAD_STACK_MIN));
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, &a, gmtime_no_stack_overflow_14313703_fn, NULL));
+ ASSERT_EQ(0, pthread_create(&t, &a, gmtime_no_stack_overflow_14313703_fn, nullptr));
ASSERT_EQ(0, pthread_join(t, nullptr));
}
@@ -242,7 +242,7 @@
}
TEST(time, strftime_l) {
- locale_t cloc = newlocale(LC_ALL, "C.UTF-8", 0);
+ locale_t cloc = newlocale(LC_ALL, "C.UTF-8", nullptr);
locale_t old_locale = uselocale(cloc);
setenv("TZ", "UTC", 1);
@@ -302,7 +302,7 @@
ts.it_value.tv_nsec = value_ns;
ts.it_interval.tv_sec = interval_s;
ts.it_interval.tv_nsec = interval_ns;
- ASSERT_EQ(0, timer_settime(t, 0, &ts, NULL));
+ ASSERT_EQ(0, timer_settime(t, 0, &ts, nullptr));
}
static void NoOpNotifyFunction(sigval_t) {
@@ -356,7 +356,7 @@
ts.it_value.tv_nsec = 1;
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
- ASSERT_EQ(0, timer_settime(timer_id, 0, &ts, NULL));
+ ASSERT_EQ(0, timer_settime(timer_id, 0, &ts, nullptr));
usleep(500000);
ASSERT_EQ(1, timer_create_SIGEV_SIGNAL_signal_handler_invocation_count);
@@ -405,8 +405,8 @@
bool ValueUpdated() {
int current_value = value;
- time_t start = time(NULL);
- while (current_value == value && (time(NULL) - start) < 5) {
+ time_t start = time(nullptr);
+ while (current_value == value && (time(nullptr) - start) < 5) {
}
return current_value != value;
}
@@ -458,7 +458,7 @@
TEST(time, timer_create_NULL) {
// A NULL sigevent* is equivalent to asking for SIGEV_SIGNAL for SIGALRM.
timer_t timer_id;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, NULL, &timer_id));
+ ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, nullptr, &timer_id));
timer_create_NULL_signal_handler_invocation_count = 0;
ScopedSignalHandler ssh(SIGALRM, timer_create_NULL_signal_handler);
@@ -476,7 +476,7 @@
// A SIGEV_SIGNAL timer is easy; the kernel does all that.
timer_t timer_id;
- ASSERT_EQ(-1, timer_create(invalid_clock, NULL, &timer_id));
+ ASSERT_EQ(-1, timer_create(invalid_clock, nullptr, &timer_id));
ASSERT_EQ(EINVAL, errno);
// A SIGEV_THREAD timer is more interesting because we have stuff to clean up.
@@ -490,7 +490,7 @@
TEST(time, timer_delete_multiple) {
timer_t timer_id;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, NULL, &timer_id));
+ ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, nullptr, &timer_id));
ASSERT_EQ(0, timer_delete(timer_id));
ASSERT_EQ(-1, timer_delete(timer_id));
ASSERT_EQ(EINVAL, errno);
@@ -593,10 +593,10 @@
ts.it_value.tv_nsec = 0;
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
- ASSERT_EQ(0, timer_settime(tdd.timer_id, 0, &ts, NULL));
+ ASSERT_EQ(0, timer_settime(tdd.timer_id, 0, &ts, nullptr));
- time_t cur_time = time(NULL);
- while (!tdd.complete && (time(NULL) - cur_time) < 5);
+ time_t cur_time = time(nullptr);
+ while (!tdd.complete && (time(nullptr) - cur_time) < 5);
ASSERT_TRUE(tdd.complete);
#if defined(__BIONIC__)
diff --git a/tests/uchar_test.cpp b/tests/uchar_test.cpp
index 2b4c4d3..522d5ac 100644
--- a/tests/uchar_test.cpp
+++ b/tests/uchar_test.cpp
@@ -49,19 +49,19 @@
// Any non-initial state is invalid when calling c32rtomb.
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(NULL, "\xc2", 1, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(nullptr, "\xc2", 1, &ps));
EXPECT_EQ(static_cast<size_t>(-1), c32rtomb(out, 0x00a2, &ps));
EXPECT_EQ(EILSEQ, errno);
- // If the first argument to c32rtomb is NULL or the second is L'\0' the shift
+ // If the first argument to c32rtomb is nullptr or the second is L'\0' the shift
// state should be reset.
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(NULL, "\xc2", 1, &ps));
- EXPECT_EQ(1U, c32rtomb(NULL, 0x00a2, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(nullptr, "\xc2", 1, &ps));
+ EXPECT_EQ(1U, c32rtomb(nullptr, 0x00a2, &ps));
EXPECT_TRUE(mbsinit(&ps));
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(NULL, "\xf0\xa4", 1, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtoc32(nullptr, "\xf0\xa4", 1, &ps));
EXPECT_EQ(1U, c32rtomb(out, L'\0', &ps));
EXPECT_TRUE(mbsinit(&ps));
#else
@@ -71,8 +71,8 @@
TEST(uchar, c16rtomb_null_out) {
#if HAVE_UCHAR
- EXPECT_EQ(1U, c16rtomb(NULL, L'\0', NULL));
- EXPECT_EQ(1U, c16rtomb(NULL, L'h', NULL));
+ EXPECT_EQ(1U, c16rtomb(nullptr, L'\0', nullptr));
+ EXPECT_EQ(1U, c16rtomb(nullptr, L'h', nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -81,7 +81,7 @@
TEST(uchar, c16rtomb_null_char) {
#if HAVE_UCHAR
char bytes[MB_LEN_MAX];
- EXPECT_EQ(1U, c16rtomb(bytes, L'\0', NULL));
+ EXPECT_EQ(1U, c16rtomb(bytes, L'\0', nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -92,7 +92,7 @@
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, c16rtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, c16rtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
@@ -100,16 +100,16 @@
// 1-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, c16rtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, c16rtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
// 2-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(2U, c16rtomb(bytes, 0x00a2, NULL));
+ EXPECT_EQ(2U, c16rtomb(bytes, 0x00a2, nullptr));
EXPECT_EQ('\xc2', bytes[0]);
EXPECT_EQ('\xa2', bytes[1]);
// 3-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(3U, c16rtomb(bytes, 0x20ac, NULL));
+ EXPECT_EQ(3U, c16rtomb(bytes, 0x20ac, nullptr));
EXPECT_EQ('\xe2', bytes[0]);
EXPECT_EQ('\x82', bytes[1]);
EXPECT_EQ('\xac', bytes[2]);
@@ -123,8 +123,8 @@
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(0U, c16rtomb(bytes, 0xdbea, NULL));
- EXPECT_EQ(4U, c16rtomb(bytes, 0xdfcd, NULL));
+ EXPECT_EQ(0U, c16rtomb(bytes, 0xdbea, nullptr));
+ EXPECT_EQ(4U, c16rtomb(bytes, 0xdfcd, nullptr));
EXPECT_EQ('\xf4', bytes[0]);
EXPECT_EQ('\x8a', bytes[1]);
EXPECT_EQ('\xaf', bytes[2]);
@@ -139,10 +139,10 @@
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(static_cast<size_t>(-1), c16rtomb(bytes, 0xdfcd, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), c16rtomb(bytes, 0xdfcd, nullptr));
- EXPECT_EQ(0U, c16rtomb(bytes, 0xdbea, NULL));
- EXPECT_EQ(static_cast<size_t>(-1), c16rtomb(bytes, 0xdbea, NULL));
+ EXPECT_EQ(0U, c16rtomb(bytes, 0xdbea, nullptr));
+ EXPECT_EQ(static_cast<size_t>(-1), c16rtomb(bytes, 0xdbea, nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -150,7 +150,7 @@
TEST(uchar, mbrtoc16_null) {
#if HAVE_UCHAR
- ASSERT_EQ(0U, mbrtoc16(NULL, NULL, 0, NULL));
+ ASSERT_EQ(0U, mbrtoc16(nullptr, nullptr, 0, nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -161,12 +161,12 @@
char16_t out;
out = L'x';
- ASSERT_EQ(0U, mbrtoc16(&out, "hello", 0, NULL));
+ ASSERT_EQ(0U, mbrtoc16(&out, "hello", 0, nullptr));
ASSERT_EQ(L'x', out);
- ASSERT_EQ(0U, mbrtoc16(&out, "hello", 0, NULL));
- ASSERT_EQ(0U, mbrtoc16(&out, "", 0, NULL));
- ASSERT_EQ(1U, mbrtoc16(&out, "hello", 1, NULL));
+ ASSERT_EQ(0U, mbrtoc16(&out, "hello", 0, nullptr));
+ ASSERT_EQ(0U, mbrtoc16(&out, "", 0, nullptr));
+ ASSERT_EQ(1U, mbrtoc16(&out, "hello", 1, nullptr));
ASSERT_EQ(L'h', out);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
@@ -181,13 +181,13 @@
uselocale(LC_GLOBAL_LOCALE);
// 1-byte UTF-8.
- ASSERT_EQ(1U, mbrtoc16(&out, "abcdef", 6, NULL));
+ ASSERT_EQ(1U, mbrtoc16(&out, "abcdef", 6, nullptr));
ASSERT_EQ(L'a', out);
// 2-byte UTF-8.
- ASSERT_EQ(2U, mbrtoc16(&out, "\xc2\xa2" "cdef", 6, NULL));
+ ASSERT_EQ(2U, mbrtoc16(&out, "\xc2\xa2" "cdef", 6, nullptr));
ASSERT_EQ(static_cast<char16_t>(0x00a2), out);
// 3-byte UTF-8.
- ASSERT_EQ(3U, mbrtoc16(&out, "\xe2\x82\xac" "def", 6, NULL));
+ ASSERT_EQ(3U, mbrtoc16(&out, "\xe2\x82\xac" "def", 6, nullptr));
ASSERT_EQ(static_cast<char16_t>(0x20ac), out);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
@@ -199,9 +199,9 @@
char16_t out;
ASSERT_EQ(static_cast<size_t>(-3),
- mbrtoc16(&out, "\xf4\x8a\xaf\x8d", 6, NULL));
+ mbrtoc16(&out, "\xf4\x8a\xaf\x8d", 6, nullptr));
ASSERT_EQ(static_cast<char16_t>(0xdbea), out);
- ASSERT_EQ(4U, mbrtoc16(&out, "\xf4\x8a\xaf\x8d" "ef", 6, NULL));
+ ASSERT_EQ(4U, mbrtoc16(&out, "\xf4\x8a\xaf\x8d" "ef", 6, nullptr));
ASSERT_EQ(static_cast<char16_t>(0xdfcd), out);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
@@ -212,7 +212,7 @@
#if HAVE_UCHAR
char16_t out;
ASSERT_EQ(static_cast<size_t>(-1),
- mbrtoc16(&out, "\xf0\x80\xbf\xbf", 6, NULL));
+ mbrtoc16(&out, "\xf0\x80\xbf\xbf", 6, nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -222,7 +222,7 @@
#if HAVE_UCHAR
char16_t out;
ASSERT_EQ(static_cast<size_t>(-1),
- mbrtoc16(&out, "\xf5\x80\x80\x80", 6, NULL));
+ mbrtoc16(&out, "\xf5\x80\x80\x80", 6, nullptr));
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -267,7 +267,7 @@
memset(&ps, 0, sizeof(ps));
test_mbrtoc16_incomplete(&ps);
- test_mbrtoc16_incomplete(NULL);
+ test_mbrtoc16_incomplete(nullptr);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
@@ -275,18 +275,18 @@
TEST(uchar, c32rtomb) {
#if HAVE_UCHAR
- EXPECT_EQ(1U, c32rtomb(NULL, L'\0', NULL));
- EXPECT_EQ(1U, c32rtomb(NULL, L'h', NULL));
+ EXPECT_EQ(1U, c32rtomb(nullptr, L'\0', nullptr));
+ EXPECT_EQ(1U, c32rtomb(nullptr, L'h', nullptr));
char bytes[MB_LEN_MAX];
memset(bytes, 1, sizeof(bytes));
- EXPECT_EQ(1U, c32rtomb(bytes, L'\0', NULL));
+ EXPECT_EQ(1U, c32rtomb(bytes, L'\0', nullptr));
EXPECT_EQ('\0', bytes[0]);
EXPECT_EQ('\x01', bytes[1]);
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, c32rtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, c32rtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
@@ -294,28 +294,28 @@
// 1-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, c32rtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, c32rtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
// 2-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(2U, c32rtomb(bytes, 0x00a2, NULL));
+ EXPECT_EQ(2U, c32rtomb(bytes, 0x00a2, nullptr));
EXPECT_EQ('\xc2', bytes[0]);
EXPECT_EQ('\xa2', bytes[1]);
// 3-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(3U, c32rtomb(bytes, 0x20ac, NULL));
+ EXPECT_EQ(3U, c32rtomb(bytes, 0x20ac, nullptr));
EXPECT_EQ('\xe2', bytes[0]);
EXPECT_EQ('\x82', bytes[1]);
EXPECT_EQ('\xac', bytes[2]);
// 4-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(4U, c32rtomb(bytes, 0x24b62, NULL));
+ EXPECT_EQ(4U, c32rtomb(bytes, 0x24b62, nullptr));
EXPECT_EQ('\xf0', bytes[0]);
EXPECT_EQ('\xa4', bytes[1]);
EXPECT_EQ('\xad', bytes[2]);
EXPECT_EQ('\xa2', bytes[3]);
// Invalid code point.
- EXPECT_EQ(static_cast<size_t>(-1), c32rtomb(bytes, 0xffffffff, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), c32rtomb(bytes, 0xffffffff, nullptr));
EXPECT_EQ(EILSEQ, errno);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
@@ -356,42 +356,42 @@
char32_t out[8];
out[0] = L'x';
- ASSERT_EQ(0U, mbrtoc32(out, "hello", 0, NULL));
+ ASSERT_EQ(0U, mbrtoc32(out, "hello", 0, nullptr));
ASSERT_EQ(static_cast<char32_t>(L'x'), out[0]);
- ASSERT_EQ(0U, mbrtoc32(out, "hello", 0, NULL));
- ASSERT_EQ(0U, mbrtoc32(out, "", 0, NULL));
- ASSERT_EQ(1U, mbrtoc32(out, "hello", 1, NULL));
+ ASSERT_EQ(0U, mbrtoc32(out, "hello", 0, nullptr));
+ ASSERT_EQ(0U, mbrtoc32(out, "", 0, nullptr));
+ ASSERT_EQ(1U, mbrtoc32(out, "hello", 1, nullptr));
ASSERT_EQ(static_cast<char32_t>(L'h'), out[0]);
- ASSERT_EQ(0U, mbrtoc32(NULL, "hello", 0, NULL));
- ASSERT_EQ(0U, mbrtoc32(NULL, "", 0, NULL));
- ASSERT_EQ(1U, mbrtoc32(NULL, "hello", 1, NULL));
+ ASSERT_EQ(0U, mbrtoc32(nullptr, "hello", 0, nullptr));
+ ASSERT_EQ(0U, mbrtoc32(nullptr, "", 0, nullptr));
+ ASSERT_EQ(1U, mbrtoc32(nullptr, "hello", 1, nullptr));
- ASSERT_EQ(0U, mbrtoc32(NULL, NULL, 0, NULL));
+ ASSERT_EQ(0U, mbrtoc32(nullptr, nullptr, 0, nullptr));
ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
uselocale(LC_GLOBAL_LOCALE);
// 1-byte UTF-8.
- ASSERT_EQ(1U, mbrtoc32(out, "abcdef", 6, NULL));
+ ASSERT_EQ(1U, mbrtoc32(out, "abcdef", 6, nullptr));
ASSERT_EQ(static_cast<char32_t>(L'a'), out[0]);
// 2-byte UTF-8.
- ASSERT_EQ(2U, mbrtoc32(out, "\xc2\xa2" "cdef", 6, NULL));
+ ASSERT_EQ(2U, mbrtoc32(out, "\xc2\xa2" "cdef", 6, nullptr));
ASSERT_EQ(static_cast<char32_t>(0x00a2), out[0]);
// 3-byte UTF-8.
- ASSERT_EQ(3U, mbrtoc32(out, "\xe2\x82\xac" "def", 6, NULL));
+ ASSERT_EQ(3U, mbrtoc32(out, "\xe2\x82\xac" "def", 6, nullptr));
ASSERT_EQ(static_cast<char32_t>(0x20ac), out[0]);
// 4-byte UTF-8.
- ASSERT_EQ(4U, mbrtoc32(out, "\xf0\xa4\xad\xa2" "ef", 6, NULL));
+ ASSERT_EQ(4U, mbrtoc32(out, "\xf0\xa4\xad\xa2" "ef", 6, nullptr));
ASSERT_EQ(static_cast<char32_t>(0x24b62), out[0]);
#if defined(__BIONIC__) // glibc allows this.
// Illegal 5-byte UTF-8.
- ASSERT_EQ(static_cast<size_t>(-1), mbrtoc32(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, NULL));
+ ASSERT_EQ(static_cast<size_t>(-1), mbrtoc32(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, nullptr));
ASSERT_EQ(EILSEQ, errno);
#endif
// Illegal over-long sequence.
- ASSERT_EQ(static_cast<size_t>(-1), mbrtoc32(out, "\xf0\x82\x82\xac" "ef", 6, NULL));
+ ASSERT_EQ(static_cast<size_t>(-1), mbrtoc32(out, "\xf0\x82\x82\xac" "ef", 6, nullptr));
ASSERT_EQ(EILSEQ, errno);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
@@ -435,7 +435,7 @@
memset(&ps, 0, sizeof(ps));
test_mbrtoc32_incomplete(&ps);
- test_mbrtoc32_incomplete(NULL);
+ test_mbrtoc32_incomplete(nullptr);
#else
GTEST_LOG_(INFO) << "uchar.h is unavailable.\n";
#endif
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index fd99455..1f7f555 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -273,7 +273,7 @@
ASSERT_EQ(0, setenv("test-variable", "hello", 1));
ASSERT_STREQ("hello", getenv("test-variable"));
ASSERT_EQ(0, unsetenv("test-variable"));
- ASSERT_TRUE(getenv("test-variable") == NULL);
+ ASSERT_TRUE(getenv("test-variable") == nullptr);
}
TEST(UNISTD_TEST, unsetenv_EINVAL) {
@@ -284,9 +284,9 @@
}
TEST(UNISTD_TEST, setenv_EINVAL) {
- EXPECT_EQ(-1, setenv(NULL, "value", 0));
+ EXPECT_EQ(-1, setenv(nullptr, "value", 0));
EXPECT_EQ(EINVAL, errno);
- EXPECT_EQ(-1, setenv(NULL, "value", 1));
+ EXPECT_EQ(-1, setenv(nullptr, "value", 1));
EXPECT_EQ(EINVAL, errno);
EXPECT_EQ(-1, setenv("", "value", 0));
EXPECT_EQ(EINVAL, errno);
@@ -353,14 +353,14 @@
// Stash a copy.
std::vector<char*> old_environ;
- for (size_t i = 0; environ[i] != NULL; ++i) {
+ for (size_t i = 0; environ[i] != nullptr; ++i) {
old_environ.push_back(strdup(environ[i]));
}
ASSERT_EQ(0, clearenv());
- EXPECT_TRUE(environ == NULL || environ[0] == NULL);
- EXPECT_EQ(NULL, getenv("test-variable"));
+ EXPECT_TRUE(environ == nullptr || environ[0] == nullptr);
+ EXPECT_EQ(nullptr, getenv("test-variable"));
EXPECT_EQ(0, setenv("test-variable", "post-clear", 1));
EXPECT_STREQ("post-clear", getenv("test-variable"));
@@ -539,7 +539,7 @@
static int CloneStartRoutine(int (*start_routine)(void*)) {
void* child_stack[1024];
- return clone(start_routine, &child_stack[1024], SIGCHLD, NULL);
+ return clone(start_routine, &child_stack[1024], SIGCHLD, nullptr);
}
static int GetPidCachingCloneStartRoutine(void*) {
@@ -594,20 +594,20 @@
static void* GetPidCachingPthreadStartRoutine(void*) {
AssertGetPidCorrect();
- return NULL;
+ return nullptr;
}
TEST(UNISTD_TEST, getpid_caching_and_pthread_create) {
pid_t parent_pid = getpid();
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, GetPidCachingPthreadStartRoutine, NULL));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, GetPidCachingPthreadStartRoutine, nullptr));
ASSERT_EQ(parent_pid, getpid());
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
- ASSERT_EQ(NULL, result);
+ ASSERT_EQ(nullptr, result);
}
static void* GetTidCachingPthreadStartRoutine(void*) {
@@ -620,7 +620,7 @@
pid_t parent_tid = GetTidForTest();
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, GetTidCachingPthreadStartRoutine, &parent_tid));
+ ASSERT_EQ(0, pthread_create(&t, nullptr, GetTidCachingPthreadStartRoutine, &parent_tid));
ASSERT_EQ(parent_tid, GetTidForTest());
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp
index e2def07..9aef800 100644
--- a/tests/wchar_test.cpp
+++ b/tests/wchar_test.cpp
@@ -35,32 +35,32 @@
TEST(wchar, mbrlen) {
char bytes[] = { 'h', 'e', 'l', 'l', 'o', '\0' };
- EXPECT_EQ(0U, mbrlen(&bytes[0], 0, NULL));
- EXPECT_EQ(1U, mbrlen(&bytes[0], 1, NULL));
+ EXPECT_EQ(0U, mbrlen(&bytes[0], 0, nullptr));
+ EXPECT_EQ(1U, mbrlen(&bytes[0], 1, nullptr));
- EXPECT_EQ(1U, mbrlen(&bytes[4], 1, NULL));
- EXPECT_EQ(0U, mbrlen(&bytes[5], 1, NULL));
+ EXPECT_EQ(1U, mbrlen(&bytes[4], 1, nullptr));
+ EXPECT_EQ(0U, mbrlen(&bytes[5], 1, nullptr));
}
TEST(wchar, wctomb_wcrtomb) {
// wctomb and wcrtomb behave differently when s == NULL.
- EXPECT_EQ(0, wctomb(NULL, L'h'));
- EXPECT_EQ(0, wctomb(NULL, L'\0'));
- EXPECT_EQ(1U, wcrtomb(NULL, L'\0', NULL));
- EXPECT_EQ(1U, wcrtomb(NULL, L'h', NULL));
+ EXPECT_EQ(0, wctomb(nullptr, L'h'));
+ EXPECT_EQ(0, wctomb(nullptr, L'\0'));
+ EXPECT_EQ(1U, wcrtomb(nullptr, L'\0', nullptr));
+ EXPECT_EQ(1U, wcrtomb(nullptr, L'h', nullptr));
char bytes[MB_LEN_MAX];
// wctomb and wcrtomb behave similarly for the null wide character.
EXPECT_EQ(1, wctomb(bytes, L'\0'));
- EXPECT_EQ(1U, wcrtomb(bytes, L'\0', NULL));
+ EXPECT_EQ(1U, wcrtomb(bytes, L'\0', nullptr));
// ...and for regular characters.
memset(bytes, 0, sizeof(bytes));
EXPECT_EQ(1, wctomb(bytes, L'h'));
EXPECT_EQ('h', bytes[0]);
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, wcrtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, wcrtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
@@ -68,28 +68,28 @@
// 1-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(1U, wcrtomb(bytes, L'h', NULL));
+ EXPECT_EQ(1U, wcrtomb(bytes, L'h', nullptr));
EXPECT_EQ('h', bytes[0]);
// 2-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(2U, wcrtomb(bytes, 0x00a2, NULL));
+ EXPECT_EQ(2U, wcrtomb(bytes, 0x00a2, nullptr));
EXPECT_EQ('\xc2', bytes[0]);
EXPECT_EQ('\xa2', bytes[1]);
// 3-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(3U, wcrtomb(bytes, 0x20ac, NULL));
+ EXPECT_EQ(3U, wcrtomb(bytes, 0x20ac, nullptr));
EXPECT_EQ('\xe2', bytes[0]);
EXPECT_EQ('\x82', bytes[1]);
EXPECT_EQ('\xac', bytes[2]);
// 4-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
- EXPECT_EQ(4U, wcrtomb(bytes, 0x24b62, NULL));
+ EXPECT_EQ(4U, wcrtomb(bytes, 0x24b62, nullptr));
EXPECT_EQ('\xf0', bytes[0]);
EXPECT_EQ('\xa4', bytes[1]);
EXPECT_EQ('\xad', bytes[2]);
EXPECT_EQ('\xa2', bytes[3]);
// Invalid code point.
- EXPECT_EQ(static_cast<size_t>(-1), wcrtomb(bytes, 0xffffffff, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), wcrtomb(bytes, 0xffffffff, nullptr));
EXPECT_EQ(EILSEQ, errno);
}
@@ -99,19 +99,19 @@
// Any non-initial state is invalid when calling wcrtomb.
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(NULL, "\xc2", 1, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(nullptr, "\xc2", 1, &ps));
EXPECT_EQ(static_cast<size_t>(-1), wcrtomb(out, 0x00a2, &ps));
EXPECT_EQ(EILSEQ, errno);
// If the first argument to wcrtomb is NULL or the second is L'\0' the shift
// state should be reset.
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(NULL, "\xc2", 1, &ps));
- EXPECT_EQ(1U, wcrtomb(NULL, 0x00a2, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(nullptr, "\xc2", 1, &ps));
+ EXPECT_EQ(1U, wcrtomb(nullptr, 0x00a2, &ps));
EXPECT_TRUE(mbsinit(&ps));
memset(&ps, 0, sizeof(ps));
- EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(NULL, "\xf0\xa4", 1, &ps));
+ EXPECT_EQ(static_cast<size_t>(-2), mbrtowc(nullptr, "\xf0\xa4", 1, &ps));
EXPECT_EQ(1U, wcrtomb(out, L'\0', &ps));
EXPECT_TRUE(mbsinit(&ps));
}
@@ -123,37 +123,37 @@
char bytes[BUFSIZ];
// Given a NULL destination, these functions count valid characters.
- EXPECT_EQ(5U, wcstombs(NULL, chars, 0));
- EXPECT_EQ(5U, wcstombs(NULL, chars, 4));
- EXPECT_EQ(5U, wcstombs(NULL, chars, 256));
+ EXPECT_EQ(5U, wcstombs(nullptr, chars, 0));
+ EXPECT_EQ(5U, wcstombs(nullptr, chars, 4));
+ EXPECT_EQ(5U, wcstombs(nullptr, chars, 256));
src = chars;
- EXPECT_EQ(5U, wcsrtombs(NULL, &src, 0, NULL));
+ EXPECT_EQ(5U, wcsrtombs(nullptr, &src, 0, nullptr));
EXPECT_EQ(&chars[0], src);
src = chars;
- EXPECT_EQ(5U, wcsrtombs(NULL, &src, 4, NULL));
+ EXPECT_EQ(5U, wcsrtombs(nullptr, &src, 4, nullptr));
EXPECT_EQ(&chars[0], src);
src = chars;
- EXPECT_EQ(5U, wcsrtombs(NULL, &src, 256, NULL));
+ EXPECT_EQ(5U, wcsrtombs(nullptr, &src, 256, nullptr));
EXPECT_EQ(&chars[0], src);
// An unrepresentable char just returns an error from wcstombs...
errno = 0;
- EXPECT_EQ(static_cast<size_t>(-1), wcstombs(NULL, bad_chars, 0));
+ EXPECT_EQ(static_cast<size_t>(-1), wcstombs(nullptr, bad_chars, 0));
EXPECT_EQ(EILSEQ, errno);
errno = 0;
- EXPECT_EQ(static_cast<size_t>(-1), wcstombs(NULL, bad_chars, 256));
+ EXPECT_EQ(static_cast<size_t>(-1), wcstombs(nullptr, bad_chars, 256));
EXPECT_EQ(EILSEQ, errno);
// And wcsrtombs doesn't tell us where it got stuck because we didn't ask it
// to actually convert anything...
errno = 0;
src = bad_chars;
- EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(NULL, &src, 0, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(nullptr, &src, 0, nullptr));
EXPECT_EQ(&bad_chars[0], src);
EXPECT_EQ(EILSEQ, errno);
errno = 0;
src = bad_chars;
- EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(NULL, &src, 256, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(nullptr, &src, 256, nullptr));
EXPECT_EQ(&bad_chars[0], src);
EXPECT_EQ(EILSEQ, errno);
@@ -180,13 +180,13 @@
// wcsrtombs is a bit more informative...
memset(bytes, 'x', sizeof(bytes));
src = chars;
- EXPECT_EQ(0U, wcsrtombs(bytes, &src, 0, NULL));
+ EXPECT_EQ(0U, wcsrtombs(bytes, &src, 0, nullptr));
EXPECT_EQ(&chars[0], src); // No input consumed.
EXPECT_EQ(EILSEQ, errno);
memset(bytes, 'x', sizeof(bytes));
src = chars;
- EXPECT_EQ(4U, wcsrtombs(bytes, &src, 4, NULL));
+ EXPECT_EQ(4U, wcsrtombs(bytes, &src, 4, nullptr));
EXPECT_EQ(&chars[4], src); // Some input consumed.
EXPECT_EQ(EILSEQ, errno);
bytes[5] = 0;
@@ -194,21 +194,21 @@
memset(bytes, 'x', sizeof(bytes));
src = chars;
- EXPECT_EQ(5U, wcsrtombs(bytes, &src, 256, NULL));
- EXPECT_EQ(NULL, src); // All input consumed!
+ EXPECT_EQ(5U, wcsrtombs(bytes, &src, 256, nullptr));
+ EXPECT_EQ(nullptr, src); // All input consumed!
EXPECT_EQ(EILSEQ, errno);
EXPECT_STREQ("hello", bytes);
memset(bytes, 'x', sizeof(bytes));
src = chars;
- EXPECT_EQ(5U, wcsrtombs(bytes, &src, 6, NULL));
- EXPECT_EQ(NULL, src); // All input consumed.
+ EXPECT_EQ(5U, wcsrtombs(bytes, &src, 6, nullptr));
+ EXPECT_EQ(nullptr, src); // All input consumed.
EXPECT_EQ(EILSEQ, errno);
EXPECT_STREQ("hello", bytes);
memset(bytes, 'x', sizeof(bytes));
src = bad_chars;
- EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(bytes, &src, 256, NULL));
+ EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(bytes, &src, 256, nullptr));
EXPECT_EQ(&bad_chars[2], src);
EXPECT_EQ(EILSEQ, errno);
bytes[3] = 0;
@@ -218,8 +218,8 @@
mbstate_t ps;
src = chars;
memset(&ps, 0, sizeof(ps));
- ASSERT_EQ(static_cast<size_t>(-2), mbrtowc(NULL, "\xc2", 1, &ps));
- EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(NULL, &src, 0, &ps));
+ ASSERT_EQ(static_cast<size_t>(-2), mbrtowc(nullptr, "\xc2", 1, &ps));
+ EXPECT_EQ(static_cast<size_t>(-1), wcsrtombs(nullptr, &src, 0, &ps));
EXPECT_EQ(EILSEQ, errno);
}
@@ -235,12 +235,12 @@
ASSERT_EQ(haystack, wcsstr(haystack, empty_needle));
ASSERT_EQ(&haystack[10], wcsstr(haystack, good_needle));
- ASSERT_EQ(NULL, wcsstr(haystack, bad_needle));
+ ASSERT_EQ(nullptr, wcsstr(haystack, bad_needle));
}
TEST(wchar, wcsstr_80199) {
// https://code.google.com/p/android/issues/detail?id=80199
- ASSERT_TRUE(wcsstr(L"romrom", L"rom") != NULL);
+ ASSERT_TRUE(wcsstr(L"romrom", L"rom") != nullptr);
}
TEST(wchar, mbtowc) {
@@ -255,53 +255,53 @@
ASSERT_EQ(1, mbtowc(out, "hello", 1));
ASSERT_EQ(L'h', out[0]);
- ASSERT_EQ(0, mbtowc(NULL, "hello", 0));
- ASSERT_EQ(0, mbtowc(NULL, "", 0));
- ASSERT_EQ(1, mbtowc(NULL, "hello", 1));
+ ASSERT_EQ(0, mbtowc(nullptr, "hello", 0));
+ ASSERT_EQ(0, mbtowc(nullptr, "", 0));
+ ASSERT_EQ(1, mbtowc(nullptr, "hello", 1));
- ASSERT_EQ(0, mbtowc(NULL, NULL, 0));
+ ASSERT_EQ(0, mbtowc(nullptr, nullptr, 0));
}
TEST(wchar, mbrtowc) {
wchar_t out[8];
out[0] = 'x';
- ASSERT_EQ(0U, mbrtowc(out, "hello", 0, NULL));
+ ASSERT_EQ(0U, mbrtowc(out, "hello", 0, nullptr));
ASSERT_EQ('x', out[0]);
- ASSERT_EQ(0U, mbrtowc(out, "hello", 0, NULL));
- ASSERT_EQ(0U, mbrtowc(out, "", 0, NULL));
- ASSERT_EQ(1U, mbrtowc(out, "hello", 1, NULL));
+ ASSERT_EQ(0U, mbrtowc(out, "hello", 0, nullptr));
+ ASSERT_EQ(0U, mbrtowc(out, "", 0, nullptr));
+ ASSERT_EQ(1U, mbrtowc(out, "hello", 1, nullptr));
ASSERT_EQ(L'h', out[0]);
- ASSERT_EQ(0U, mbrtowc(NULL, "hello", 0, NULL));
- ASSERT_EQ(0U, mbrtowc(NULL, "", 0, NULL));
- ASSERT_EQ(1U, mbrtowc(NULL, "hello", 1, NULL));
+ ASSERT_EQ(0U, mbrtowc(nullptr, "hello", 0, nullptr));
+ ASSERT_EQ(0U, mbrtowc(nullptr, "", 0, nullptr));
+ ASSERT_EQ(1U, mbrtowc(nullptr, "hello", 1, nullptr));
- ASSERT_EQ(0U, mbrtowc(NULL, NULL, 0, NULL));
+ ASSERT_EQ(0U, mbrtowc(nullptr, nullptr, 0, nullptr));
ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
uselocale(LC_GLOBAL_LOCALE);
// 1-byte UTF-8.
- ASSERT_EQ(1U, mbrtowc(out, "abcdef", 6, NULL));
+ ASSERT_EQ(1U, mbrtowc(out, "abcdef", 6, nullptr));
ASSERT_EQ(L'a', out[0]);
// 2-byte UTF-8.
- ASSERT_EQ(2U, mbrtowc(out, "\xc2\xa2" "cdef", 6, NULL));
+ ASSERT_EQ(2U, mbrtowc(out, "\xc2\xa2" "cdef", 6, nullptr));
ASSERT_EQ(static_cast<wchar_t>(0x00a2), out[0]);
// 3-byte UTF-8.
- ASSERT_EQ(3U, mbrtowc(out, "\xe2\x82\xac" "def", 6, NULL));
+ ASSERT_EQ(3U, mbrtowc(out, "\xe2\x82\xac" "def", 6, nullptr));
ASSERT_EQ(static_cast<wchar_t>(0x20ac), out[0]);
// 4-byte UTF-8.
- ASSERT_EQ(4U, mbrtowc(out, "\xf0\xa4\xad\xa2" "ef", 6, NULL));
+ ASSERT_EQ(4U, mbrtowc(out, "\xf0\xa4\xad\xa2" "ef", 6, nullptr));
ASSERT_EQ(static_cast<wchar_t>(0x24b62), out[0]);
#if defined(__BIONIC__) // glibc allows this.
// Illegal 5-byte UTF-8.
- ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, NULL));
+ ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, nullptr));
ASSERT_EQ(EILSEQ, errno);
#endif
// Illegal over-long sequence.
- ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf0\x82\x82\xac" "ef", 6, NULL));
+ ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf0\x82\x82\xac" "ef", 6, nullptr));
ASSERT_EQ(EILSEQ, errno);
}
@@ -361,7 +361,7 @@
memset(&ps, 0, sizeof(ps));
test_mbrtowc_incomplete(&ps);
- test_mbrtowc_incomplete(NULL);
+ test_mbrtowc_incomplete(nullptr);
}
static void test_mbsrtowcs(mbstate_t* ps) {
@@ -419,7 +419,7 @@
mbstate_t ps;
memset(&ps, 0, sizeof(ps));
test_mbsrtowcs(&ps);
- test_mbsrtowcs(NULL);
+ test_mbsrtowcs(nullptr);
// Invalid multi byte continuation.
const char* invalid = "\x20";
@@ -531,18 +531,18 @@
memset(dst, 0, sizeof(dst));
src = s;
- ASSERT_EQ(0U, mbsnrtowcs(dst, &src, 0, 0, NULL));
+ ASSERT_EQ(0U, mbsnrtowcs(dst, &src, 0, 0, nullptr));
memset(dst, 0, sizeof(dst));
src = s;
- ASSERT_EQ(2U, mbsnrtowcs(dst, &src, 2, 123, NULL)); // glibc chokes on SIZE_MAX here.
+ ASSERT_EQ(2U, mbsnrtowcs(dst, &src, 2, 123, nullptr)); // glibc chokes on SIZE_MAX here.
ASSERT_EQ(L'h', dst[0]);
ASSERT_EQ(L'e', dst[1]);
ASSERT_EQ(&s[2], src);
memset(dst, 0, sizeof(dst));
src = s;
- ASSERT_EQ(3U, mbsnrtowcs(dst, &src, SIZE_MAX, 3, NULL));
+ ASSERT_EQ(3U, mbsnrtowcs(dst, &src, SIZE_MAX, 3, nullptr));
ASSERT_EQ(L'h', dst[0]);
ASSERT_EQ(L'e', dst[1]);
ASSERT_EQ(L'l', dst[2]);
@@ -669,19 +669,19 @@
size_t n;
// 1-byte character.
- n = mbrtowc(&wc, "x", MB_CUR_MAX, NULL);
+ n = mbrtowc(&wc, "x", MB_CUR_MAX, nullptr);
EXPECT_EQ(1U, n);
EXPECT_EQ(L'x', wc);
// 2-byte character.
- n = mbrtowc(&wc, "\xc2\xa2", MB_CUR_MAX, NULL);
+ n = mbrtowc(&wc, "\xc2\xa2", MB_CUR_MAX, nullptr);
EXPECT_EQ(2U, n);
EXPECT_EQ(L'¢', wc);
// 3-byte character.
- n = mbrtowc(&wc, "\xe2\x82\xac", MB_CUR_MAX, NULL);
+ n = mbrtowc(&wc, "\xe2\x82\xac", MB_CUR_MAX, nullptr);
EXPECT_EQ(3U, n);
EXPECT_EQ(L'€', wc);
// 4-byte character.
- n = mbrtowc(&wc, "\xf0\xa4\xad\xa2", MB_CUR_MAX, NULL);
+ n = mbrtowc(&wc, "\xf0\xa4\xad\xa2", MB_CUR_MAX, nullptr);
EXPECT_EQ(4U, n);
EXPECT_EQ(L'𤭢', wc);
}
@@ -719,73 +719,73 @@
TEST(wchar, wcstol_EINVAL) {
errno = 0;
- wcstol(L"123", NULL, -1);
+ wcstol(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstol(L"123", NULL, 1);
+ wcstol(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstol(L"123", NULL, 37);
+ wcstol(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(wchar, wcstoll_EINVAL) {
errno = 0;
- wcstoll(L"123", NULL, -1);
+ wcstoll(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoll(L"123", NULL, 1);
+ wcstoll(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoll(L"123", NULL, 37);
+ wcstoll(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(wchar, wcstoul_EINVAL) {
errno = 0;
- wcstoul(L"123", NULL, -1);
+ wcstoul(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoul(L"123", NULL, 1);
+ wcstoul(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoul(L"123", NULL, 37);
+ wcstoul(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(wchar, wcstoull_EINVAL) {
errno = 0;
- wcstoull(L"123", NULL, -1);
+ wcstoull(L"123", nullptr, -1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoull(L"123", NULL, 1);
+ wcstoull(L"123", nullptr, 1);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoull(L"123", NULL, 37);
+ wcstoull(L"123", nullptr, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(wchar, wcstoll_l_EINVAL) {
errno = 0;
- wcstoll_l(L"123", NULL, -1, LC_GLOBAL_LOCALE);
+ wcstoll_l(L"123", nullptr, -1, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoll_l(L"123", NULL, 1, LC_GLOBAL_LOCALE);
+ wcstoll_l(L"123", nullptr, 1, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoll_l(L"123", NULL, 37, LC_GLOBAL_LOCALE);
+ wcstoll_l(L"123", nullptr, 37, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
}
TEST(wchar, wcstoull_l_EINVAL) {
errno = 0;
- wcstoull_l(L"123", NULL, -1, LC_GLOBAL_LOCALE);
+ wcstoull_l(L"123", nullptr, -1, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoull_l(L"123", NULL, 1, LC_GLOBAL_LOCALE);
+ wcstoull_l(L"123", nullptr, 1, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
errno = 0;
- wcstoull_l(L"123", NULL, 37, LC_GLOBAL_LOCALE);
+ wcstoull_l(L"123", nullptr, 37, LC_GLOBAL_LOCALE);
ASSERT_EQ(EINVAL, errno);
}
diff --git a/tests/wctype_test.cpp b/tests/wctype_test.cpp
index 7da53e0..06e1571 100644
--- a/tests/wctype_test.cpp
+++ b/tests/wctype_test.cpp
@@ -24,7 +24,7 @@
class UtfLocale {
public:
- UtfLocale() : l(newlocale(LC_ALL, "C.UTF-8", 0)) {}
+ UtfLocale() : l(newlocale(LC_ALL, "C.UTF-8", nullptr)) {}
~UtfLocale() { freelocale(l); }
locale_t l;
};
@@ -215,18 +215,18 @@
}
TEST(wctype, towctrans) {
- EXPECT_TRUE(wctrans("tolower") != 0);
- EXPECT_TRUE(wctrans("toupper") != 0);
+ EXPECT_TRUE(wctrans("tolower") != nullptr);
+ EXPECT_TRUE(wctrans("toupper") != nullptr);
- EXPECT_TRUE(wctrans("monkeys") == 0);
+ EXPECT_TRUE(wctrans("monkeys") == nullptr);
}
TEST(wctype, towctrans_l) {
UtfLocale l;
- EXPECT_TRUE(wctrans_l("tolower", l.l) != 0);
- EXPECT_TRUE(wctrans_l("toupper", l.l) != 0);
+ EXPECT_TRUE(wctrans_l("tolower", l.l) != nullptr);
+ EXPECT_TRUE(wctrans_l("toupper", l.l) != nullptr);
- EXPECT_TRUE(wctrans_l("monkeys", l.l) == 0);
+ EXPECT_TRUE(wctrans_l("monkeys", l.l) == nullptr);
}
TEST(wctype, wctrans) {