binder: Turn on -Werror
Change-Id: I0ee785927a7ae5f731b02176b0b781b87c22a24e
This commit is contained in:
parent
f1dd859baa
commit
d4ecccfd20
@ -46,6 +46,7 @@ ifneq ($(TARGET_IS_64_BIT),true)
|
|||||||
LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
|
LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
LOCAL_CFLAGS += -Werror
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
@ -57,4 +58,5 @@ ifneq ($(TARGET_IS_64_BIT),true)
|
|||||||
LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
|
LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
LOCAL_CFLAGS += -Werror
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
@ -73,7 +73,7 @@ void BpBinder::ObjectManager::detach(const void* objectID)
|
|||||||
void BpBinder::ObjectManager::kill()
|
void BpBinder::ObjectManager::kill()
|
||||||
{
|
{
|
||||||
const size_t N = mObjects.size();
|
const size_t N = mObjects.size();
|
||||||
ALOGV("Killing %d objects in manager %p", N, this);
|
ALOGV("Killing %zu objects in manager %p", N, this);
|
||||||
for (size_t i=0; i<N; i++) {
|
for (size_t i=0; i<N; i++) {
|
||||||
const entry_t& e = mObjects.valueAt(i);
|
const entry_t& e = mObjects.valueAt(i);
|
||||||
if (e.func != NULL) {
|
if (e.func != NULL) {
|
||||||
@ -119,11 +119,11 @@ const String16& BpBinder::getInterfaceDescriptor() const
|
|||||||
mDescriptorCache = res;
|
mDescriptorCache = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're returning a reference to a non-static object here. Usually this
|
// we're returning a reference to a non-static object here. Usually this
|
||||||
// is not something smart to do, however, with binder objects it is
|
// is not something smart to do, however, with binder objects it is
|
||||||
// (usually) safe because they are reference-counted.
|
// (usually) safe because they are reference-counted.
|
||||||
|
|
||||||
return mDescriptorCache;
|
return mDescriptorCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,8 +260,8 @@ void BpBinder::sendObituary()
|
|||||||
mObitsSent = 1;
|
mObitsSent = 1;
|
||||||
mLock.unlock();
|
mLock.unlock();
|
||||||
|
|
||||||
ALOGV("Reporting death of proxy %p for %d recipients\n",
|
ALOGV("Reporting death of proxy %p for %zu recipients\n",
|
||||||
this, obits ? obits->size() : 0);
|
this, obits ? obits->size() : 0U);
|
||||||
|
|
||||||
if (obits != NULL) {
|
if (obits != NULL) {
|
||||||
const size_t N = obits->size();
|
const size_t N = obits->size();
|
||||||
|
@ -155,7 +155,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/,
|
|||||||
const sp<IBinder>& binder, Parcel* out)
|
const sp<IBinder>& binder, Parcel* out)
|
||||||
{
|
{
|
||||||
flat_binder_object obj;
|
flat_binder_object obj;
|
||||||
|
|
||||||
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
||||||
if (binder != NULL) {
|
if (binder != NULL) {
|
||||||
IBinder *local = binder->localBinder();
|
IBinder *local = binder->localBinder();
|
||||||
@ -179,7 +179,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/,
|
|||||||
obj.binder = 0;
|
obj.binder = 0;
|
||||||
obj.cookie = 0;
|
obj.cookie = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return finish_flatten_binder(binder, obj, out);
|
return finish_flatten_binder(binder, obj, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/,
|
|||||||
const wp<IBinder>& binder, Parcel* out)
|
const wp<IBinder>& binder, Parcel* out)
|
||||||
{
|
{
|
||||||
flat_binder_object obj;
|
flat_binder_object obj;
|
||||||
|
|
||||||
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
||||||
if (binder != NULL) {
|
if (binder != NULL) {
|
||||||
sp<IBinder> real = binder.promote();
|
sp<IBinder> real = binder.promote();
|
||||||
@ -210,7 +210,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/,
|
|||||||
}
|
}
|
||||||
return finish_flatten_binder(real, obj, out);
|
return finish_flatten_binder(real, obj, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX How to deal? In order to flatten the given binder,
|
// XXX How to deal? In order to flatten the given binder,
|
||||||
// we need to probe it for information, which requires a primary
|
// we need to probe it for information, which requires a primary
|
||||||
// reference... but we don't have one.
|
// reference... but we don't have one.
|
||||||
@ -223,7 +223,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/,
|
|||||||
obj.binder = 0;
|
obj.binder = 0;
|
||||||
obj.cookie = 0;
|
obj.cookie = 0;
|
||||||
return finish_flatten_binder(NULL, obj, out);
|
return finish_flatten_binder(NULL, obj, out);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
obj.type = BINDER_TYPE_BINDER;
|
obj.type = BINDER_TYPE_BINDER;
|
||||||
obj.binder = 0;
|
obj.binder = 0;
|
||||||
@ -238,12 +238,12 @@ inline static status_t finish_unflatten_binder(
|
|||||||
{
|
{
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t unflatten_binder(const sp<ProcessState>& proc,
|
status_t unflatten_binder(const sp<ProcessState>& proc,
|
||||||
const Parcel& in, sp<IBinder>* out)
|
const Parcel& in, sp<IBinder>* out)
|
||||||
{
|
{
|
||||||
const flat_binder_object* flat = in.readObject(false);
|
const flat_binder_object* flat = in.readObject(false);
|
||||||
|
|
||||||
if (flat) {
|
if (flat) {
|
||||||
switch (flat->type) {
|
switch (flat->type) {
|
||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
@ -253,7 +253,7 @@ status_t unflatten_binder(const sp<ProcessState>& proc,
|
|||||||
*out = proc->getStrongProxyForHandle(flat->handle);
|
*out = proc->getStrongProxyForHandle(flat->handle);
|
||||||
return finish_unflatten_binder(
|
return finish_unflatten_binder(
|
||||||
static_cast<BpBinder*>(out->get()), *flat, in);
|
static_cast<BpBinder*>(out->get()), *flat, in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BAD_TYPE;
|
return BAD_TYPE;
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ status_t unflatten_binder(const sp<ProcessState>& proc,
|
|||||||
const Parcel& in, wp<IBinder>* out)
|
const Parcel& in, wp<IBinder>* out)
|
||||||
{
|
{
|
||||||
const flat_binder_object* flat = in.readObject(false);
|
const flat_binder_object* flat = in.readObject(false);
|
||||||
|
|
||||||
if (flat) {
|
if (flat) {
|
||||||
switch (flat->type) {
|
switch (flat->type) {
|
||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
@ -336,7 +336,7 @@ status_t Parcel::setDataSize(size_t size)
|
|||||||
err = continueWrite(size);
|
err = continueWrite(size);
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
mDataSize = size;
|
mDataSize = size;
|
||||||
ALOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("setDataSize Setting data size of %p to %zu", this, mDataSize);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -424,7 +424,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
|
|||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
mObjectsCapacity = newSize;
|
mObjectsCapacity = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// append and acquire objects
|
// append and acquire objects
|
||||||
int idx = mObjectsSize;
|
int idx = mObjectsSize;
|
||||||
for (int i = firstIndex; i <= lastIndex; i++) {
|
for (int i = firstIndex; i <= lastIndex; i++) {
|
||||||
@ -510,7 +510,7 @@ bool Parcel::enforceInterface(const String16& interface,
|
|||||||
if (str == interface) {
|
if (str == interface) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ALOGW("**** enforceInterface() expected '%s' but read '%s'\n",
|
ALOGW("**** enforceInterface() expected '%s' but read '%s'",
|
||||||
String8(interface).string(), String8(str).string());
|
String8(interface).string(), String8(str).string());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -540,10 +540,10 @@ status_t Parcel::finishWrite(size_t len)
|
|||||||
{
|
{
|
||||||
//printf("Finish write of %d\n", len);
|
//printf("Finish write of %d\n", len);
|
||||||
mDataPos += len;
|
mDataPos += len;
|
||||||
ALOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("finishWrite Setting data pos of %p to %zu", this, mDataPos);
|
||||||
if (mDataPos > mDataSize) {
|
if (mDataPos > mDataSize) {
|
||||||
mDataSize = mDataPos;
|
mDataSize = mDataPos;
|
||||||
ALOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("finishWrite Setting data size of %p to %zu", this, mDataSize);
|
||||||
}
|
}
|
||||||
//printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
|
//printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
@ -709,7 +709,7 @@ status_t Parcel::writeString16(const String16& str)
|
|||||||
status_t Parcel::writeString16(const char16_t* str, size_t len)
|
status_t Parcel::writeString16(const char16_t* str, size_t len)
|
||||||
{
|
{
|
||||||
if (str == NULL) return writeInt32(-1);
|
if (str == NULL) return writeInt32(-1);
|
||||||
|
|
||||||
status_t err = writeInt32(len);
|
status_t err = writeInt32(len);
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
len *= sizeof(char16_t);
|
len *= sizeof(char16_t);
|
||||||
@ -872,14 +872,14 @@ status_t Parcel::writeObject(const flat_binder_object& val, bool nullMetaData)
|
|||||||
if (enoughData && enoughObjects) {
|
if (enoughData && enoughObjects) {
|
||||||
restart_write:
|
restart_write:
|
||||||
*reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
|
*reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
|
||||||
|
|
||||||
// Need to write meta-data?
|
// Need to write meta-data?
|
||||||
if (nullMetaData || val.binder != 0) {
|
if (nullMetaData || val.binder != 0) {
|
||||||
mObjects[mObjectsSize] = mDataPos;
|
mObjects[mObjectsSize] = mDataPos;
|
||||||
acquire_object(ProcessState::self(), val, this);
|
acquire_object(ProcessState::self(), val, this);
|
||||||
mObjectsSize++;
|
mObjectsSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remember if it's a file descriptor
|
// remember if it's a file descriptor
|
||||||
if (val.type == BINDER_TYPE_FD) {
|
if (val.type == BINDER_TYPE_FD) {
|
||||||
if (!mAllowFds) {
|
if (!mAllowFds) {
|
||||||
@ -902,7 +902,7 @@ restart_write:
|
|||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
mObjectsCapacity = newSize;
|
mObjectsCapacity = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
goto restart_write;
|
goto restart_write;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,7 +922,7 @@ status_t Parcel::read(void* outData, size_t len) const
|
|||||||
&& len <= PAD_SIZE(len)) {
|
&& len <= PAD_SIZE(len)) {
|
||||||
memcpy(outData, mData+mDataPos, len);
|
memcpy(outData, mData+mDataPos, len);
|
||||||
mDataPos += PAD_SIZE(len);
|
mDataPos += PAD_SIZE(len);
|
||||||
ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("read Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
return NOT_ENOUGH_DATA;
|
return NOT_ENOUGH_DATA;
|
||||||
@ -934,7 +934,7 @@ const void* Parcel::readInplace(size_t len) const
|
|||||||
&& len <= PAD_SIZE(len)) {
|
&& len <= PAD_SIZE(len)) {
|
||||||
const void* data = mData+mDataPos;
|
const void* data = mData+mDataPos;
|
||||||
mDataPos += PAD_SIZE(len);
|
mDataPos += PAD_SIZE(len);
|
||||||
ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1088,7 +1088,7 @@ const char* Parcel::readCString() const
|
|||||||
if (eos) {
|
if (eos) {
|
||||||
const size_t len = eos - str;
|
const size_t len = eos - str;
|
||||||
mDataPos += PAD_SIZE(len+1);
|
mDataPos += PAD_SIZE(len+1);
|
||||||
ALOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1190,9 +1190,9 @@ int Parcel::readFileDescriptor() const
|
|||||||
if (flat) {
|
if (flat) {
|
||||||
switch (flat->type) {
|
switch (flat->type) {
|
||||||
case BINDER_TYPE_FD:
|
case BINDER_TYPE_FD:
|
||||||
//ALOGI("Returning file descriptor %ld from parcel %p\n", flat->handle, this);
|
//ALOGI("Returning file descriptor %ld from parcel %p", flat->handle, this);
|
||||||
return flat->handle;
|
return flat->handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BAD_TYPE;
|
return BAD_TYPE;
|
||||||
}
|
}
|
||||||
@ -1244,7 +1244,7 @@ status_t Parcel::read(FlattenableHelperInterface& val) const
|
|||||||
fds[i] = dup(this->readFileDescriptor());
|
fds[i] = dup(this->readFileDescriptor());
|
||||||
if (fds[i] < 0) {
|
if (fds[i] < 0) {
|
||||||
err = BAD_VALUE;
|
err = BAD_VALUE;
|
||||||
ALOGE("dup() failed in Parcel::read, i is %d, fds[i] is %d, fd_count is %d, error: %s",
|
ALOGE("dup() failed in Parcel::read, i is %zu, fds[i] is %d, fd_count is %zu, error: %s",
|
||||||
i, fds[i], fd_count, strerror(errno));
|
i, fds[i], fd_count, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1270,19 +1270,19 @@ const flat_binder_object* Parcel::readObject(bool nullMetaData) const
|
|||||||
// When transferring a NULL object, we don't write it into
|
// When transferring a NULL object, we don't write it into
|
||||||
// the object list, so we don't want to check for it when
|
// the object list, so we don't want to check for it when
|
||||||
// reading.
|
// reading.
|
||||||
ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that this object is valid...
|
// Ensure that this object is valid...
|
||||||
binder_size_t* const OBJS = mObjects;
|
binder_size_t* const OBJS = mObjects;
|
||||||
const size_t N = mObjectsSize;
|
const size_t N = mObjectsSize;
|
||||||
size_t opos = mNextObjectHint;
|
size_t opos = mNextObjectHint;
|
||||||
|
|
||||||
if (N > 0) {
|
if (N > 0) {
|
||||||
ALOGV("Parcel %p looking for obj at %d, hint=%d\n",
|
ALOGV("Parcel %p looking for obj at %zu, hint=%zu",
|
||||||
this, DPOS, opos);
|
this, DPOS, opos);
|
||||||
|
|
||||||
// Start at the current hint position, looking for an object at
|
// Start at the current hint position, looking for an object at
|
||||||
// the current data position.
|
// the current data position.
|
||||||
if (opos < N) {
|
if (opos < N) {
|
||||||
@ -1294,23 +1294,23 @@ const flat_binder_object* Parcel::readObject(bool nullMetaData) const
|
|||||||
}
|
}
|
||||||
if (OBJS[opos] == DPOS) {
|
if (OBJS[opos] == DPOS) {
|
||||||
// Found it!
|
// Found it!
|
||||||
ALOGV("Parcel found obj %d at index %d with forward search",
|
ALOGV("Parcel %p found obj %zu at index %zu with forward search",
|
||||||
this, DPOS, opos);
|
this, DPOS, opos);
|
||||||
mNextObjectHint = opos+1;
|
mNextObjectHint = opos+1;
|
||||||
ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look backwards for it...
|
// Look backwards for it...
|
||||||
while (opos > 0 && OBJS[opos] > DPOS) {
|
while (opos > 0 && OBJS[opos] > DPOS) {
|
||||||
opos--;
|
opos--;
|
||||||
}
|
}
|
||||||
if (OBJS[opos] == DPOS) {
|
if (OBJS[opos] == DPOS) {
|
||||||
// Found it!
|
// Found it!
|
||||||
ALOGV("Parcel found obj %d at index %d with backward search",
|
ALOGV("Parcel %p found obj %zu at index %zu with backward search",
|
||||||
this, DPOS, opos);
|
this, DPOS, opos);
|
||||||
mNextObjectHint = opos+1;
|
mNextObjectHint = opos+1;
|
||||||
ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1324,14 +1324,14 @@ void Parcel::closeFileDescriptors()
|
|||||||
{
|
{
|
||||||
size_t i = mObjectsSize;
|
size_t i = mObjectsSize;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
//ALOGI("Closing file descriptors for %d objects...", mObjectsSize);
|
//ALOGI("Closing file descriptors for %zu objects...", i);
|
||||||
}
|
}
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
const flat_binder_object* flat
|
const flat_binder_object* flat
|
||||||
= reinterpret_cast<flat_binder_object*>(mData+mObjects[i]);
|
= reinterpret_cast<flat_binder_object*>(mData+mObjects[i]);
|
||||||
if (flat->type == BINDER_TYPE_FD) {
|
if (flat->type == BINDER_TYPE_FD) {
|
||||||
//ALOGI("Closing fd: %ld\n", flat->handle);
|
//ALOGI("Closing fd: %ld", flat->handle);
|
||||||
close(flat->handle);
|
close(flat->handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1365,9 +1365,9 @@ void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
|||||||
mError = NO_ERROR;
|
mError = NO_ERROR;
|
||||||
mData = const_cast<uint8_t*>(data);
|
mData = const_cast<uint8_t*>(data);
|
||||||
mDataSize = mDataCapacity = dataSize;
|
mDataSize = mDataCapacity = dataSize;
|
||||||
//ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)\n", this, mDataSize, getpid());
|
//ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)", this, mDataSize, getpid());
|
||||||
mDataPos = 0;
|
mDataPos = 0;
|
||||||
ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("setDataReference Setting data pos of %p to %zu", this, mDataPos);
|
||||||
mObjects = const_cast<binder_size_t*>(objects);
|
mObjects = const_cast<binder_size_t*>(objects);
|
||||||
mObjectsSize = mObjectsCapacity = objectsCount;
|
mObjectsSize = mObjectsCapacity = objectsCount;
|
||||||
mNextObjectHint = 0;
|
mNextObjectHint = 0;
|
||||||
@ -1389,7 +1389,7 @@ void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
|||||||
void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
|
void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
|
||||||
{
|
{
|
||||||
to << "Parcel(";
|
to << "Parcel(";
|
||||||
|
|
||||||
if (errorCheck() != NO_ERROR) {
|
if (errorCheck() != NO_ERROR) {
|
||||||
const status_t err = errorCheck();
|
const status_t err = errorCheck();
|
||||||
to << "Error: " << (void*)(intptr_t)err << " \"" << strerror(-err) << "\"";
|
to << "Error: " << (void*)(intptr_t)err << " \"" << strerror(-err) << "\"";
|
||||||
@ -1408,7 +1408,7 @@ void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
|
|||||||
} else {
|
} else {
|
||||||
to << "NULL";
|
to << "NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
to << ")";
|
to << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1449,7 +1449,7 @@ void Parcel::freeData()
|
|||||||
void Parcel::freeDataNoInit()
|
void Parcel::freeDataNoInit()
|
||||||
{
|
{
|
||||||
if (mOwner) {
|
if (mOwner) {
|
||||||
//ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
|
//ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
|
||||||
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
||||||
} else {
|
} else {
|
||||||
releaseObjects();
|
releaseObjects();
|
||||||
@ -1472,24 +1472,24 @@ status_t Parcel::restartWrite(size_t desired)
|
|||||||
freeData();
|
freeData();
|
||||||
return continueWrite(desired);
|
return continueWrite(desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* data = (uint8_t*)realloc(mData, desired);
|
uint8_t* data = (uint8_t*)realloc(mData, desired);
|
||||||
if (!data && desired > mDataCapacity) {
|
if (!data && desired > mDataCapacity) {
|
||||||
mError = NO_MEMORY;
|
mError = NO_MEMORY;
|
||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseObjects();
|
releaseObjects();
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mData = data;
|
mData = data;
|
||||||
mDataCapacity = desired;
|
mDataCapacity = desired;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDataSize = mDataPos = 0;
|
mDataSize = mDataPos = 0;
|
||||||
ALOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("restartWrite Setting data size of %p to %zu", this, mDataSize);
|
||||||
ALOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("restartWrite Setting data pos of %p to %zu", this, mDataPos);
|
||||||
|
|
||||||
free(mObjects);
|
free(mObjects);
|
||||||
mObjects = NULL;
|
mObjects = NULL;
|
||||||
mObjectsSize = mObjectsCapacity = 0;
|
mObjectsSize = mObjectsCapacity = 0;
|
||||||
@ -1497,7 +1497,7 @@ status_t Parcel::restartWrite(size_t desired)
|
|||||||
mHasFds = false;
|
mHasFds = false;
|
||||||
mFdsKnown = true;
|
mFdsKnown = true;
|
||||||
mAllowFds = true;
|
mAllowFds = true;
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1517,7 +1517,7 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOwner) {
|
if (mOwner) {
|
||||||
// If the size is going to zero, just release the owner's data.
|
// If the size is going to zero, just release the owner's data.
|
||||||
if (desired == 0) {
|
if (desired == 0) {
|
||||||
@ -1533,7 +1533,7 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
binder_size_t* objects = NULL;
|
binder_size_t* objects = NULL;
|
||||||
|
|
||||||
if (objectsSize) {
|
if (objectsSize) {
|
||||||
objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
|
objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
|
||||||
if (!objects) {
|
if (!objects) {
|
||||||
@ -1550,21 +1550,21 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
acquireObjects();
|
acquireObjects();
|
||||||
mObjectsSize = oldObjectsSize;
|
mObjectsSize = oldObjectsSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mData) {
|
if (mData) {
|
||||||
memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
|
memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
|
||||||
}
|
}
|
||||||
if (objects && mObjects) {
|
if (objects && mObjects) {
|
||||||
memcpy(objects, mObjects, objectsSize*sizeof(binder_size_t));
|
memcpy(objects, mObjects, objectsSize*sizeof(binder_size_t));
|
||||||
}
|
}
|
||||||
//ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
|
//ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
|
||||||
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
||||||
mOwner = NULL;
|
mOwner = NULL;
|
||||||
|
|
||||||
mData = data;
|
mData = data;
|
||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
mDataSize = (mDataSize < desired) ? mDataSize : desired;
|
mDataSize = (mDataSize < desired) ? mDataSize : desired;
|
||||||
ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
|
||||||
mDataCapacity = desired;
|
mDataCapacity = desired;
|
||||||
mObjectsSize = mObjectsCapacity = objectsSize;
|
mObjectsSize = mObjectsCapacity = objectsSize;
|
||||||
mNextObjectHint = 0;
|
mNextObjectHint = 0;
|
||||||
@ -1604,14 +1604,14 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
} else {
|
} else {
|
||||||
if (mDataSize > desired) {
|
if (mDataSize > desired) {
|
||||||
mDataSize = desired;
|
mDataSize = desired;
|
||||||
ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
|
||||||
}
|
}
|
||||||
if (mDataPos > desired) {
|
if (mDataPos > desired) {
|
||||||
mDataPos = desired;
|
mDataPos = desired;
|
||||||
ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// This is the first data. Easy!
|
// This is the first data. Easy!
|
||||||
uint8_t* data = (uint8_t*)malloc(desired);
|
uint8_t* data = (uint8_t*)malloc(desired);
|
||||||
@ -1624,11 +1624,11 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
&& mObjectsCapacity == 0)) {
|
&& mObjectsCapacity == 0)) {
|
||||||
ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired);
|
ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
mData = data;
|
mData = data;
|
||||||
mDataSize = mDataPos = 0;
|
mDataSize = mDataPos = 0;
|
||||||
ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
|
||||||
ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
|
||||||
mDataCapacity = desired;
|
mDataCapacity = desired;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1642,8 +1642,8 @@ void Parcel::initState()
|
|||||||
mDataSize = 0;
|
mDataSize = 0;
|
||||||
mDataCapacity = 0;
|
mDataCapacity = 0;
|
||||||
mDataPos = 0;
|
mDataPos = 0;
|
||||||
ALOGV("initState Setting data size of %p to %d\n", this, mDataSize);
|
ALOGV("initState Setting data size of %p to %zu", this, mDataSize);
|
||||||
ALOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("initState Setting data pos of %p to %zu", this, mDataPos);
|
||||||
mObjects = NULL;
|
mObjects = NULL;
|
||||||
mObjectsSize = 0;
|
mObjectsSize = 0;
|
||||||
mObjectsCapacity = 0;
|
mObjectsCapacity = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user