Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
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;
}