Merge "[binder] Replace NULL/0 with nullptr"
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index f3b86ae..4a9b9a7 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -42,7 +42,7 @@
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 @@
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 @@
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::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 a81f44e..1bd7c4f 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -43,17 +43,17 @@
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 @@
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 @@
break;
}
- if (reply != NULL) {
+ if (reply != nullptr) {
reply->setDataPosition(0);
}
@@ -171,7 +171,7 @@
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::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 @@
(void)out;
(void)err;
- if (resultReceiver != NULL) {
+ if (resultReceiver != nullptr) {
resultReceiver->send(INVALID_OPERATION);
}
@@ -273,7 +273,7 @@
};
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 c0e0296..49ff460 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -62,7 +62,7 @@
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 @@
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 @@
: mHandle(handle)
, mAlive(1)
, mObitsSent(0)
- , mObituaries(NULL)
+ , mObituaries(nullptr)
{
ALOGV("Creating BpBinder %p handle %d\n", this, mHandle);
@@ -179,7 +179,7 @@
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 @@
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 @@
self->clearDeathNotification(mHandle, this);
self->flushCommands();
delete mObituaries;
- mObituaries = NULL;
+ mObituaries = nullptr;
}
return NO_ERROR;
}
@@ -250,12 +250,12 @@
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 @@
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 @@
{
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 @@
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 30e70b0..0946aca 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -36,7 +36,7 @@
{
explicit BufferState(int32_t _seq)
: seq(_seq)
- , buffer(NULL)
+ , buffer(nullptr)
, bufferPos(0)
, bufferSize(0)
, atFront(true)
@@ -266,13 +266,13 @@
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 4ac61a3..f38bbb2 100644
--- a/libs/binder/Debug.cpp
+++ b/libs/binder/Debug.cpp
@@ -165,13 +165,13 @@
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 @@
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 638ae5c..c38568c 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -108,7 +108,7 @@
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 2fcd3d9..6b77291 100644
--- a/libs/binder/IInterface.cpp
+++ b/libs/binder/IInterface.cpp
@@ -32,14 +32,14 @@
// 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 5c1a4f4..7afec45 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -130,7 +130,7 @@
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 @@
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 @@
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 @@
} else {
// Hm.
android_errorWriteWithInfoLog(0x534e4554,
- "26877992", -1, NULL, 0);
+ "26877992", -1, nullptr, 0);
mOffset = 0;
mSize = 0;
}
@@ -212,7 +212,7 @@
}
if (offset) *offset = mOffset;
if (size) *size = mSize;
- return (mSize > 0) ? mHeap : 0;
+ return (mSize > 0) ? mHeap : nullptr;
}
// ---------------------------------------------------------------------------
@@ -334,7 +334,7 @@
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 ba9bf61..33ec65f 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -289,7 +289,7 @@
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 @@
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* st = (IPCThreadState*)pthread_getspecific(k);
return st;
}
- return NULL;
+ return nullptr;
}
void IPCThreadState::shutdown()
@@ -326,7 +326,7 @@
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 @@
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 @@
else alog << "(none requested)" << endl;
}
} else {
- err = waitForResponse(NULL, NULL);
+ err = waitForResponse(nullptr, nullptr);
}
return err;
@@ -725,7 +725,7 @@
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 @@
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 @@
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 646809e..14b5259 100644
--- a/libs/binder/IResultReceiver.cpp
+++ b/libs/binder/IResultReceiver.cpp
@@ -40,7 +40,7 @@
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 @@
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 c7a0f43..001dc9e 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -33,14 +33,14 @@
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 @@
bool checkCallingPermission(const String16& permission)
{
- return checkCallingPermission(permission, NULL, NULL);
+ return checkCallingPermission(permission, nullptr, nullptr);
}
static String16 _permission("permission");
@@ -76,7 +76,7 @@
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 @@
// 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 @@
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 c793df3..4568a42 100644
--- a/libs/binder/IShellCallback.cpp
+++ b/libs/binder/IShellCallback.cpp
@@ -65,7 +65,7 @@
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 1cfe02a..eacad3b 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -52,8 +52,8 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
}
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 03f00be..9850ad9 100644
--- a/libs/binder/MemoryHeapBase.cpp
+++ b/libs/binder/MemoryHeapBase.cpp
@@ -36,17 +36,17 @@
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(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(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 @@
}
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 @@
mBase = base;
mNeedUnmap = true;
} else {
- mBase = 0; // not MAP_FAILED
+ mBase = nullptr; // not MAP_FAILED
mNeedUnmap = false;
}
mFD = fd;
@@ -143,7 +143,7 @@
//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 f739f07..03aef17 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -117,7 +117,7 @@
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 @@
}
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,
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
IPCThreadState* threadState) const
{
int32_t strictPolicy = readInt32();
- if (threadState == NULL) {
+ if (threadState == nullptr) {
threadState = IPCThreadState::self();
}
if ((threadState->getLastTransactionBinderFlags() &
@@ -721,14 +721,14 @@
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 @@
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 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 @@
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 @@
// 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 @@
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::writeNullableMap(const std::unique_ptr<binder::Map>& map)
{
- if (map == NULL) {
+ if (map == nullptr) {
return writeInt32(-1);
}
@@ -1492,7 +1492,7 @@
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 @@
ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos);
return data;
}
- return NULL;
+ return nullptr;
}
template<class T>
@@ -1943,7 +1943,7 @@
return str;
}
}
- return NULL;
+ return nullptr;
}
String8 Parcel::readString8() const
@@ -1974,7 +1974,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
}
//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 @@
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 @@
{
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 @@
// --- 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::clear() {
mFd = -1;
- mData = NULL;
+ mData = nullptr;
mSize = 0;
mMutable = false;
}
diff --git a/libs/binder/PermissionCache.cpp b/libs/binder/PermissionCache.cpp
index a503be8..a4c28ad 100644
--- a/libs/binder/PermissionCache.cpp
+++ b/libs/binder/PermissionCache.cpp
@@ -75,7 +75,7 @@
}
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 8939d9c..5cb2033 100644
--- a/libs/binder/ProcessInfoService.cpp
+++ b/libs/binder/ProcessInfoService.cpp
@@ -36,7 +36,7 @@
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 @@
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 @@
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 8606129..6e7c427 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -68,7 +68,7 @@
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::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 @@
{
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 @@
ipc->flushCommands();
- if (object != NULL) setContextObject(object, name);
+ if (object != nullptr) setContextObject(object, name);
return object;
}
@@ -180,8 +180,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
, 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 85cd739..2b263ed 100644
--- a/libs/binder/Value.cpp
+++ b/libs/binder/Value.cpp
@@ -143,12 +143,12 @@
// ====================================================================
-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 @@
return true;
}
- if ( (lhs.mContent == NULL)
- || (rhs.mContent == NULL)
+ if ( (lhs.mContent == nullptr)
+ || (rhs.mContent == nullptr)
) {
return false;
}
@@ -186,25 +186,25 @@
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 @@
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 4f00bc1..77ebac8 100644
--- a/libs/binder/tests/binderDriverInterfaceTest.cpp
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -36,8 +36,8 @@
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, 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 1611e11..53072cc 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -88,7 +88,7 @@
strpipefd1,
usepoll,
binderserversuffix,
- NULL
+ nullptr
};
ret = pipe(pipefd);
@@ -123,7 +123,7 @@
}
}
if (ret < 0) {
- wait(NULL);
+ wait(nullptr);
return ret;
}
return pid;
@@ -145,7 +145,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
public:
BinderLibTestCallBack()
: m_result(NOT_ENOUGH_DATA)
- , m_prev_end(NULL)
+ , m_prev_end(nullptr)
{
}
status_t getResult(void)
@@ -413,7 +413,7 @@
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 @@
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 @@
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, AddServer)
{
sp<IBinder> server = addServer();
- ASSERT_TRUE(server != NULL);
+ ASSERT_TRUE(server != nullptr);
}
TEST_F(BinderLibTest, DeathNotificationNoRefs)
@@ -557,7 +557,7 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
status_t ret;
sp<IBinder> server = addServer();
- ASSERT_TRUE(server != NULL);
+ ASSERT_TRUE(server != nullptr);
__u32 freedHandle;
wp<IBinder> keepFreedBinder;
@@ -881,12 +881,12 @@
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 @@
: 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 @@
}
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 @@
sp<IBinder> binder;
id = data.readInt32();
binder = data.readStrongBinder();
- if (binder == NULL) {
+ if (binder == nullptr) {
return BAD_VALUE;
}
@@ -993,7 +993,7 @@
} 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return ret;
}
buf = data.readInplace(size);
- if (buf == NULL) {
+ if (buf == nullptr) {
return BAD_VALUE;
}
ret = write(fd, buf, size);
@@ -1147,7 +1147,7 @@
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 @@
if (ret != NO_ERROR)
exit(EXIT_FAILURE);
- if (strong == NULL) {
+ if (strong == nullptr) {
reply->setError(1);
}
return NO_ERROR;
@@ -1165,7 +1165,7 @@
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 455f2c4..da7fc39 100644
--- a/libs/binder/tests/binderThroughputTest.cpp
+++ b/libs/binder/tests/binderThroughputTest.cpp
@@ -380,7 +380,7 @@
// 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 13f03b1..6cf7f36 100644
--- a/libs/binder/tests/schd-dbg.cpp
+++ b/libs/binder/tests/schd-dbg.cpp
@@ -295,7 +295,7 @@
no_inherent += reply.readInt32();
no_sync += reply.readInt32();
- return 0;
+ return nullptr;
}
// create a fifo thread to transact and wait it to finished