diff options
author | 2018-07-24 01:14:06 -0700 | |
---|---|---|
committer | 2018-07-24 01:14:06 -0700 | |
commit | 87d465c19c1a9d4d3b997fce7d36a40b3bf1ca4e (patch) | |
tree | d0207965de17eff0dd190fff6bdf6724e6321455 | |
parent | 8b24732c844209477834f3d5674629ad03d700b1 (diff) |
[binder] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: Ibecc3b84c4e8c42cf65a0480ceb7c7bf1077866c
-rw-r--r-- | libs/binder/Value.cpp | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/Binder.h | 6 | ||||
-rw-r--r-- | libs/binder/include/binder/BpBinder.h | 6 | ||||
-rw-r--r-- | libs/binder/include/binder/Debug.h | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/IBinder.h | 6 | ||||
-rw-r--r-- | libs/binder/include/binder/IInterface.h | 6 | ||||
-rw-r--r-- | libs/binder/include/binder/IMemory.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/IPCThreadState.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/IServiceManager.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/MemoryDealer.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/MemoryHeapBase.h | 6 | ||||
-rw-r--r-- | libs/binder/include/binder/Parcel.h | 8 | ||||
-rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 2 |
13 files changed, 28 insertions, 28 deletions
diff --git a/libs/binder/Value.cpp b/libs/binder/Value.cpp index 2b263ed2ee..a28a618939 100644 --- a/libs/binder/Value.cpp +++ b/libs/binder/Value.cpp @@ -229,7 +229,7 @@ int32_t Value::parcelType() const #ifdef LIBBINDER_VALUE_SUPPORTS_TYPE_INFO const std::type_info& Value::type() const { - return mContent != NULL + return mContent != nullptr ? mContent->type() : typeid(void); } @@ -306,7 +306,7 @@ status_t Value::writeToParcel(Parcel* parcel) const #define BEGIN_HANDLE_WRITE() \ do { \ - const void* t_info(mContent?mContent->type_ptr():NULL); \ + const void* t_info(mContent?mContent->type_ptr():nullptr); \ if (false) { } #define HANDLE_WRITE_TYPE(T, TYPEVAL, TYPEMETHOD) \ else if (t_info == internal_type_ptr<T>()) { \ diff --git a/libs/binder/include/binder/Binder.h b/libs/binder/include/binder/Binder.h index 34048816cd..0b60b4e5fd 100644 --- a/libs/binder/include/binder/Binder.h +++ b/libs/binder/include/binder/Binder.h @@ -40,13 +40,13 @@ public: uint32_t flags = 0); virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0); virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL); + wp<DeathRecipient>* outRecipient = nullptr); virtual void attachObject( const void* objectID, void* object, diff --git a/libs/binder/include/binder/BpBinder.h b/libs/binder/include/binder/BpBinder.h index 8bd297bcfb..c4c8ba3e74 100644 --- a/libs/binder/include/binder/BpBinder.h +++ b/libs/binder/include/binder/BpBinder.h @@ -47,12 +47,12 @@ public: uint32_t flags = 0); virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0); virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL); + wp<DeathRecipient>* outRecipient = nullptr); virtual void attachObject( const void* objectID, void* object, diff --git a/libs/binder/include/binder/Debug.h b/libs/binder/include/binder/Debug.h index be0266ccce..58e2b32b3a 100644 --- a/libs/binder/include/binder/Debug.h +++ b/libs/binder/include/binder/Debug.h @@ -31,12 +31,12 @@ const char* stringForIndent(int32_t indentLevel); typedef void (*debugPrintFunc)(void* cookie, const char* txt); void printTypeCode(uint32_t typeCode, - debugPrintFunc func = 0, void* cookie = 0); + debugPrintFunc func = nullptr, void* cookie = nullptr); void printHexData(int32_t indent, const void *buf, size_t length, size_t bytesPerLine=16, int32_t singleLineBytesCutoff=16, size_t alignment=0, bool cArrayStyle=false, - debugPrintFunc func = 0, void* cookie = 0); + debugPrintFunc func = nullptr, void* cookie = nullptr); ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf); diff --git a/libs/binder/include/binder/IBinder.h b/libs/binder/include/binder/IBinder.h index 2e6295787d..318070a2ac 100644 --- a/libs/binder/include/binder/IBinder.h +++ b/libs/binder/include/binder/IBinder.h @@ -132,7 +132,7 @@ public: * directly do with it now that it has passed on.) */ virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0) = 0; /** @@ -143,9 +143,9 @@ public: * added with that cookie will be unlinked. */ virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, + void* cookie = nullptr, uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL) = 0; + wp<DeathRecipient>* outRecipient = nullptr) = 0; virtual bool checkSubclass(const void* subclassID) const; diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h index b61278a6aa..5ec02b1df3 100644 --- a/libs/binder/include/binder/IInterface.h +++ b/libs/binder/include/binder/IInterface.h @@ -96,11 +96,11 @@ public: \ const ::android::sp<::android::IBinder>& obj) \ { \ ::android::sp<I##INTERFACE> intr; \ - if (obj != NULL) { \ + if (obj != nullptr) { \ intr = static_cast<I##INTERFACE*>( \ obj->queryLocalInterface( \ I##INTERFACE::descriptor).get()); \ - if (intr == NULL) { \ + if (intr == nullptr) { \ intr = new Bp##INTERFACE(obj); \ } \ } \ @@ -135,7 +135,7 @@ inline sp<IInterface> BnInterface<INTERFACE>::queryLocalInterface( const String16& _descriptor) { if (_descriptor == INTERFACE::descriptor) return this; - return NULL; + return nullptr; } template<typename INTERFACE> diff --git a/libs/binder/include/binder/IMemory.h b/libs/binder/include/binder/IMemory.h index 15a104fe6a..3099bf5fb8 100644 --- a/libs/binder/include/binder/IMemory.h +++ b/libs/binder/include/binder/IMemory.h @@ -72,7 +72,7 @@ class IMemory : public IInterface public: DECLARE_META_INTERFACE(Memory) - virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0; + virtual sp<IMemoryHeap> getMemory(ssize_t* offset=nullptr, size_t* size=nullptr) const = 0; // helpers void* fastPointer(const sp<IBinder>& heap, ssize_t offset) const; diff --git a/libs/binder/include/binder/IPCThreadState.h b/libs/binder/include/binder/IPCThreadState.h index 245607e74e..ab68b41f12 100644 --- a/libs/binder/include/binder/IPCThreadState.h +++ b/libs/binder/include/binder/IPCThreadState.h @@ -95,7 +95,7 @@ private: status_t sendReply(const Parcel& reply, uint32_t flags); status_t waitForResponse(Parcel *reply, - status_t *acquireResult=NULL); + status_t *acquireResult=nullptr); status_t talkWithDriver(bool doReceive=true); status_t writeTransactionData(int32_t cmd, uint32_t binderFlags, diff --git a/libs/binder/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h index 3b23f81e43..445a0724ea 100644 --- a/libs/binder/include/binder/IServiceManager.h +++ b/libs/binder/include/binder/IServiceManager.h @@ -69,7 +69,7 @@ template<typename INTERFACE> status_t getService(const String16& name, sp<INTERFACE>* outService) { const sp<IServiceManager> sm = defaultServiceManager(); - if (sm != NULL) { + if (sm != nullptr) { *outService = interface_cast<INTERFACE>(sm->getService(name)); if ((*outService) != NULL) return NO_ERROR; } diff --git a/libs/binder/include/binder/MemoryDealer.h b/libs/binder/include/binder/MemoryDealer.h index 60a624c5a1..fe5a31d5a6 100644 --- a/libs/binder/include/binder/MemoryDealer.h +++ b/libs/binder/include/binder/MemoryDealer.h @@ -34,7 +34,7 @@ class SimpleBestFitAllocator; class MemoryDealer : public RefBase { public: - MemoryDealer(size_t size, const char* name = 0, + MemoryDealer(size_t size, const char* name = nullptr, uint32_t flags = 0 /* or bits such as MemoryHeapBase::READ_ONLY */ ); virtual sp<IMemory> allocate(size_t size); diff --git a/libs/binder/include/binder/MemoryHeapBase.h b/libs/binder/include/binder/MemoryHeapBase.h index ea9b66c497..5e0a382a7e 100644 --- a/libs/binder/include/binder/MemoryHeapBase.h +++ b/libs/binder/include/binder/MemoryHeapBase.h @@ -52,7 +52,7 @@ public: /* * maps memory from ashmem, with the given name for debugging */ - MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = NULL); + MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = nullptr); virtual ~MemoryHeapBase(); @@ -74,7 +74,7 @@ public: /* this is only needed as a workaround, use only if you know * what you are doing */ status_t setDevice(const char* device) { - if (mDevice == 0) + if (mDevice == nullptr) mDevice = device; return mDevice ? NO_ERROR : ALREADY_EXISTS; } @@ -83,7 +83,7 @@ protected: MemoryHeapBase(); // init() takes ownership of fd status_t init(int fd, void *base, int size, - int flags = 0, const char* device = NULL); + int flags = 0, const char* device = nullptr); private: status_t mapfd(int fd, size_t size, uint32_t offset = 0); diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h index b9a3ae6cec..14478b5db3 100644 --- a/libs/binder/include/binder/Parcel.h +++ b/libs/binder/include/binder/Parcel.h @@ -91,7 +91,7 @@ public: // IPCThreadState, which as an optimization may optionally be // passed in. bool enforceInterface(const String16& interface, - IPCThreadState* threadState = NULL) const; + IPCThreadState* threadState = nullptr) const; bool checkInterface(IBinder*) const; void freeData(); @@ -552,7 +552,7 @@ public: friend class Parcel; public: inline const void* data() const { return mData; } - inline void* mutableData() { return isMutable() ? mData : NULL; } + inline void* mutableData() { return isMutable() ? mData : nullptr; } }; class WritableBlob : public Blob { @@ -592,7 +592,7 @@ status_t Parcel::write(const LightFlattenable<T>& val) { } if (size) { void* buffer = writeInplace(size); - if (buffer == NULL) + if (buffer == nullptr) return NO_MEMORY; return val.flatten(buffer, size); } @@ -620,7 +620,7 @@ status_t Parcel::read(LightFlattenable<T>& val) const { } if (size) { void const* buffer = readInplace(size); - return buffer == NULL ? NO_MEMORY : + return buffer == nullptr ? NO_MEMORY : val.unflatten(buffer, size); } return NO_ERROR; diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index f23ac52b93..73c2eba1d5 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -1189,7 +1189,7 @@ class BinderLibTestService : public BBinder return ret; } buf = data.readInplace(size); - if (buf == NULL) { + if (buf == nullptr) { return BAD_VALUE; } ret = write(fd.get(), buf, size); |