summaryrefslogtreecommitdiffstats
path: root/libutils
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2018-07-11 17:37:34 -0700
committerYi Kong <yikong@google.com>2018-07-13 15:28:59 -0700
commitc1a156254864f39cdefffaac34dd39dbe2853129 (patch)
tree5d71b353e76f8487e0f69eab1fdb892f62d4dda2 /libutils
parentd73414c5e819ef7a921ac92f1f5c7545d4f87ef1 (diff)
downloadsystem_core-c1a156254864f39cdefffaac34dd39dbe2853129.tar.gz
system_core-c1a156254864f39cdefffaac34dd39dbe2853129.tar.bz2
system_core-c1a156254864f39cdefffaac34dd39dbe2853129.zip
Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning for binder. Test: m Bug: 68236239 Change-Id: I8184bd6aa4ebff1bd8c88dad16886e98df853b03
Diffstat (limited to 'libutils')
-rw-r--r--libutils/include/utils/AndroidThreads.h2
-rw-r--r--libutils/include/utils/CallStack.h6
-rw-r--r--libutils/include/utils/Looper.h4
-rw-r--r--libutils/include/utils/Mutex.h8
-rw-r--r--libutils/include/utils/RWLock.h8
-rw-r--r--libutils/include/utils/RefBase.h6
-rw-r--r--libutils/include/utils/Singleton.h6
-rw-r--r--libutils/include/utils/String8.h2
-rw-r--r--libutils/include/utils/StrongPointer.h4
-rw-r--r--libutils/include/utils/VectorImpl.h2
10 files changed, 24 insertions, 24 deletions
diff --git a/libutils/include/utils/AndroidThreads.h b/libutils/include/utils/AndroidThreads.h
index dab888d5a..a8d785175 100644
--- a/libutils/include/utils/AndroidThreads.h
+++ b/libutils/include/utils/AndroidThreads.h
@@ -106,7 +106,7 @@ inline bool createThreadEtc(thread_func_t entryFunction,
const char* threadName = "android:unnamed_thread",
int32_t threadPriority = PRIORITY_DEFAULT,
size_t threadStackSize = 0,
- thread_id_t *threadId = 0)
+ thread_id_t *threadId = nullptr)
{
return androidCreateThreadEtc(entryFunction, userData, threadName,
threadPriority, threadStackSize, threadId) ? true : false;
diff --git a/libutils/include/utils/CallStack.h b/libutils/include/utils/CallStack.h
index 96221425e..0c1b87522 100644
--- a/libutils/include/utils/CallStack.h
+++ b/libutils/include/utils/CallStack.h
@@ -49,13 +49,13 @@ public:
// Dump a stack trace to the log using the supplied logtag.
void log(const char* logtag,
android_LogPriority priority = ANDROID_LOG_DEBUG,
- const char* prefix = 0) const;
+ const char* prefix = nullptr) const;
// Dump a stack trace to the specified file descriptor.
- void dump(int fd, int indent = 0, const char* prefix = 0) const;
+ void dump(int fd, int indent = 0, const char* prefix = nullptr) const;
// Return a string (possibly very long) containing the complete stack trace.
- String8 toString(const char* prefix = 0) const;
+ String8 toString(const char* prefix = nullptr) const;
// Dump a serialized representation of the stack trace to the specified printer.
void print(Printer& printer) const;
diff --git a/libutils/include/utils/Looper.h b/libutils/include/utils/Looper.h
index a62e67f5f..4509d75ff 100644
--- a/libutils/include/utils/Looper.h
+++ b/libutils/include/utils/Looper.h
@@ -262,7 +262,7 @@ public:
*/
int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData);
inline int pollOnce(int timeoutMillis) {
- return pollOnce(timeoutMillis, NULL, NULL, NULL);
+ return pollOnce(timeoutMillis, nullptr, nullptr, nullptr);
}
/**
@@ -272,7 +272,7 @@ public:
*/
int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData);
inline int pollAll(int timeoutMillis) {
- return pollAll(timeoutMillis, NULL, NULL, NULL);
+ return pollAll(timeoutMillis, nullptr, nullptr, nullptr);
}
/**
diff --git a/libutils/include/utils/Mutex.h b/libutils/include/utils/Mutex.h
index 1228df4cd..29c2e8ce1 100644
--- a/libutils/include/utils/Mutex.h
+++ b/libutils/include/utils/Mutex.h
@@ -100,7 +100,7 @@ class CAPABILITY("mutex") Mutex {
Mutex();
explicit Mutex(const char* name);
- explicit Mutex(int type, const char* name = NULL);
+ explicit Mutex(int type, const char* name = nullptr);
~Mutex();
// lock or unlock the mutex
@@ -160,10 +160,10 @@ class CAPABILITY("mutex") Mutex {
#if !defined(_WIN32)
inline Mutex::Mutex() {
- pthread_mutex_init(&mMutex, NULL);
+ pthread_mutex_init(&mMutex, nullptr);
}
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
- pthread_mutex_init(&mMutex, NULL);
+ pthread_mutex_init(&mMutex, nullptr);
}
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
if (type == SHARED) {
@@ -173,7 +173,7 @@ inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
pthread_mutex_init(&mMutex, &attr);
pthread_mutexattr_destroy(&attr);
} else {
- pthread_mutex_init(&mMutex, NULL);
+ pthread_mutex_init(&mMutex, nullptr);
}
}
inline Mutex::~Mutex() {
diff --git a/libutils/include/utils/RWLock.h b/libutils/include/utils/RWLock.h
index 7d43e69f1..64e370e3e 100644
--- a/libutils/include/utils/RWLock.h
+++ b/libutils/include/utils/RWLock.h
@@ -48,7 +48,7 @@ public:
RWLock();
explicit RWLock(const char* name);
- explicit RWLock(int type, const char* name = NULL);
+ explicit RWLock(int type, const char* name = nullptr);
~RWLock();
status_t readLock();
@@ -82,10 +82,10 @@ private:
};
inline RWLock::RWLock() {
- pthread_rwlock_init(&mRWLock, NULL);
+ pthread_rwlock_init(&mRWLock, nullptr);
}
inline RWLock::RWLock(__attribute__((unused)) const char* name) {
- pthread_rwlock_init(&mRWLock, NULL);
+ pthread_rwlock_init(&mRWLock, nullptr);
}
inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) {
if (type == SHARED) {
@@ -95,7 +95,7 @@ inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) {
pthread_rwlock_init(&mRWLock, &attr);
pthread_rwlockattr_destroy(&attr);
} else {
- pthread_rwlock_init(&mRWLock, NULL);
+ pthread_rwlock_init(&mRWLock, nullptr);
}
}
inline RWLock::~RWLock() {
diff --git a/libutils/include/utils/RefBase.h b/libutils/include/utils/RefBase.h
index e817ee4d6..13b6a2bc9 100644
--- a/libutils/include/utils/RefBase.h
+++ b/libutils/include/utils/RefBase.h
@@ -354,7 +354,7 @@ class wp
public:
typedef typename RefBase::weakref_type weakref_type;
- inline wp() : m_ptr(0) { }
+ inline wp() : m_ptr(nullptr) { }
wp(T* other); // NOLINT(implicit)
wp(const wp<T>& other);
@@ -505,7 +505,7 @@ template<typename T>
wp<T>& wp<T>::operator = (T* other)
{
weakref_type* newRefs =
- other ? other->createWeak(this) : 0;
+ other ? other->createWeak(this) : nullptr;
if (m_ptr) m_refs->decWeak(this);
m_ptr = other;
m_refs = newRefs;
@@ -528,7 +528,7 @@ template<typename T>
wp<T>& wp<T>::operator = (const sp<T>& other)
{
weakref_type* newRefs =
- other != NULL ? other->createWeak(this) : 0;
+ other != nullptr ? other->createWeak(this) : nullptr;
T* otherPtr(other.m_ptr);
if (m_ptr) m_refs->decWeak(this);
m_ptr = otherPtr;
diff --git a/libutils/include/utils/Singleton.h b/libutils/include/utils/Singleton.h
index 2dd5a47e6..44d8ad79c 100644
--- a/libutils/include/utils/Singleton.h
+++ b/libutils/include/utils/Singleton.h
@@ -51,7 +51,7 @@ public:
static TYPE& getInstance() {
Mutex::Autolock _l(sLock);
TYPE* instance = sInstance;
- if (instance == 0) {
+ if (instance == nullptr) {
instance = new TYPE();
sInstance = instance;
}
@@ -60,7 +60,7 @@ public:
static bool hasInstance() {
Mutex::Autolock _l(sLock);
- return sInstance != 0;
+ return sInstance != nullptr;
}
protected:
@@ -90,7 +90,7 @@ private:
#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \
template<> ::android::Mutex \
(::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE); \
- template<> TYPE* ::android::Singleton< TYPE >::sInstance(0); /* NOLINT */ \
+ template<> TYPE* ::android::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \
template class ::android::Singleton< TYPE >;
diff --git a/libutils/include/utils/String8.h b/libutils/include/utils/String8.h
index 94ac32fbb..c8f584e30 100644
--- a/libutils/include/utils/String8.h
+++ b/libutils/include/utils/String8.h
@@ -187,7 +187,7 @@ public:
* "/tmp" --> "tmp" (remain = "")
* "bar.c" --> "bar.c" (remain = "")
*/
- String8 walkPath(String8* outRemains = NULL) const;
+ String8 walkPath(String8* outRemains = nullptr) const;
/*
* Return the filename extension. This is the last '.' and any number
diff --git a/libutils/include/utils/StrongPointer.h b/libutils/include/utils/StrongPointer.h
index 9cd278f1f..360fce509 100644
--- a/libutils/include/utils/StrongPointer.h
+++ b/libutils/include/utils/StrongPointer.h
@@ -52,7 +52,7 @@ inline bool operator _op_ (const wp<U>& o) const { \
template<typename T>
class sp {
public:
- inline sp() : m_ptr(0) { }
+ inline sp() : m_ptr(nullptr) { }
sp(T* other); // NOLINT(implicit)
sp(const sp<T>& other);
@@ -230,7 +230,7 @@ template<typename T>
void sp<T>::clear() {
if (m_ptr) {
m_ptr->decStrong(this);
- m_ptr = 0;
+ m_ptr = nullptr;
}
}
diff --git a/libutils/include/utils/VectorImpl.h b/libutils/include/utils/VectorImpl.h
index 55d5d9818..41b9f3310 100644
--- a/libutils/include/utils/VectorImpl.h
+++ b/libutils/include/utils/VectorImpl.h
@@ -157,7 +157,7 @@ protected:
virtual int do_compare(const void* lhs, const void* rhs) const = 0;
private:
- ssize_t _indexOrderOf(const void* item, size_t* order = 0) const;
+ ssize_t _indexOrderOf(const void* item, size_t* order = nullptr) const;
// these are made private, because they can't be used on a SortedVector
// (they don't have an implementation either)