summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp108
1 files changed, 54 insertions, 54 deletions
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;
}