diff options
author | 2018-06-07 17:52:27 -0700 | |
---|---|---|
committer | 2018-06-07 17:54:21 -0700 | |
commit | fdd8da9e3f79be25b91293e22114c177c3b3fd8d (patch) | |
tree | cbc9fea00e9b67d631bde2bbb70de5b151dfcadc | |
parent | a160f5a70ffba3715c8a92f4f469922d59635356 (diff) |
[binder] Replace NULL/0 with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
clang-tidy -checks=modernize-use-nullptr -p compile_commands.json -fix
...
Test: m
Bug: 68236239
Change-Id: I3181bc5683796423a98b0f9b94daf30880c07bdc
Merged-In: I3181bc5683796423a98b0f9b94daf30880c07bdc
(cherry picked from commit 91635563b8a1bf7a31e4ceb439728dacb79abd76)
-rw-r--r-- | libs/binder/AppOpsManager.cpp | 22 | ||||
-rw-r--r-- | libs/binder/Binder.cpp | 20 | ||||
-rw-r--r-- | libs/binder/BpBinder.cpp | 28 | ||||
-rw-r--r-- | libs/binder/BufferedTextOutput.cpp | 8 | ||||
-rw-r--r-- | libs/binder/Debug.cpp | 6 | ||||
-rw-r--r-- | libs/binder/IAppOpsService.cpp | 2 | ||||
-rw-r--r-- | libs/binder/IInterface.cpp | 4 | ||||
-rw-r--r-- | libs/binder/IMemory.cpp | 22 | ||||
-rw-r--r-- | libs/binder/IPCThreadState.cpp | 20 | ||||
-rw-r--r-- | libs/binder/IResultReceiver.cpp | 4 | ||||
-rw-r--r-- | libs/binder/IServiceManager.cpp | 20 | ||||
-rw-r--r-- | libs/binder/IShellCallback.cpp | 2 | ||||
-rw-r--r-- | libs/binder/MemoryDealer.cpp | 24 | ||||
-rw-r--r-- | libs/binder/MemoryHeapBase.cpp | 16 | ||||
-rw-r--r-- | libs/binder/Parcel.cpp | 108 | ||||
-rw-r--r-- | libs/binder/PermissionCache.cpp | 2 | ||||
-rw-r--r-- | libs/binder/ProcessInfoService.cpp | 6 | ||||
-rw-r--r-- | libs/binder/ProcessState.cpp | 44 | ||||
-rw-r--r-- | libs/binder/Value.cpp | 18 | ||||
-rw-r--r-- | libs/binder/tests/binderDriverInterfaceTest.cpp | 14 | ||||
-rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 100 | ||||
-rw-r--r-- | libs/binder/tests/binderThroughputTest.cpp | 2 | ||||
-rw-r--r-- | libs/binder/tests/schd-dbg.cpp | 2 |
23 files changed, 247 insertions, 247 deletions
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp index f3b86ae311..4a9b9a7608 100644 --- a/libs/binder/AppOpsManager.cpp +++ b/libs/binder/AppOpsManager.cpp @@ -42,7 +42,7 @@ static sp<IBinder> gToken; static const sp<IBinder>& getToken(const sp<IAppOpsService>& service) { pthread_mutex_lock(&gTokenMutex); - if (gToken == NULL || gToken->pingBinder() != NO_ERROR) { + if (gToken == nullptr || gToken->pingBinder() != NO_ERROR) { gToken = service->getToken(new BBinder()); } pthread_mutex_unlock(&gTokenMutex); @@ -63,16 +63,16 @@ sp<IAppOpsService> AppOpsManager::getService() std::lock_guard<Mutex> scoped_lock(mLock); int64_t startTime = 0; sp<IAppOpsService> service = mService; - while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) { + while (service == nullptr || !IInterface::asBinder(service)->isBinderAlive()) { sp<IBinder> binder = defaultServiceManager()->checkService(_appops); - if (binder == NULL) { + if (binder == nullptr) { // Wait for the app ops service to come back... if (startTime == 0) { startTime = uptimeMillis(); ALOGI("Waiting for app ops service"); } else if ((uptimeMillis()-startTime) > 10000) { ALOGW("Waiting too long for app ops service, giving up"); - service = NULL; + service = nullptr; break; } sleep(1); @@ -88,28 +88,28 @@ sp<IAppOpsService> AppOpsManager::getService() int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage) { sp<IAppOpsService> service = getService(); - return service != NULL + return service != nullptr ? service->checkOperation(op, uid, callingPackage) : APP_OPS_MANAGER_UNAVAILABLE_MODE; } int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) { sp<IAppOpsService> service = getService(); - return service != NULL + return service != nullptr ? service->noteOperation(op, uid, callingPackage) : APP_OPS_MANAGER_UNAVAILABLE_MODE; } int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) { sp<IAppOpsService> service = getService(); - return service != NULL + return service != nullptr ? service->startOperation(getToken(service), op, uid, callingPackage) : APP_OPS_MANAGER_UNAVAILABLE_MODE; } void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) { sp<IAppOpsService> service = getService(); - if (service != NULL) { + if (service != nullptr) { service->finishOperation(getToken(service), op, uid, callingPackage); } } @@ -117,21 +117,21 @@ void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPac void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName, const sp<IAppOpsCallback>& callback) { sp<IAppOpsService> service = getService(); - if (service != NULL) { + if (service != nullptr) { service->startWatchingMode(op, packageName, callback); } } void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) { sp<IAppOpsService> service = getService(); - if (service != NULL) { + if (service != nullptr) { service->stopWatchingMode(callback); } } int32_t AppOpsManager::permissionToOpCode(const String16& permission) { sp<IAppOpsService> service = getService(); - if (service != NULL) { + if (service != nullptr) { return service->permissionToOpCode(permission); } return -1; diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index a81f44ef8e..1bd7c4fb42 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -43,17 +43,17 @@ IBinder::~IBinder() sp<IInterface> IBinder::queryLocalInterface(const String16& /*descriptor*/) { - return NULL; + return nullptr; } BBinder* IBinder::localBinder() { - return NULL; + return nullptr; } BpBinder* IBinder::remoteBinder() { - return NULL; + return nullptr; } bool IBinder::checkSubclass(const void* /*subclassID*/) const @@ -76,8 +76,8 @@ status_t IBinder::shellCommand(const sp<IBinder>& target, int in, int out, int e for (size_t i = 0; i < numArgs; i++) { send.writeString16(args[i]); } - send.writeStrongBinder(callback != NULL ? IInterface::asBinder(callback) : NULL); - send.writeStrongBinder(resultReceiver != NULL ? IInterface::asBinder(resultReceiver) : NULL); + send.writeStrongBinder(callback != nullptr ? IInterface::asBinder(callback) : nullptr); + send.writeStrongBinder(resultReceiver != nullptr ? IInterface::asBinder(resultReceiver) : nullptr); return target->transact(SHELL_COMMAND_TRANSACTION, send, &reply); } @@ -130,7 +130,7 @@ status_t BBinder::transact( break; } - if (reply != NULL) { + if (reply != nullptr) { reply->setDataPosition(0); } @@ -171,7 +171,7 @@ void BBinder::attachObject( delete e; e = expected; // Filled in by CAS } - if (e == 0) return; // out of memory + if (e == nullptr) return; // out of memory } AutoMutex _l(e->mLock); @@ -181,7 +181,7 @@ void BBinder::attachObject( void* BBinder::findObject(const void* objectID) const { Extras* e = mExtras.load(std::memory_order_acquire); - if (!e) return NULL; + if (!e) return nullptr; AutoMutex _l(e->mLock); return e->mObjects.find(objectID); @@ -246,7 +246,7 @@ status_t BBinder::onTransact( (void)out; (void)err; - if (resultReceiver != NULL) { + if (resultReceiver != nullptr) { resultReceiver->send(INVALID_OPERATION); } @@ -273,7 +273,7 @@ enum { }; BpRefBase::BpRefBase(const sp<IBinder>& o) - : mRemote(o.get()), mRefs(NULL), mState(0) + : mRemote(o.get()), mRefs(nullptr), mState(0) { extendObjectLifetime(OBJECT_LIFETIME_WEAK); diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index c0e029622a..49ff46033c 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -62,7 +62,7 @@ void BpBinder::ObjectManager::attach( void* BpBinder::ObjectManager::find(const void* objectID) const { const ssize_t i = mObjects.indexOfKey(objectID); - if (i < 0) return NULL; + if (i < 0) return nullptr; return mObjects.valueAt(i).object; } @@ -77,7 +77,7 @@ void BpBinder::ObjectManager::kill() ALOGV("Killing %zu objects in manager %p", N, this); for (size_t i=0; i<N; i++) { const entry_t& e = mObjects.valueAt(i); - if (e.func != NULL) { + if (e.func != nullptr) { e.func(mObjects.keyAt(i), e.object, e.cleanupCookie); } } @@ -91,7 +91,7 @@ BpBinder::BpBinder(int32_t handle) : mHandle(handle) , mAlive(1) , mObitsSent(0) - , mObituaries(NULL) + , mObituaries(nullptr) { ALOGV("Creating BpBinder %p handle %d\n", this, mHandle); @@ -179,7 +179,7 @@ status_t BpBinder::linkToDeath( ob.cookie = cookie; ob.flags = flags; - LOG_ALWAYS_FATAL_IF(recipient == NULL, + LOG_ALWAYS_FATAL_IF(recipient == nullptr, "linkToDeath(): recipient must be non-NULL"); { @@ -219,9 +219,9 @@ status_t BpBinder::unlinkToDeath( for (size_t i=0; i<N; i++) { const Obituary& obit = mObituaries->itemAt(i); if ((obit.recipient == recipient - || (recipient == NULL && obit.cookie == cookie)) + || (recipient == nullptr && obit.cookie == cookie)) && obit.flags == flags) { - if (outRecipient != NULL) { + if (outRecipient != nullptr) { *outRecipient = mObituaries->itemAt(i).recipient; } mObituaries->removeAt(i); @@ -231,7 +231,7 @@ status_t BpBinder::unlinkToDeath( self->clearDeathNotification(mHandle, this); self->flushCommands(); delete mObituaries; - mObituaries = NULL; + mObituaries = nullptr; } return NO_ERROR; } @@ -250,12 +250,12 @@ void BpBinder::sendObituary() mLock.lock(); Vector<Obituary>* obits = mObituaries; - if(obits != NULL) { + if(obits != nullptr) { ALOGV("Clearing sent death notification: %p handle %d\n", this, mHandle); IPCThreadState* self = IPCThreadState::self(); self->clearDeathNotification(mHandle, this); self->flushCommands(); - mObituaries = NULL; + mObituaries = nullptr; } mObitsSent = 1; mLock.unlock(); @@ -263,7 +263,7 @@ void BpBinder::sendObituary() ALOGV("Reporting death of proxy %p for %zu recipients\n", this, obits ? obits->size() : 0U); - if (obits != NULL) { + if (obits != nullptr) { const size_t N = obits->size(); for (size_t i=0; i<N; i++) { reportOneDeath(obits->itemAt(i)); @@ -277,7 +277,7 @@ void BpBinder::reportOneDeath(const Obituary& obit) { sp<DeathRecipient> recipient = obit.recipient.promote(); ALOGV("Reporting death to recipient: %p\n", recipient.get()); - if (recipient == NULL) return; + if (recipient == nullptr) return; recipient->binderDied(this); } @@ -317,13 +317,13 @@ BpBinder::~BpBinder() mLock.lock(); Vector<Obituary>* obits = mObituaries; - if(obits != NULL) { + if(obits != nullptr) { if (ipc) ipc->clearDeathNotification(mHandle, this); - mObituaries = NULL; + mObituaries = nullptr; } mLock.unlock(); - if (obits != NULL) { + if (obits != nullptr) { // XXX Should we tell any remaining DeathRecipient // objects that the last strong ref has gone away, so they // are no longer linked? diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp index 30e70b074e..0946aca876 100644 --- a/libs/binder/BufferedTextOutput.cpp +++ b/libs/binder/BufferedTextOutput.cpp @@ -36,7 +36,7 @@ struct BufferedTextOutput::BufferState : public RefBase { explicit BufferState(int32_t _seq) : seq(_seq) - , buffer(NULL) + , buffer(nullptr) , bufferPos(0) , bufferSize(0) , atFront(true) @@ -266,13 +266,13 @@ BufferedTextOutput::BufferState* BufferedTextOutput::getBuffer() const if ((mFlags&MULTITHREADED) != 0) { ThreadState* ts = getThreadState(); if (ts) { - while (ts->states.size() <= (size_t)mIndex) ts->states.add(NULL); + while (ts->states.size() <= (size_t)mIndex) ts->states.add(nullptr); BufferState* bs = ts->states[mIndex].get(); - if (bs != NULL && bs->seq == mSeq) return bs; + if (bs != nullptr && bs->seq == mSeq) return bs; ts->states.editItemAt(mIndex) = new BufferState(mIndex); bs = ts->states[mIndex].get(); - if (bs != NULL) return bs; + if (bs != nullptr) return bs; } } diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp index 4ac61a3007..f38bbb2f32 100644 --- a/libs/binder/Debug.cpp +++ b/libs/binder/Debug.cpp @@ -165,13 +165,13 @@ void printHexData(int32_t indent, const void *buf, size_t length, else if (bytesPerLine >= 8) alignment = 2; else alignment = 1; } - if (func == NULL) func = defaultPrintFunc; + if (func == nullptr) func = defaultPrintFunc; size_t offset; unsigned char *pos = (unsigned char *)buf; - if (pos == NULL) { + if (pos == nullptr) { if (singleLineBytesCutoff < 0) func(cookie, "\n"); func(cookie, "(NULL)"); return; @@ -297,7 +297,7 @@ void printHexData(int32_t indent, const void *buf, size_t length, ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf) { sp<ProcessState> proc = ProcessState::selfOrNull(); - if (proc.get() == NULL) { + if (proc.get() == nullptr) { return 0; } diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp index 638ae5c8ac..c38568c40f 100644 --- a/libs/binder/IAppOpsService.cpp +++ b/libs/binder/IAppOpsService.cpp @@ -108,7 +108,7 @@ public: data.writeStrongBinder(clientToken); remote()->transact(GET_TOKEN_TRANSACTION, data, &reply); // fail on exception - if (reply.readExceptionCode() != 0) return NULL; + if (reply.readExceptionCode() != 0) return nullptr; return reply.readStrongBinder(); } diff --git a/libs/binder/IInterface.cpp b/libs/binder/IInterface.cpp index 2fcd3d92fb..6b7729186e 100644 --- a/libs/binder/IInterface.cpp +++ b/libs/binder/IInterface.cpp @@ -32,14 +32,14 @@ IInterface::~IInterface() { // static sp<IBinder> IInterface::asBinder(const IInterface* iface) { - if (iface == NULL) return NULL; + if (iface == nullptr) return nullptr; return const_cast<IInterface*>(iface)->onAsBinder(); } // static sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface) { - if (iface == NULL) return NULL; + if (iface == nullptr) return nullptr; return iface->onAsBinder(); } diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp index 5c1a4f41e0..7afec454a2 100644 --- a/libs/binder/IMemory.cpp +++ b/libs/binder/IMemory.cpp @@ -130,7 +130,7 @@ class BpMemory : public BpInterface<IMemory> public: explicit BpMemory(const sp<IBinder>& impl); virtual ~BpMemory(); - virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const; + virtual sp<IMemoryHeap> getMemory(ssize_t* offset=nullptr, size_t* size=nullptr) const; private: mutable sp<IMemoryHeap> mHeap; @@ -145,22 +145,22 @@ void* IMemory::fastPointer(const sp<IBinder>& binder, ssize_t offset) const sp<IMemoryHeap> realHeap = BpMemoryHeap::get_heap(binder); void* const base = realHeap->base(); if (base == MAP_FAILED) - return 0; + return nullptr; return static_cast<char*>(base) + offset; } void* IMemory::pointer() const { ssize_t offset; sp<IMemoryHeap> heap = getMemory(&offset); - void* const base = heap!=0 ? heap->base() : MAP_FAILED; + void* const base = heap!=nullptr ? heap->base() : MAP_FAILED; if (base == MAP_FAILED) - return 0; + return nullptr; return static_cast<char*>(base) + offset; } size_t IMemory::size() const { size_t size; - getMemory(NULL, &size); + getMemory(nullptr, &size); return size; } @@ -183,16 +183,16 @@ BpMemory::~BpMemory() sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const { - if (mHeap == 0) { + if (mHeap == nullptr) { Parcel data, reply; data.writeInterfaceToken(IMemory::getInterfaceDescriptor()); if (remote()->transact(GET_MEMORY, data, &reply) == NO_ERROR) { sp<IBinder> heap = reply.readStrongBinder(); ssize_t o = reply.readInt32(); size_t s = reply.readInt32(); - if (heap != 0) { + if (heap != nullptr) { mHeap = interface_cast<IMemoryHeap>(heap); - if (mHeap != 0) { + if (mHeap != nullptr) { size_t heapSize = mHeap->getSize(); if (s <= heapSize && o >= 0 @@ -202,7 +202,7 @@ sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const } else { // Hm. android_errorWriteWithInfoLog(0x534e4554, - "26877992", -1, NULL, 0); + "26877992", -1, nullptr, 0); mOffset = 0; mSize = 0; } @@ -212,7 +212,7 @@ sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const } if (offset) *offset = mOffset; if (size) *size = mSize; - return (mSize > 0) ? mHeap : 0; + return (mSize > 0) ? mHeap : nullptr; } // --------------------------------------------------------------------------- @@ -334,7 +334,7 @@ void BpMemoryHeap::assertReallyMapped() const access |= PROT_WRITE; } mRealHeap = true; - mBase = mmap(0, size, access, MAP_SHARED, fd, offset); + mBase = mmap(nullptr, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", IInterface::asBinder(this).get(), size, fd, strerror(errno)); diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index ba9bf61f8c..33ec65f10e 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -289,7 +289,7 @@ restart: if (gShutdown) { ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n"); - return NULL; + return nullptr; } pthread_mutex_lock(&gTLSMutex); @@ -299,7 +299,7 @@ restart: pthread_mutex_unlock(&gTLSMutex); ALOGW("IPCThreadState::self() unable to create TLS key, expect a crash: %s\n", strerror(key_create_value)); - return NULL; + return nullptr; } gHaveTLS = true; } @@ -314,7 +314,7 @@ IPCThreadState* IPCThreadState::selfOrNull() IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k); return st; } - return NULL; + return nullptr; } void IPCThreadState::shutdown() @@ -326,7 +326,7 @@ void IPCThreadState::shutdown() IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); if (st) { delete st; - pthread_setspecific(gTLS, NULL); + pthread_setspecific(gTLS, nullptr); } pthread_key_delete(gTLS); gHaveTLS = false; @@ -584,7 +584,7 @@ status_t IPCThreadState::transact(int32_t handle, LOG_ONEWAY(">>>> SEND from pid %d uid %d %s", getpid(), getuid(), (flags & TF_ONE_WAY) == 0 ? "READ REPLY" : "ONE WAY"); - err = writeTransactionData(BC_TRANSACTION, flags, handle, code, data, NULL); + err = writeTransactionData(BC_TRANSACTION, flags, handle, code, data, nullptr); if (err != NO_ERROR) { if (reply) reply->setError(err); @@ -621,7 +621,7 @@ status_t IPCThreadState::transact(int32_t handle, else alog << "(none requested)" << endl; } } else { - err = waitForResponse(NULL, NULL); + err = waitForResponse(nullptr, nullptr); } return err; @@ -725,7 +725,7 @@ status_t IPCThreadState::sendReply(const Parcel& reply, uint32_t flags) err = writeTransactionData(BC_REPLY, flags, -1, 0, reply, &statusBuffer); if (err < NO_ERROR) return err; - return waitForResponse(NULL, NULL); + return waitForResponse(nullptr, nullptr); } status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) @@ -785,14 +785,14 @@ status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) freeBuffer, this); } else { err = *reinterpret_cast<const status_t*>(tr.data.ptr.buffer); - freeBuffer(NULL, + freeBuffer(nullptr, reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer), tr.data_size, reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets), tr.offsets_size/sizeof(binder_size_t), this); } } else { - freeBuffer(NULL, + freeBuffer(nullptr, reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer), tr.data_size, reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets), @@ -1185,7 +1185,7 @@ void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data, alog << "Writing BC_FREE_BUFFER for " << data << endl; } ALOG_ASSERT(data != NULL, "Called with NULL data"); - if (parcel != NULL) parcel->closeFileDescriptors(); + if (parcel != nullptr) parcel->closeFileDescriptors(); IPCThreadState* state = self(); state->mOut.writeInt32(BC_FREE_BUFFER); state->mOut.writePointer((uintptr_t)data); diff --git a/libs/binder/IResultReceiver.cpp b/libs/binder/IResultReceiver.cpp index 646809e089..14b5259536 100644 --- a/libs/binder/IResultReceiver.cpp +++ b/libs/binder/IResultReceiver.cpp @@ -40,7 +40,7 @@ public: Parcel data; data.writeInterfaceToken(IResultReceiver::getInterfaceDescriptor()); data.writeInt32(resultCode); - remote()->transact(OP_SEND, data, NULL, IBinder::FLAG_ONEWAY); + remote()->transact(OP_SEND, data, nullptr, IBinder::FLAG_ONEWAY); } }; @@ -56,7 +56,7 @@ status_t BnResultReceiver::onTransact( CHECK_INTERFACE(IResultReceiver, data, reply); int32_t resultCode = data.readInt32(); send(resultCode); - if (reply != NULL) { + if (reply != nullptr) { reply->writeNoException(); } return NO_ERROR; diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index c7a0f43a9d..001dc9e6cd 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -33,14 +33,14 @@ namespace android { sp<IServiceManager> defaultServiceManager() { - if (gDefaultServiceManager != NULL) return gDefaultServiceManager; + if (gDefaultServiceManager != nullptr) return gDefaultServiceManager; { AutoMutex _l(gDefaultServiceManagerLock); - while (gDefaultServiceManager == NULL) { + while (gDefaultServiceManager == nullptr) { gDefaultServiceManager = interface_cast<IServiceManager>( - ProcessState::self()->getContextObject(NULL)); - if (gDefaultServiceManager == NULL) + ProcessState::self()->getContextObject(nullptr)); + if (gDefaultServiceManager == nullptr) sleep(1); } } @@ -50,7 +50,7 @@ sp<IServiceManager> defaultServiceManager() bool checkCallingPermission(const String16& permission) { - return checkCallingPermission(permission, NULL, NULL); + return checkCallingPermission(permission, nullptr, nullptr); } static String16 _permission("permission"); @@ -76,7 +76,7 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid) int64_t startTime = 0; while (true) { - if (pc != NULL) { + if (pc != nullptr) { bool res = pc->checkPermission(permission, pid, uid); if (res) { if (startTime != 0) { @@ -97,14 +97,14 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid) // Object is dead! gDefaultServiceManagerLock.lock(); if (gPermissionController == pc) { - gPermissionController = NULL; + gPermissionController = nullptr; } gDefaultServiceManagerLock.unlock(); } // Need to retrieve the permission controller. sp<IBinder> binder = defaultServiceManager()->checkService(_permission); - if (binder == NULL) { + if (binder == nullptr) { // Wait for the permission controller to come back... if (startTime == 0) { startTime = uptimeMillis(); @@ -146,9 +146,9 @@ public: sleep(1); } sp<IBinder> svc = checkService(name); - if (svc != NULL) return svc; + if (svc != nullptr) return svc; } - return NULL; + return nullptr; } virtual sp<IBinder> checkService( const String16& name) const diff --git a/libs/binder/IShellCallback.cpp b/libs/binder/IShellCallback.cpp index c793df3266..4568a426cd 100644 --- a/libs/binder/IShellCallback.cpp +++ b/libs/binder/IShellCallback.cpp @@ -65,7 +65,7 @@ status_t BnShellCallback::onTransact( String16 path(data.readString16()); String16 seLinuxContext(data.readString16()); int fd = openOutputFile(path, seLinuxContext); - if (reply != NULL) { + if (reply != nullptr) { reply->writeNoException(); if (fd >= 0) { reply->writeInt32(1); diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp index 1cfe02a3fe..eacad3b6b3 100644 --- a/libs/binder/MemoryDealer.cpp +++ b/libs/binder/MemoryDealer.cpp @@ -52,8 +52,8 @@ class LinkedList NODE* mLast; public: - LinkedList() : mFirst(0), mLast(0) { } - bool isEmpty() const { return mFirst == 0; } + LinkedList() : mFirst(nullptr), mLast(nullptr) { } + bool isEmpty() const { return mFirst == nullptr; } NODE const* head() const { return mFirst; } NODE* head() { return mFirst; } NODE const* tail() const { return mLast; } @@ -62,7 +62,7 @@ public: void insertAfter(NODE* node, NODE* newNode) { newNode->prev = node; newNode->next = node->next; - if (node->next == 0) mLast = newNode; + if (node->next == nullptr) mLast = newNode; else node->next->prev = newNode; node->next = newNode; } @@ -70,17 +70,17 @@ public: void insertBefore(NODE* node, NODE* newNode) { newNode->prev = node->prev; newNode->next = node; - if (node->prev == 0) mFirst = newNode; + if (node->prev == nullptr) mFirst = newNode; else node->prev->next = newNode; node->prev = newNode; } void insertHead(NODE* newNode) { - if (mFirst == 0) { + if (mFirst == nullptr) { mFirst = mLast = newNode; - newNode->prev = newNode->next = 0; + newNode->prev = newNode->next = nullptr; } else { - newNode->prev = 0; + newNode->prev = nullptr; newNode->next = mFirst; mFirst->prev = newNode; mFirst = newNode; @@ -99,9 +99,9 @@ public: } NODE* remove(NODE* node) { - if (node->prev == 0) mFirst = node->next; + if (node->prev == nullptr) mFirst = node->next; else node->prev->next = node->next; - if (node->next == 0) mLast = node->prev; + if (node->next == nullptr) mLast = node->prev; else node->next->prev = node->prev; return node; } @@ -141,7 +141,7 @@ private: struct chunk_t { chunk_t(size_t start, size_t size) - : start(start), size(size), free(1), prev(0), next(0) { + : start(start), size(size), free(1), prev(nullptr), next(nullptr) { } size_t start; size_t size : 28; @@ -329,7 +329,7 @@ ssize_t SimpleBestFitAllocator::alloc(size_t size, uint32_t flags) return 0; } size = (size + kMemoryAlign-1) / kMemoryAlign; - chunk_t* free_chunk = 0; + chunk_t* free_chunk = nullptr; chunk_t* cur = mList.head(); size_t pagesize = getpagesize(); @@ -418,7 +418,7 @@ SimpleBestFitAllocator::chunk_t* SimpleBestFitAllocator::dealloc(size_t start) } cur = cur->next; } - return 0; + return nullptr; } void SimpleBestFitAllocator::dump(const char* what) const diff --git a/libs/binder/MemoryHeapBase.cpp b/libs/binder/MemoryHeapBase.cpp index 03f00be6a2..9850ad9624 100644 --- a/libs/binder/MemoryHeapBase.cpp +++ b/libs/binder/MemoryHeapBase.cpp @@ -36,17 +36,17 @@ namespace android { MemoryHeapBase::MemoryHeapBase() : mFD(-1), mSize(0), mBase(MAP_FAILED), - mDevice(NULL), mNeedUnmap(false), mOffset(0) + mDevice(nullptr), mNeedUnmap(false), mOffset(0) { } MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), - mDevice(0), mNeedUnmap(false), mOffset(0) + mDevice(nullptr), mNeedUnmap(false), mOffset(0) { const size_t pagesize = getpagesize(); size = ((size + pagesize-1) & ~(pagesize-1)); - int fd = ashmem_create_region(name == NULL ? "MemoryHeapBase" : name, size); + int fd = ashmem_create_region(name == nullptr ? "MemoryHeapBase" : name, size); ALOGE_IF(fd<0, "error creating ashmem region: %s", strerror(errno)); if (fd >= 0) { if (mapfd(fd, size) == NO_ERROR) { @@ -59,7 +59,7 @@ MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name) MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), - mDevice(0), mNeedUnmap(false), mOffset(0) + mDevice(nullptr), mNeedUnmap(false), mOffset(0) { int open_flags = O_RDWR; if (flags & NO_CACHING) @@ -78,7 +78,7 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), - mDevice(0), mNeedUnmap(false), mOffset(0) + mDevice(nullptr), mNeedUnmap(false), mOffset(0) { const size_t pagesize = getpagesize(); size = ((size + pagesize-1) & ~(pagesize-1)); @@ -109,7 +109,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) } if ((mFlags & DONT_MAP_LOCALLY) == 0) { - void* base = (uint8_t*)mmap(0, size, + void* base = (uint8_t*)mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); if (base == MAP_FAILED) { ALOGE("mmap(fd=%d, size=%u) failed (%s)", @@ -121,7 +121,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) mBase = base; mNeedUnmap = true; } else { - mBase = 0; // not MAP_FAILED + mBase = nullptr; // not MAP_FAILED mNeedUnmap = false; } mFD = fd; @@ -143,7 +143,7 @@ void MemoryHeapBase::dispose() //ALOGD("munmap(fd=%d, base=%p, size=%lu)", fd, mBase, mSize); munmap(mBase, mSize); } - mBase = 0; + mBase = nullptr; mSize = 0; close(fd); } diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index f739f07024..03aef1791c 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -117,7 +117,7 @@ void acquire_object(const sp<ProcessState>& proc, return; case BINDER_TYPE_HANDLE: { const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle); - if (b != NULL) { + if (b != nullptr) { LOG_REFS("Parcel %p acquiring reference on remote %p", who, b.get()); b->incStrong(who); } @@ -125,11 +125,11 @@ void acquire_object(const sp<ProcessState>& proc, } case BINDER_TYPE_WEAK_HANDLE: { const wp<IBinder> b = proc->getWeakProxyForHandle(obj.handle); - if (b != NULL) b.get_refs()->incWeak(who); + if (b != nullptr) b.get_refs()->incWeak(who); return; } case BINDER_TYPE_FD: { - if ((obj.cookie != 0) && (outAshmemSize != NULL) && ashmem_valid(obj.handle)) { + if ((obj.cookie != 0) && (outAshmemSize != nullptr) && ashmem_valid(obj.handle)) { // If we own an ashmem fd, keep track of how much memory it refers to. int size = ashmem_get_size_region(obj.handle); if (size > 0) { @@ -146,7 +146,7 @@ void acquire_object(const sp<ProcessState>& proc, void acquire_object(const sp<ProcessState>& proc, const flat_binder_object& obj, const void* who) { - acquire_object(proc, obj, who, NULL); + acquire_object(proc, obj, who, nullptr); } static void release_object(const sp<ProcessState>& proc, @@ -165,7 +165,7 @@ static void release_object(const sp<ProcessState>& proc, return; case BINDER_TYPE_HANDLE: { const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle); - if (b != NULL) { + if (b != nullptr) { LOG_REFS("Parcel %p releasing reference on remote %p", who, b.get()); b->decStrong(who); } @@ -173,12 +173,12 @@ static void release_object(const sp<ProcessState>& proc, } case BINDER_TYPE_WEAK_HANDLE: { const wp<IBinder> b = proc->getWeakProxyForHandle(obj.handle); - if (b != NULL) b.get_refs()->decWeak(who); + if (b != nullptr) b.get_refs()->decWeak(who); return; } case BINDER_TYPE_FD: { if (obj.cookie != 0) { // owned - if ((outAshmemSize != NULL) && ashmem_valid(obj.handle)) { + if ((outAshmemSize != nullptr) && ashmem_valid(obj.handle)) { int size = ashmem_get_size_region(obj.handle); if (size > 0) { *outAshmemSize -= size; @@ -197,7 +197,7 @@ static void release_object(const sp<ProcessState>& proc, void release_object(const sp<ProcessState>& proc, const flat_binder_object& obj, const void* who) { - release_object(proc, obj, who, NULL); + release_object(proc, obj, who, nullptr); } inline static status_t finish_flatten_binder( @@ -219,11 +219,11 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/, obj.flags = 0x13 | FLAT_BINDER_FLAG_ACCEPTS_FDS; } - if (binder != NULL) { + if (binder != nullptr) { IBinder *local = binder->localBinder(); if (!local) { BpBinder *proxy = binder->remoteBinder(); - if (proxy == NULL) { + if (proxy == nullptr) { ALOGE("null proxy"); } const int32_t handle = proxy ? proxy->handle() : 0; @@ -251,13 +251,13 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/, flat_binder_object obj; obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS; - if (binder != NULL) { + if (binder != nullptr) { sp<IBinder> real = binder.promote(); - if (real != NULL) { + if (real != nullptr) { IBinder *local = real->localBinder(); if (!local) { BpBinder *proxy = real->remoteBinder(); - if (proxy == NULL) { + if (proxy == nullptr) { ALOGE("null proxy"); } const int32_t handle = proxy ? proxy->handle() : 0; @@ -284,13 +284,13 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/, obj.hdr.type = BINDER_TYPE_BINDER; obj.binder = 0; obj.cookie = 0; - return finish_flatten_binder(NULL, obj, out); + return finish_flatten_binder(nullptr, obj, out); } else { obj.hdr.type = BINDER_TYPE_BINDER; obj.binder = 0; obj.cookie = 0; - return finish_flatten_binder(NULL, obj, out); + return finish_flatten_binder(nullptr, obj, out); } } @@ -310,7 +310,7 @@ status_t unflatten_binder(const sp<ProcessState>& proc, switch (flat->hdr.type) { case BINDER_TYPE_BINDER: *out = reinterpret_cast<IBinder*>(flat->cookie); - return finish_unflatten_binder(NULL, *flat, in); + return finish_unflatten_binder(nullptr, *flat, in); case BINDER_TYPE_HANDLE: *out = proc->getStrongProxyForHandle(flat->handle); return finish_unflatten_binder( @@ -329,16 +329,16 @@ status_t unflatten_binder(const sp<ProcessState>& proc, switch (flat->hdr.type) { case BINDER_TYPE_BINDER: *out = reinterpret_cast<IBinder*>(flat->cookie); - return finish_unflatten_binder(NULL, *flat, in); + return finish_unflatten_binder(nullptr, *flat, in); case BINDER_TYPE_WEAK_BINDER: if (flat->binder != 0) { out->set_object_and_refs( reinterpret_cast<IBinder*>(flat->cookie), reinterpret_cast<RefBase::weakref_type*>(flat->binder)); } else { - *out = NULL; + *out = nullptr; } - return finish_unflatten_binder(NULL, *flat, in); + return finish_unflatten_binder(nullptr, *flat, in); case BINDER_TYPE_HANDLE: case BINDER_TYPE_WEAK_HANDLE: *out = proc->getWeakProxyForHandle(flat->handle); @@ -525,7 +525,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len) if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow binder_size_t *objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t)); - if (objects == (binder_size_t*)0) { + if (objects == (binder_size_t*)nullptr) { return NO_MEMORY; } mObjects = objects; @@ -613,7 +613,7 @@ bool Parcel::enforceInterface(const String16& interface, IPCThreadState* threadState) const { int32_t strictPolicy = readInt32(); - if (threadState == NULL) { + if (threadState == nullptr) { threadState = IPCThreadState::self(); } if ((threadState->getLastTransactionBinderFlags() & @@ -721,14 +721,14 @@ void* Parcel::writeInplace(size_t len) if (len > INT32_MAX) { // don't accept size_t values which may have come from an // inadvertent conversion from a negative int. - return NULL; + return nullptr; } const size_t padded = pad_size(len); // sanity check for integer overflow if (mDataPos+padded < mDataPos) { - return NULL; + return nullptr; } if ((mDataPos+padded) <= mDataCapacity) { @@ -759,7 +759,7 @@ restart_write: status_t err = growData(padded); if (err == NO_ERROR) goto restart_write; - return NULL; + return nullptr; } status_t Parcel::writeUtf8AsUtf16(const std::string& str) { @@ -1062,7 +1062,7 @@ status_t Parcel::writeString16(const String16& str) status_t Parcel::writeString16(const char16_t* str, size_t len) { - if (str == NULL) return writeInt32(-1); + if (str == nullptr) return writeInt32(-1); status_t err = writeInt32(len); if (err == NO_ERROR) { @@ -1220,7 +1220,7 @@ status_t Parcel::writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob) if (result < 0) { status = result; } else { - void* ptr = ::mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + void* ptr = ::mmap(nullptr, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { status = -errno; } else { @@ -1277,10 +1277,10 @@ status_t Parcel::write(const FlattenableHelperInterface& val) // payload void* const buf = this->writeInplace(pad_size(len)); - if (buf == NULL) + if (buf == nullptr) return BAD_VALUE; - int* fds = NULL; + int* fds = nullptr; if (fd_count) { fds = new (std::nothrow) int[fd_count]; if (fds == nullptr) { @@ -1336,7 +1336,7 @@ restart_write: size_t newSize = ((mObjectsSize+2)*3)/2; if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t)); - if (objects == NULL) return NO_MEMORY; + if (objects == nullptr) return NO_MEMORY; mObjects = objects; mObjectsCapacity = newSize; } @@ -1382,7 +1382,7 @@ status_t Parcel::writeMap(const ::android::binder::Map& map_in) status_t Parcel::writeNullableMap(const std::unique_ptr<binder::Map>& map) { - if (map == NULL) { + if (map == nullptr) { return writeInt32(-1); } @@ -1492,7 +1492,7 @@ const void* Parcel::readInplace(size_t len) const if (len > INT32_MAX) { // don't accept size_t values which may have come from an // inadvertent conversion from a negative int. - return NULL; + return nullptr; } if ((mDataPos+pad_size(len)) >= mDataPos && (mDataPos+pad_size(len)) <= mDataSize @@ -1502,7 +1502,7 @@ const void* Parcel::readInplace(size_t len) const ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos); return data; } - return NULL; + return nullptr; } template<class T> @@ -1943,7 +1943,7 @@ const char* Parcel::readCString() const return str; } } - return NULL; + return nullptr; } String8 Parcel::readString8() const @@ -1974,7 +1974,7 @@ status_t Parcel::readString8(String8* pArg) const return OK; } const char* str = (const char*)readInplace(size + 1); - if (str == NULL) { + if (str == nullptr) { return BAD_VALUE; } pArg->setTo(str, size); @@ -2033,12 +2033,12 @@ const char16_t* Parcel::readString16Inplace(size_t* outLen) const if (size >= 0 && size < INT32_MAX) { *outLen = size; const char16_t* str = (const char16_t*)readInplace((size+1)*sizeof(char16_t)); - if (str != NULL) { + if (str != nullptr) { return str; } } *outLen = 0; - return NULL; + return nullptr; } status_t Parcel::readStrongBinder(sp<IBinder>* val) const @@ -2100,13 +2100,13 @@ native_handle* Parcel::readNativeHandle() const int numFds, numInts; status_t err; err = readInt32(&numFds); - if (err != NO_ERROR) return 0; + if (err != NO_ERROR) return nullptr; err = readInt32(&numInts); - if (err != NO_ERROR) return 0; + if (err != NO_ERROR) return nullptr; native_handle* h = native_handle_create(numFds, numInts); if (!h) { - return 0; + return nullptr; } for (int i=0 ; err==NO_ERROR && i<numFds ; i++) { @@ -2116,14 +2116,14 @@ native_handle* Parcel::readNativeHandle() const close(h->data[j]); } native_handle_delete(h); - return 0; + return nullptr; } } err = read(h->data + numFds, sizeof(int)*numInts); if (err != NO_ERROR) { native_handle_close(h); native_handle_delete(h); - h = 0; + h = nullptr; } return h; } @@ -2196,7 +2196,7 @@ status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const int fd = readFileDescriptor(); if (fd == int(BAD_TYPE)) return BAD_VALUE; - void* ptr = ::mmap(NULL, len, isMutable ? PROT_READ | PROT_WRITE : PROT_READ, + void* ptr = ::mmap(nullptr, len, isMutable ? PROT_READ | PROT_WRITE : PROT_READ, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) return NO_MEMORY; @@ -2218,10 +2218,10 @@ status_t Parcel::read(FlattenableHelperInterface& val) const // payload void const* const buf = this->readInplace(pad_size(len)); - if (buf == NULL) + if (buf == nullptr) return BAD_VALUE; - int* fds = NULL; + int* fds = nullptr; if (fd_count) { fds = new (std::nothrow) int[fd_count]; if (fds == nullptr) { @@ -2312,7 +2312,7 @@ const flat_binder_object* Parcel::readObject(bool nullMetaData) const ALOGW("Attempt to read object from Parcel %p at offset %zu that is not in the object list", this, DPOS); } - return NULL; + return nullptr; } void Parcel::closeFileDescriptors() @@ -2521,7 +2521,7 @@ status_t Parcel::restartWrite(size_t desired) ALOGV("restartWrite Setting data pos of %p to %zu", this, mDataPos); free(mObjects); - mObjects = NULL; + mObjects = nullptr; mObjectsSize = mObjectsCapacity = 0; mNextObjectHint = 0; mHasFds = false; @@ -2568,7 +2568,7 @@ status_t Parcel::continueWrite(size_t desired) mError = NO_MEMORY; return NO_MEMORY; } - binder_size_t* objects = NULL; + binder_size_t* objects = nullptr; if (objectsSize) { objects = (binder_size_t*)calloc(objectsSize, sizeof(binder_size_t)); @@ -2595,7 +2595,7 @@ status_t Parcel::continueWrite(size_t desired) } //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid()); mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie); - mOwner = NULL; + mOwner = nullptr; LOG_ALLOC("Parcel %p: taking ownership of %zu capacity", this, desired); pthread_mutex_lock(&gParcelGlobalAllocSizeLock); @@ -2668,7 +2668,7 @@ status_t Parcel::continueWrite(size_t desired) return NO_MEMORY; } - if(!(mDataCapacity == 0 && mObjects == NULL + if(!(mDataCapacity == 0 && mObjects == nullptr && mObjectsCapacity == 0)) { ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired); } @@ -2693,20 +2693,20 @@ void Parcel::initState() { LOG_ALLOC("Parcel %p: initState", this); mError = NO_ERROR; - mData = 0; + mData = nullptr; mDataSize = 0; mDataCapacity = 0; mDataPos = 0; ALOGV("initState Setting data size of %p to %zu", this, mDataSize); ALOGV("initState Setting data pos of %p to %zu", this, mDataPos); - mObjects = NULL; + mObjects = nullptr; mObjectsSize = 0; mObjectsCapacity = 0; mNextObjectHint = 0; mHasFds = false; mFdsKnown = true; mAllowFds = true; - mOwner = NULL; + mOwner = nullptr; mOpenAshmemSize = 0; // racing multiple init leads only to multiple identical write @@ -2753,7 +2753,7 @@ size_t Parcel::getOpenAshmemSize() const // --- Parcel::Blob --- Parcel::Blob::Blob() : - mFd(-1), mData(NULL), mSize(0), mMutable(false) { + mFd(-1), mData(nullptr), mSize(0), mMutable(false) { } Parcel::Blob::~Blob() { @@ -2776,7 +2776,7 @@ void Parcel::Blob::init(int fd, void* data, size_t size, bool isMutable) { void Parcel::Blob::clear() { mFd = -1; - mData = NULL; + mData = nullptr; mSize = 0; mMutable = false; } diff --git a/libs/binder/PermissionCache.cpp b/libs/binder/PermissionCache.cpp index a503be8cd7..a4c28ad74e 100644 --- a/libs/binder/PermissionCache.cpp +++ b/libs/binder/PermissionCache.cpp @@ -75,7 +75,7 @@ void PermissionCache::purge() { } bool PermissionCache::checkCallingPermission(const String16& permission) { - return PermissionCache::checkCallingPermission(permission, NULL, NULL); + return PermissionCache::checkCallingPermission(permission, nullptr, nullptr); } bool PermissionCache::checkCallingPermission( diff --git a/libs/binder/ProcessInfoService.cpp b/libs/binder/ProcessInfoService.cpp index 8939d9c9b2..5cb2033b07 100644 --- a/libs/binder/ProcessInfoService.cpp +++ b/libs/binder/ProcessInfoService.cpp @@ -36,7 +36,7 @@ status_t ProcessInfoService::getProcessStatesImpl(size_t length, /*in*/ int32_t* for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) { - if (pis != NULL) { + if (pis != nullptr) { err = pis->getProcessStatesFromPids(length, /*in*/ pids, /*out*/ states); if (err == NO_ERROR) return NO_ERROR; // success if (IInterface::asBinder(pis)->isBinderAlive()) return err; @@ -68,7 +68,7 @@ status_t ProcessInfoService::getProcessStatesScoresImpl(size_t length, for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) { - if (pis != NULL) { + if (pis != nullptr) { err = pis->getProcessStatesAndOomScoresFromPids(length, /*in*/ pids, /*out*/ states, /*out*/ scores); if (err == NO_ERROR) return NO_ERROR; // success @@ -93,7 +93,7 @@ status_t ProcessInfoService::getProcessStatesScoresImpl(size_t length, void ProcessInfoService::updateBinderLocked() { const sp<IServiceManager> sm(defaultServiceManager()); - if (sm != NULL) { + if (sm != nullptr) { const String16 name("processinfo"); mProcessInfoService = interface_cast<IProcessInfoService>(sm->checkService(name)); } diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 860612983f..6e7c427b12 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -68,7 +68,7 @@ protected: sp<ProcessState> ProcessState::self() { Mutex::Autolock _l(gProcessMutex); - if (gProcess != NULL) { + if (gProcess != nullptr) { return gProcess; } gProcess = new ProcessState("/dev/binder"); @@ -78,7 +78,7 @@ sp<ProcessState> ProcessState::self() sp<ProcessState> ProcessState::initWithDriver(const char* driver) { Mutex::Autolock _l(gProcessMutex); - if (gProcess != NULL) { + if (gProcess != nullptr) { // Allow for initWithDriver to be called repeatedly with the same // driver. if (!strcmp(gProcess->getDriverName().c_str(), driver)) { @@ -122,18 +122,18 @@ sp<IBinder> ProcessState::getContextObject(const String16& name, const sp<IBinde { mLock.lock(); sp<IBinder> object( - mContexts.indexOfKey(name) >= 0 ? mContexts.valueFor(name) : NULL); + mContexts.indexOfKey(name) >= 0 ? mContexts.valueFor(name) : nullptr); mLock.unlock(); //printf("Getting context object %s for %p\n", String8(name).string(), caller.get()); - if (object != NULL) return object; + if (object != nullptr) return object; // Don't attempt to retrieve contexts if we manage them if (mManagesContexts) { ALOGE("getContextObject(%s) failed, but we manage the contexts!\n", String8(name).string()); - return NULL; + return nullptr; } IPCThreadState* ipc = IPCThreadState::self(); @@ -150,7 +150,7 @@ sp<IBinder> ProcessState::getContextObject(const String16& name, const sp<IBinde ipc->flushCommands(); - if (object != NULL) setContextObject(object, name); + if (object != nullptr) setContextObject(object, name); return object; } @@ -180,8 +180,8 @@ bool ProcessState::becomeContextManager(context_check_func checkFunc, void* user if (result == 0) { mManagesContexts = true; } else if (result == -1) { - mBinderContextCheckFunc = NULL; - mBinderContextUserData = NULL; + mBinderContextCheckFunc = nullptr; + mBinderContextUserData = nullptr; ALOGE("Binder ioctl to become context manager failed: %s\n", strerror(errno)); } } @@ -207,7 +207,7 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf) binder_node_debug_info info = {}; - uintptr_t* end = buf ? buf + buf_count : NULL; + uintptr_t* end = buf ? buf + buf_count : nullptr; size_t count = 0; do { @@ -233,10 +233,10 @@ ProcessState::handle_entry* ProcessState::lookupHandleLocked(int32_t handle) const size_t N=mHandleToObject.size(); if (N <= (size_t)handle) { handle_entry e; - e.binder = NULL; - e.refs = NULL; + e.binder = nullptr; + e.refs = nullptr; status_t err = mHandleToObject.insertAt(e, N, handle+1-N); - if (err < NO_ERROR) return NULL; + if (err < NO_ERROR) return nullptr; } return &mHandleToObject.editItemAt(handle); } @@ -249,12 +249,12 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) handle_entry* e = lookupHandleLocked(handle); - if (e != NULL) { + if (e != nullptr) { // We need to create a new BpBinder if there isn't currently one, OR we // are unable to acquire a weak reference on this current one. See comment // in getWeakProxyForHandle() for more info about this. IBinder* b = e->binder; - if (b == NULL || !e->refs->attemptIncWeak(this)) { + if (b == nullptr || !e->refs->attemptIncWeak(this)) { if (handle == 0) { // Special case for context manager... // The context manager is the only object for which we create @@ -277,9 +277,9 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) Parcel data; status_t status = IPCThreadState::self()->transact( - 0, IBinder::PING_TRANSACTION, data, NULL, 0); + 0, IBinder::PING_TRANSACTION, data, nullptr, 0); if (status == DEAD_OBJECT) - return NULL; + return nullptr; } b = new BpBinder(handle); @@ -306,7 +306,7 @@ wp<IBinder> ProcessState::getWeakProxyForHandle(int32_t handle) handle_entry* e = lookupHandleLocked(handle); - if (e != NULL) { + if (e != nullptr) { // We need to create a new BpBinder if there isn't currently one, OR we // are unable to acquire a weak reference on this current one. The // attemptIncWeak() is safe because we know the BpBinder destructor will always @@ -315,7 +315,7 @@ wp<IBinder> ProcessState::getWeakProxyForHandle(int32_t handle) // releasing a reference on this BpBinder, and a new reference on its handle // arriving from the driver. IBinder* b = e->binder; - if (b == NULL || !e->refs->attemptIncWeak(this)) { + if (b == nullptr || !e->refs->attemptIncWeak(this)) { b = new BpBinder(handle); result = b; e->binder = b; @@ -338,7 +338,7 @@ void ProcessState::expungeHandle(int32_t handle, IBinder* binder) // This handle may have already been replaced with a new BpBinder // (if someone failed the AttemptIncWeak() above); we don't want // to overwrite it. - if (e && e->binder == binder) e->binder = NULL; + if (e && e->binder == binder) e->binder = nullptr; } String8 ProcessState::makeBinderThreadName() { @@ -416,14 +416,14 @@ ProcessState::ProcessState(const char *driver) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) , mManagesContexts(false) - , mBinderContextCheckFunc(NULL) - , mBinderContextUserData(NULL) + , mBinderContextCheckFunc(nullptr) + , mBinderContextUserData(nullptr) , mThreadPoolStarted(false) , mThreadPoolSeq(1) { if (mDriverFD >= 0) { // mmap the binder, providing a chunk of virtual address space to receive transactions. - mVMStart = mmap(0, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0); + mVMStart = mmap(nullptr, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0); if (mVMStart == MAP_FAILED) { // *sigh* ALOGE("Using %s failed: unable to mmap transaction memory.\n", mDriverName.c_str()); diff --git a/libs/binder/Value.cpp b/libs/binder/Value.cpp index 85cd739411..2b263ed2ee 100644 --- a/libs/binder/Value.cpp +++ b/libs/binder/Value.cpp @@ -143,12 +143,12 @@ template<typename T> bool Value::ContentBase::get(T* out) const // ==================================================================== -Value::Value() : mContent(NULL) +Value::Value() : mContent(nullptr) { } Value::Value(const Value& value) - : mContent(value.mContent ? value.mContent->clone() : NULL) + : mContent(value.mContent ? value.mContent->clone() : nullptr) { } @@ -165,8 +165,8 @@ bool Value::operator==(const Value& rhs) const return true; } - if ( (lhs.mContent == NULL) - || (rhs.mContent == NULL) + if ( (lhs.mContent == nullptr) + || (rhs.mContent == nullptr) ) { return false; } @@ -186,25 +186,25 @@ Value& Value::operator=(const Value& rhs) delete mContent; mContent = rhs.mContent ? rhs.mContent->clone() - : NULL; + : nullptr; } return *this; } bool Value::empty() const { - return mContent == NULL; + return mContent == nullptr; } void Value::clear() { delete mContent; - mContent = NULL; + mContent = nullptr; } int32_t Value::parcelType() const { - const void* t_info(mContent ? mContent->type_ptr() : NULL); + const void* t_info(mContent ? mContent->type_ptr() : nullptr); if (t_info == internal_type_ptr<bool>()) return VAL_BOOLEAN; if (t_info == internal_type_ptr<uint8_t>()) return VAL_BYTE; @@ -381,7 +381,7 @@ status_t Value::readFromParcel(const Parcel* parcel) int32_t value_type = VAL_NULL; delete mContent; - mContent = NULL; + mContent = nullptr; RETURN_IF_FAILED(parcel->readInt32(&value_type)); diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp index 4f00bc13bc..77ebac8f5a 100644 --- a/libs/binder/tests/binderDriverInterfaceTest.cpp +++ b/libs/binder/tests/binderDriverInterfaceTest.cpp @@ -36,8 +36,8 @@ class BinderDriverInterfaceTestEnv : public ::testing::Environment { m_binderFd = open(BINDER_DEV_NAME, O_RDWR | O_NONBLOCK | O_CLOEXEC); ASSERT_GE(m_binderFd, 0); - m_buffer = mmap(NULL, 64*1024, PROT_READ, MAP_SHARED, m_binderFd, 0); - ASSERT_NE(m_buffer, (void *)NULL); + m_buffer = mmap(nullptr, 64*1024, PROT_READ, MAP_SHARED, m_binderFd, 0); + ASSERT_NE(m_buffer, (void *)nullptr); ret = ioctl(m_binderFd, BINDER_SET_MAX_THREADS, &max_threads); EXPECT_EQ(0, ret); EnterLooper(); @@ -156,23 +156,23 @@ TEST_F(BinderDriverInterfaceTest, OpenNoMmap) { } TEST_F(BinderDriverInterfaceTest, WriteReadNull) { - binderTestIoctlErr1(BINDER_WRITE_READ, NULL, EFAULT); + binderTestIoctlErr1(BINDER_WRITE_READ, nullptr, EFAULT); } TEST_F(BinderDriverInterfaceTest, SetIdleTimeoutNull) { - binderTestIoctlErr2(BINDER_SET_IDLE_TIMEOUT, NULL, EFAULT, EINVAL); + binderTestIoctlErr2(BINDER_SET_IDLE_TIMEOUT, nullptr, EFAULT, EINVAL); } TEST_F(BinderDriverInterfaceTest, SetMaxThreadsNull) { - binderTestIoctlErr2(BINDER_SET_MAX_THREADS, NULL, EFAULT, EINVAL); /* TODO: don't accept EINVAL */ + binderTestIoctlErr2(BINDER_SET_MAX_THREADS, nullptr, EFAULT, EINVAL); /* TODO: don't accept EINVAL */ } TEST_F(BinderDriverInterfaceTest, SetIdlePriorityNull) { - binderTestIoctlErr2(BINDER_SET_IDLE_PRIORITY, NULL, EFAULT, EINVAL); + binderTestIoctlErr2(BINDER_SET_IDLE_PRIORITY, nullptr, EFAULT, EINVAL); } TEST_F(BinderDriverInterfaceTest, VersionNull) { - binderTestIoctlErr2(BINDER_VERSION, NULL, EFAULT, EINVAL); /* TODO: don't accept EINVAL */ + binderTestIoctlErr2(BINDER_VERSION, nullptr, EFAULT, EINVAL); /* TODO: don't accept EINVAL */ } TEST_F(BinderDriverInterfaceTest, SetIdleTimeoutNoTest) { diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index 1611e11209..53072ccacb 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -88,7 +88,7 @@ pid_t start_server_process(int arg2, bool usePoll = false) strpipefd1, usepoll, binderserversuffix, - NULL + nullptr }; ret = pipe(pipefd); @@ -123,7 +123,7 @@ pid_t start_server_process(int arg2, bool usePoll = false) } } if (ret < 0) { - wait(NULL); + wait(nullptr); return ret; } return pid; @@ -145,7 +145,7 @@ class BinderLibTestEnv : public ::testing::Environment { sp<IServiceManager> sm = defaultServiceManager(); //printf("%s: pid %d, get service\n", __func__, m_pid); m_server = sm->getService(binderLibTestServiceName); - ASSERT_TRUE(m_server != NULL); + ASSERT_TRUE(m_server != nullptr); //printf("%s: pid %d, get service done\n", __func__, m_pid); } virtual void TearDown() { @@ -155,7 +155,7 @@ class BinderLibTestEnv : public ::testing::Environment { pid_t pid; //printf("%s: pid %d\n", __func__, m_pid); - if (m_server != NULL) { + if (m_server != nullptr) { ret = m_server->transact(BINDER_LIB_TEST_GET_STATUS_TRANSACTION, data, &reply); EXPECT_EQ(0, ret); ret = m_server->transact(BINDER_LIB_TEST_EXIT_TRANSACTION, data, &reply, TF_ONE_WAY); @@ -192,9 +192,9 @@ class BinderLibTest : public ::testing::Test { ret = m_server->transact(code, data, &reply); EXPECT_EQ(NO_ERROR, ret); - EXPECT_FALSE(binder != NULL); + EXPECT_FALSE(binder != nullptr); binder = reply.readStrongBinder(); - EXPECT_TRUE(binder != NULL); + EXPECT_TRUE(binder != nullptr); ret = reply.readInt32(&id); EXPECT_EQ(NO_ERROR, ret); if (idPtr) @@ -202,12 +202,12 @@ class BinderLibTest : public ::testing::Test { return binder; } - sp<IBinder> addServer(int32_t *idPtr = NULL) + sp<IBinder> addServer(int32_t *idPtr = nullptr) { return addServerEtc(idPtr, BINDER_LIB_TEST_ADD_SERVER); } - sp<IBinder> addPollServer(int32_t *idPtr = NULL) + sp<IBinder> addPollServer(int32_t *idPtr = nullptr) { return addServerEtc(idPtr, BINDER_LIB_TEST_ADD_POLL_SERVER); } @@ -274,8 +274,8 @@ class BinderLibTestEvent BinderLibTestEvent(void) : m_eventTriggered(false) { - pthread_mutex_init(&m_waitMutex, NULL); - pthread_cond_init(&m_waitCond, NULL); + pthread_mutex_init(&m_waitMutex, nullptr); + pthread_cond_init(&m_waitCond, nullptr); } int waitEvent(int timeout_s) { @@ -315,7 +315,7 @@ class BinderLibTestCallBack : public BBinder, public BinderLibTestEvent public: BinderLibTestCallBack() : m_result(NOT_ENOUGH_DATA) - , m_prev_end(NULL) + , m_prev_end(nullptr) { } status_t getResult(void) @@ -413,7 +413,7 @@ TEST_F(BinderLibTest, PtrSize) { int32_t ptrsize; Parcel data, reply; sp<IBinder> server = addServer(); - ASSERT_TRUE(server != NULL); + ASSERT_TRUE(server != nullptr); ret = server->transact(BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION, data, &reply); EXPECT_EQ(NO_ERROR, ret); ret = reply.readInt32(&ptrsize); @@ -436,7 +436,7 @@ TEST_F(BinderLibTest, IndirectGetId2) BinderLibTestBundle datai; server = addServer(&serverId[i]); - ASSERT_TRUE(server != NULL); + ASSERT_TRUE(server != nullptr); data.writeStrongBinder(server); data.writeInt32(BINDER_LIB_TEST_GET_ID_TRANSACTION); datai.appendTo(&data); @@ -480,7 +480,7 @@ TEST_F(BinderLibTest, IndirectGetId3) BinderLibTestBundle datai2; server = addServer(&serverId[i]); - ASSERT_TRUE(server != NULL); + ASSERT_TRUE(server != nullptr); data.writeStrongBinder(server); data.writeInt32(BINDER_LIB_TEST_INDIRECT_TRANSACTION); @@ -546,7 +546,7 @@ TEST_F(BinderLibTest, CallBack) TEST_F(BinderLibTest, AddServer) { sp<IBinder> server = addServer(); - ASSERT_TRUE(server != NULL); + ASSERT_TRUE(server != nullptr); } TEST_F(BinderLibTest, DeathNotificationNoRefs) @@ -557,7 +557,7 @@ TEST_F(BinderLibTest, DeathNotificationNoRefs) { sp<IBinder> binder = addServer(); - ASSERT_TRUE(binder != NULL); + ASSERT_TRUE(binder != nullptr); ret = binder->linkToDeath(testDeathRecipient); EXPECT_EQ(NO_ERROR, ret); } @@ -579,7 +579,7 @@ TEST_F(BinderLibTest, DeathNotificationWeakRef) { sp<IBinder> binder = addServer(); - ASSERT_TRUE(binder != NULL); + ASSERT_TRUE(binder != nullptr); ret = binder->linkToDeath(testDeathRecipient); EXPECT_EQ(NO_ERROR, ret); wbinder = binder; @@ -602,7 +602,7 @@ TEST_F(BinderLibTest, DeathNotificationStrongRef) { sp<IBinder> binder = addServer(); - ASSERT_TRUE(binder != NULL); + ASSERT_TRUE(binder != nullptr); ret = binder->linkToDeath(testDeathRecipient); EXPECT_EQ(NO_ERROR, ret); sbinder = binder; @@ -629,13 +629,13 @@ TEST_F(BinderLibTest, DeathNotificationMultiple) sp<IBinder> passiveclient[clientcount]; target = addServer(); - ASSERT_TRUE(target != NULL); + ASSERT_TRUE(target != nullptr); for (int i = 0; i < clientcount; i++) { { Parcel data, reply; linkedclient[i] = addServer(); - ASSERT_TRUE(linkedclient[i] != NULL); + ASSERT_TRUE(linkedclient[i] != nullptr); callBack[i] = new BinderLibTestCallBack(); data.writeStrongBinder(target); data.writeStrongBinder(callBack[i]); @@ -646,7 +646,7 @@ TEST_F(BinderLibTest, DeathNotificationMultiple) Parcel data, reply; passiveclient[i] = addServer(); - ASSERT_TRUE(passiveclient[i] != NULL); + ASSERT_TRUE(passiveclient[i] != nullptr); data.writeStrongBinder(target); ret = passiveclient[i]->transact(BINDER_LIB_TEST_ADD_STRONG_REF_TRANSACTION, data, &reply, TF_ONE_WAY); EXPECT_EQ(NO_ERROR, ret); @@ -671,9 +671,9 @@ TEST_F(BinderLibTest, DeathNotificationThread) status_t ret; sp<BinderLibTestCallBack> callback; sp<IBinder> target = addServer(); - ASSERT_TRUE(target != NULL); + ASSERT_TRUE(target != nullptr); sp<IBinder> client = addServer(); - ASSERT_TRUE(client != NULL); + ASSERT_TRUE(client != nullptr); sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient(); @@ -767,12 +767,12 @@ TEST_F(BinderLibTest, PromoteLocal) { sp<IBinder> strong = new BBinder(); wp<IBinder> weak = strong; sp<IBinder> strong_from_weak = weak.promote(); - EXPECT_TRUE(strong != NULL); + EXPECT_TRUE(strong != nullptr); EXPECT_EQ(strong, strong_from_weak); - strong = NULL; - strong_from_weak = NULL; + strong = nullptr; + strong_from_weak = nullptr; strong_from_weak = weak.promote(); - EXPECT_TRUE(strong_from_weak == NULL); + EXPECT_TRUE(strong_from_weak == nullptr); } TEST_F(BinderLibTest, PromoteRemote) { @@ -781,8 +781,8 @@ TEST_F(BinderLibTest, PromoteRemote) { sp<IBinder> strong = new BBinder(); sp<IBinder> server = addServer(); - ASSERT_TRUE(server != NULL); - ASSERT_TRUE(strong != NULL); + ASSERT_TRUE(server != nullptr); + ASSERT_TRUE(strong != nullptr); ret = data.writeWeakBinder(strong); EXPECT_EQ(NO_ERROR, ret); @@ -799,7 +799,7 @@ TEST_F(BinderLibTest, CheckHandleZeroBinderHighBitsZeroCookie) { EXPECT_EQ(NO_ERROR, ret); const flat_binder_object *fb = reply.readObject(false); - ASSERT_TRUE(fb != NULL); + ASSERT_TRUE(fb != nullptr); EXPECT_EQ(BINDER_TYPE_HANDLE, fb->hdr.type); EXPECT_EQ(m_server, ProcessState::self()->getStrongProxyForHandle(fb->handle)); EXPECT_EQ((binder_uintptr_t)0, fb->cookie); @@ -810,7 +810,7 @@ TEST_F(BinderLibTest, FreedBinder) { status_t ret; sp<IBinder> server = addServer(); - ASSERT_TRUE(server != NULL); + ASSERT_TRUE(server != nullptr); __u32 freedHandle; wp<IBinder> keepFreedBinder; @@ -881,12 +881,12 @@ TEST_F(BinderLibTest, OnewayQueueing) data2.writeStrongBinder(callBack2); data2.writeInt32(0); // delay in us - ret = pollServer->transact(BINDER_LIB_TEST_DELAYED_CALL_BACK, data, NULL, TF_ONE_WAY); + ret = pollServer->transact(BINDER_LIB_TEST_DELAYED_CALL_BACK, data, nullptr, TF_ONE_WAY); EXPECT_EQ(NO_ERROR, ret); // The delay ensures that this second transaction will end up on the async_todo list // (for a single-threaded server) - ret = pollServer->transact(BINDER_LIB_TEST_DELAYED_CALL_BACK, data2, NULL, TF_ONE_WAY); + ret = pollServer->transact(BINDER_LIB_TEST_DELAYED_CALL_BACK, data2, nullptr, TF_ONE_WAY); EXPECT_EQ(NO_ERROR, ret); // The server will ensure that the two transactions are handled in the expected order; @@ -909,10 +909,10 @@ class BinderLibTestService : public BBinder : m_id(id) , m_nextServerId(id + 1) , m_serverStartRequested(false) - , m_callback(NULL) + , m_callback(nullptr) { - pthread_mutex_init(&m_serverWaitMutex, NULL); - pthread_cond_init(&m_serverWaitCond, NULL); + pthread_mutex_init(&m_serverWaitMutex, nullptr); + pthread_cond_init(&m_serverWaitCond, nullptr); } ~BinderLibTestService() { @@ -920,11 +920,11 @@ class BinderLibTestService : public BBinder } void processPendingCall() { - if (m_callback != NULL) { + if (m_callback != nullptr) { Parcel data; data.writeInt32(NO_ERROR); m_callback->transact(BINDER_LIB_TEST_CALL_BACK, data, nullptr, TF_ONE_WAY); - m_callback = NULL; + m_callback = nullptr; } } @@ -943,7 +943,7 @@ class BinderLibTestService : public BBinder sp<IBinder> binder; id = data.readInt32(); binder = data.readStrongBinder(); - if (binder == NULL) { + if (binder == nullptr) { return BAD_VALUE; } @@ -993,7 +993,7 @@ class BinderLibTestService : public BBinder } else { reply->writeStrongBinder(m_serverStarted); reply->writeInt32(serverid); - m_serverStarted = NULL; + m_serverStarted = nullptr; ret = NO_ERROR; } } else if (ret >= 0) { @@ -1008,7 +1008,7 @@ class BinderLibTestService : public BBinder case BINDER_LIB_TEST_DELAYED_CALL_BACK: { // Note: this transaction is only designed for use with a // poll() server. See comments around epoll_wait(). - if (m_callback != NULL) { + if (m_callback != nullptr) { // A callback was already pending; this means that // we received a second call while still processing // the first one. Fail the test. @@ -1016,7 +1016,7 @@ class BinderLibTestService : public BBinder Parcel data2; data2.writeInt32(UNKNOWN_ERROR); - callback->transact(BINDER_LIB_TEST_CALL_BACK, data2, NULL, TF_ONE_WAY); + callback->transact(BINDER_LIB_TEST_CALL_BACK, data2, nullptr, TF_ONE_WAY); } else { m_callback = data.readStrongBinder(); int32_t delayUs = data.readInt32(); @@ -1045,7 +1045,7 @@ class BinderLibTestService : public BBinder Parcel data2, reply2; sp<IBinder> binder; binder = data.readStrongBinder(); - if (binder == NULL) { + if (binder == nullptr) { return BAD_VALUE; } data2.writeInt32(NO_ERROR); @@ -1068,7 +1068,7 @@ class BinderLibTestService : public BBinder reply->writeInt32(count); for (int i = 0; i < count; i++) { binder = data.readStrongBinder(); - if (binder == NULL) { + if (binder == nullptr) { return BAD_VALUE; } indirect_code = data.readInt32(); @@ -1101,11 +1101,11 @@ class BinderLibTestService : public BBinder sp<IBinder> callback; target = data.readStrongBinder(); - if (target == NULL) { + if (target == nullptr) { return BAD_VALUE; } callback = data.readStrongBinder(); - if (callback == NULL) { + if (callback == nullptr) { return BAD_VALUE; } ret = target->linkToDeath(testDeathRecipient); @@ -1130,7 +1130,7 @@ class BinderLibTestService : public BBinder return ret; } buf = data.readInplace(size); - if (buf == NULL) { + if (buf == nullptr) { return BAD_VALUE; } ret = write(fd, buf, size); @@ -1147,7 +1147,7 @@ class BinderLibTestService : public BBinder sp<IBinder> server = sm->getService(binderLibTestServiceName); weak = data.readWeakBinder(); - if (weak == NULL) { + if (weak == nullptr) { return BAD_VALUE; } strong = weak.promote(); @@ -1156,7 +1156,7 @@ class BinderLibTestService : public BBinder if (ret != NO_ERROR) exit(EXIT_FAILURE); - if (strong == NULL) { + if (strong == nullptr) { reply->setError(1); } return NO_ERROR; @@ -1165,7 +1165,7 @@ class BinderLibTestService : public BBinder alarm(10); return NO_ERROR; case BINDER_LIB_TEST_EXIT_TRANSACTION: - while (wait(NULL) != -1 || errno != ECHILD) + while (wait(nullptr) != -1 || errno != ECHILD) ; exit(EXIT_SUCCESS); case BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION: { diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp index 455f2c418d..da7fc39a8f 100644 --- a/libs/binder/tests/binderThroughputTest.cpp +++ b/libs/binder/tests/binderThroughputTest.cpp @@ -380,7 +380,7 @@ int main(int argc, char *argv[]) // Caller specified the max latency in microseconds. // No need to run training round in this case. if (atoi(argv[i+1]) > 0) { - max_time_bucket = strtoull(argv[i+1], (char **)NULL, 10) * 1000; + max_time_bucket = strtoull(argv[i+1], (char **)nullptr, 10) * 1000; i++; } else { cout << "Max latency -m must be positive." << endl; diff --git a/libs/binder/tests/schd-dbg.cpp b/libs/binder/tests/schd-dbg.cpp index 13f03b1ae0..6cf7f36021 100644 --- a/libs/binder/tests/schd-dbg.cpp +++ b/libs/binder/tests/schd-dbg.cpp @@ -295,7 +295,7 @@ static void* thread_start(void* p) { no_inherent += reply.readInt32(); no_sync += reply.readInt32(); - return 0; + return nullptr; } // create a fifo thread to transact and wait it to finished |