Merge "androidfw: resolve 64-bit build issues"

This commit is contained in:
Mark Salyzyn
2014-03-19 19:36:51 +00:00
committed by Gerrit Code Review
6 changed files with 98 additions and 98 deletions

View File

@@ -72,7 +72,7 @@ String8 Asset::getAssetAllocations()
} }
cur = cur->mNext; cur = cur->mNext;
} }
return res; return res;
} }
@@ -84,18 +84,18 @@ Asset::Asset(void)
mNext = mPrev = NULL; mNext = mPrev = NULL;
if (gTail == NULL) { if (gTail == NULL) {
gHead = gTail = this; gHead = gTail = this;
} else { } else {
mPrev = gTail; mPrev = gTail;
gTail->mNext = this; gTail->mNext = this;
gTail = this; gTail = this;
} }
//ALOGI("Creating Asset %p #%d\n", this, gCount); //ALOGI("Creating Asset %p #%d\n", this, gCount);
} }
Asset::~Asset(void) Asset::~Asset(void)
{ {
AutoMutex _l(gAssetLock); AutoMutex _l(gAssetLock);
gCount--; gCount--;
if (gHead == this) { if (gHead == this) {
gHead = mNext; gHead = mNext;
} }
@@ -409,7 +409,7 @@ status_t _FileAsset::openChunk(const char* fileName, int fd, off64_t offset, siz
} }
mFileName = fileName != NULL ? strdup(fileName) : NULL; mFileName = fileName != NULL ? strdup(fileName) : NULL;
return NO_ERROR; return NO_ERROR;
} }
@@ -538,7 +538,7 @@ void _FileAsset::close(void)
free(mFileName); free(mFileName);
mFileName = NULL; mFileName = NULL;
} }
if (mFp != NULL) { if (mFp != NULL) {
// can only be NULL when called from destructor // can only be NULL when called from destructor
// (otherwise we would never return this object) // (otherwise we would never return this object)

View File

@@ -289,7 +289,7 @@ BackupDataReader::ReadNextHeader(bool* done, int* type)
(int)(m_pos - sizeof(m_header)), (int)m_header.type); (int)(m_pos - sizeof(m_header)), (int)m_header.type);
m_status = EINVAL; m_status = EINVAL;
} }
return m_status; return m_status;
} }

View File

@@ -568,8 +568,8 @@ int write_tarfile(const String8& packageName, const String8& domain,
// [ 108 : 8 ] uid -- ignored in Android format; uids are remapped at restore time // [ 108 : 8 ] uid -- ignored in Android format; uids are remapped at restore time
// [ 116 : 8 ] gid -- ignored in Android format // [ 116 : 8 ] gid -- ignored in Android format
snprintf(buf + 108, 8, "0%lo", s.st_uid); snprintf(buf + 108, 8, "0%lo", (unsigned long)s.st_uid);
snprintf(buf + 116, 8, "0%lo", s.st_gid); snprintf(buf + 116, 8, "0%lo", (unsigned long)s.st_gid);
// [ 124 : 12 ] file size in bytes // [ 124 : 12 ] file size in bytes
if (s.st_size > 077777777777LL) { if (s.st_size > 077777777777LL) {
@@ -778,7 +778,7 @@ RestoreHelperBase::WriteFile(const String8& filename, BackupDataReader* in)
ALOGW("Could not open file %s -- %s", filename.string(), strerror(errno)); ALOGW("Could not open file %s -- %s", filename.string(), strerror(errno));
return errno; return errno;
} }
while ((amt = in->ReadEntityData(buf, RESTORE_BUF_SIZE)) > 0) { while ((amt = in->ReadEntityData(buf, RESTORE_BUF_SIZE)) > 0) {
err = write(fd, buf, amt); err = write(fd, buf, amt);
if (err != amt) { if (err != amt) {

View File

@@ -1,16 +1,16 @@
/* /*
* Copyright (C) 2006-2007 The Android Open Source Project * Copyright (C) 2006-2007 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */

View File

@@ -1266,7 +1266,7 @@ ResXMLParser::event_code_t ResXMLParser::nextNode()
const ResXMLTree_node* next = (const ResXMLTree_node*) const ResXMLTree_node* next = (const ResXMLTree_node*)
(((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size)); (((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size));
//ALOGW("Next node: prev=%p, next=%p\n", mCurNode, next); //ALOGW("Next node: prev=%p, next=%p\n", mCurNode, next);
if (((const uint8_t*)next) >= mTree.mDataEnd) { if (((const uint8_t*)next) >= mTree.mDataEnd) {
mCurNode = NULL; mCurNode = NULL;
return (mEventCode=END_DOCUMENT); return (mEventCode=END_DOCUMENT);
@@ -1303,7 +1303,7 @@ ResXMLParser::event_code_t ResXMLParser::nextNode()
(int)(((const uint8_t*)next)-((const uint8_t*)mTree.mHeader))); (int)(((const uint8_t*)next)-((const uint8_t*)mTree.mHeader)));
continue; continue;
} }
if ((totalSize-headerSize) < minExtSize) { if ((totalSize-headerSize) < minExtSize) {
ALOGW("Bad XML block: header type 0x%x in node at 0x%x has size %d, need %d\n", ALOGW("Bad XML block: header type 0x%x in node at 0x%x has size %d, need %d\n",
(int)dtohs(next->header.type), (int)dtohs(next->header.type),
@@ -1311,10 +1311,10 @@ ResXMLParser::event_code_t ResXMLParser::nextNode()
(int)(totalSize-headerSize), (int)minExtSize); (int)(totalSize-headerSize), (int)minExtSize);
return (mEventCode=BAD_DOCUMENT); return (mEventCode=BAD_DOCUMENT);
} }
//printf("CurNode=%p, CurExt=%p, headerSize=%d, minExtSize=%d\n", //printf("CurNode=%p, CurExt=%p, headerSize=%d, minExtSize=%d\n",
// mCurNode, mCurExt, headerSize, minExtSize); // mCurNode, mCurExt, headerSize, minExtSize);
return eventCode; return eventCode;
} while (true); } while (true);
} }
@@ -2717,7 +2717,7 @@ struct ResTable::Package
delete types[i]; delete types[i];
} }
} }
ResTable* const owner; ResTable* const owner;
const Header* const header; const Header* const header;
const ResTable_package* const package; const ResTable_package* const package;
@@ -2725,7 +2725,7 @@ struct ResTable::Package
ResStringPool typeStrings; ResStringPool typeStrings;
ResStringPool keyStrings; ResStringPool keyStrings;
const Type* getType(size_t idx) const { const Type* getType(size_t idx) const {
return idx < types.size() ? types[idx] : NULL; return idx < types.size() ? types[idx] : NULL;
} }
@@ -2775,18 +2775,18 @@ struct ResTable::PackageGroup
bags = NULL; bags = NULL;
} }
} }
ResTable* const owner; ResTable* const owner;
String16 const name; String16 const name;
uint32_t const id; uint32_t const id;
Vector<Package*> packages; Vector<Package*> packages;
// This is for finding typeStrings and other common package stuff. // This is for finding typeStrings and other common package stuff.
Package* basePackage; Package* basePackage;
// For quick access. // For quick access.
size_t typeCount; size_t typeCount;
// Computed attribute bags, first indexed by the type and second // Computed attribute bags, first indexed by the type and second
// by the entry in that type. // by the entry in that type.
bag_set*** bags; bag_set*** bags;
@@ -2935,7 +2935,7 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force)
//ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this); //ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this);
//dumpToLog(); //dumpToLog();
return NO_ERROR; return NO_ERROR;
} }
@@ -2944,7 +2944,7 @@ status_t ResTable::Theme::setTo(const Theme& other)
//ALOGI("Setting theme %p from theme %p...\n", this, &other); //ALOGI("Setting theme %p from theme %p...\n", this, &other);
//dumpToLog(); //dumpToLog();
//other.dumpToLog(); //other.dumpToLog();
if (&mTable == &other.mTable) { if (&mTable == &other.mTable) {
for (size_t i=0; i<Res_MAXPACKAGE; i++) { for (size_t i=0; i<Res_MAXPACKAGE; i++) {
if (mPackages[i] != NULL) { if (mPackages[i] != NULL) {
@@ -2974,7 +2974,7 @@ status_t ResTable::Theme::setTo(const Theme& other)
//ALOGI("Final theme:"); //ALOGI("Final theme:");
//dumpToLog(); //dumpToLog();
return NO_ERROR; return NO_ERROR;
} }
@@ -2984,7 +2984,7 @@ ssize_t ResTable::Theme::getAttribute(uint32_t resID, Res_value* outValue,
int cnt = 20; int cnt = 20;
if (outTypeSpecFlags != NULL) *outTypeSpecFlags = 0; if (outTypeSpecFlags != NULL) *outTypeSpecFlags = 0;
do { do {
const ssize_t p = mTable.getResourcePackageIndex(resID); const ssize_t p = mTable.getResourcePackageIndex(resID);
const uint32_t t = Res_GETTYPE(resID); const uint32_t t = Res_GETTYPE(resID);
@@ -3058,12 +3058,12 @@ void ResTable::Theme::dumpToLog() const
for (size_t i=0; i<Res_MAXPACKAGE; i++) { for (size_t i=0; i<Res_MAXPACKAGE; i++) {
package_info* pi = mPackages[i]; package_info* pi = mPackages[i];
if (pi == NULL) continue; if (pi == NULL) continue;
ALOGI(" Package #0x%02x:\n", (int)(i+1)); ALOGI(" Package #0x%02x:\n", (int)(i+1));
for (size_t j=0; j<pi->numTypes; j++) { for (size_t j=0; j<pi->numTypes; j++) {
type_info& ti = pi->types[j]; type_info& ti = pi->types[j];
if (ti.numEntries == 0) continue; if (ti.numEntries == 0) continue;
ALOGI(" Type #0x%02x:\n", (int)(j+1)); ALOGI(" Type #0x%02x:\n", (int)(j+1));
for (size_t k=0; k<ti.numEntries; k++) { for (size_t k=0; k<ti.numEntries; k++) {
theme_entry& te = ti.entries[k]; theme_entry& te = ti.entries[k];
@@ -3125,11 +3125,11 @@ status_t ResTable::add(Asset* asset, const int32_t cookie, bool copyData, const
status_t ResTable::add(ResTable* src) status_t ResTable::add(ResTable* src)
{ {
mError = src->mError; mError = src->mError;
for (size_t i=0; i<src->mHeaders.size(); i++) { for (size_t i=0; i<src->mHeaders.size(); i++) {
mHeaders.add(src->mHeaders[i]); mHeaders.add(src->mHeaders[i]);
} }
for (size_t i=0; i<src->mPackageGroups.size(); i++) { for (size_t i=0; i<src->mPackageGroups.size(); i++) {
PackageGroup* srcPg = src->mPackageGroups[i]; PackageGroup* srcPg = src->mPackageGroups[i];
PackageGroup* pg = new PackageGroup(this, srcPg->name, srcPg->id); PackageGroup* pg = new PackageGroup(this, srcPg->name, srcPg->id);
@@ -3140,14 +3140,14 @@ status_t ResTable::add(ResTable* src)
pg->typeCount = srcPg->typeCount; pg->typeCount = srcPg->typeCount;
mPackageGroups.add(pg); mPackageGroups.add(pg);
} }
memcpy(mPackageMap, src->mPackageMap, sizeof(mPackageMap)); memcpy(mPackageMap, src->mPackageMap, sizeof(mPackageMap));
return mError; return mError;
} }
status_t ResTable::addInternal(const void* data, size_t size, const int32_t cookie, status_t ResTable::addInternal(const void* data, size_t size, const int32_t cookie,
Asset* asset, bool copyData, const Asset* idmap) Asset* /*asset*/, bool copyData, const Asset* idmap)
{ {
if (!data) return NO_ERROR; if (!data) return NO_ERROR;
Header* header = new Header(this); Header* header = new Header(this);
@@ -3171,7 +3171,7 @@ status_t ResTable::addInternal(const void* data, size_t size, const int32_t cook
LOAD_TABLE_NOISY( LOAD_TABLE_NOISY(
ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, asset=%p, copy=%d " ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, asset=%p, copy=%d "
"idmap=%p\n", data, size, cookie, asset, copyData, idmap)); "idmap=%p\n", data, size, cookie, asset, copyData, idmap));
if (copyData || notDeviceEndian) { if (copyData || notDeviceEndian) {
header->ownedData = malloc(size); header->ownedData = malloc(size);
if (header->ownedData == NULL) { if (header->ownedData == NULL) {
@@ -3503,7 +3503,7 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag
// are identical (diff == 0), or overlay packages will not take effect. // are identical (diff == 0), or overlay packages will not take effect.
continue; continue;
} }
bestItem = thisConfig; bestItem = thisConfig;
bestValue = item; bestValue = item;
bestPackage = package; bestPackage = package;
@@ -3573,7 +3573,7 @@ ssize_t ResTable::resolveReference(Res_value* value, ssize_t blockIndex,
const char16_t* ResTable::valueToString( const char16_t* ResTable::valueToString(
const Res_value* value, size_t stringBlock, const Res_value* value, size_t stringBlock,
char16_t tmpBuffer[TMP_BUFFER_SIZE], size_t* outLen) char16_t /*tmpBuffer*/ [TMP_BUFFER_SIZE], size_t* outLen)
{ {
if (!value) { if (!value) {
return NULL; return NULL;
@@ -3596,7 +3596,7 @@ ssize_t ResTable::lockBag(uint32_t resID, const bag_entry** outBag) const
return err; return err;
} }
void ResTable::unlockBag(const bag_entry* bag) const void ResTable::unlockBag(const bag_entry* /*bag*/) const
{ {
//printf("<<< unlockBag %p\n", this); //printf("<<< unlockBag %p\n", this);
mLock.unlock(); mLock.unlock();
@@ -3697,7 +3697,7 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
bag_set* set = NULL; bag_set* set = NULL;
TABLE_NOISY(ALOGI("Building bag: %p\n", (void*)resID)); TABLE_NOISY(ALOGI("Building bag: %p\n", (void*)resID));
ResTable_config bestConfig; ResTable_config bestConfig;
memset(&bestConfig, 0, sizeof(bestConfig)); memset(&bestConfig, 0, sizeof(bestConfig));
@@ -3763,7 +3763,7 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
? dtohl(((const ResTable_map_entry*)entry)->parent.ident) : 0; ? dtohl(((const ResTable_map_entry*)entry)->parent.ident) : 0;
const uint32_t count = entrySize >= sizeof(ResTable_map_entry) const uint32_t count = entrySize >= sizeof(ResTable_map_entry)
? dtohl(((const ResTable_map_entry*)entry)->count) : 0; ? dtohl(((const ResTable_map_entry*)entry)->count) : 0;
size_t N = count; size_t N = count;
TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n", TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n",
@@ -3807,7 +3807,7 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
} else { } else {
set->typeSpecFlags = -1; set->typeSpecFlags = -1;
} }
// Now merge in the new attributes... // Now merge in the new attributes...
ssize_t curOff = offset; ssize_t curOff = offset;
const ResTable_map* map; const ResTable_map* map;
@@ -4070,7 +4070,7 @@ nope:
TABLE_NOISY(printf("Expected type structure not found in package %s for idnex %d\n", TABLE_NOISY(printf("Expected type structure not found in package %s for idnex %d\n",
String8(group->name).string(), ti)); String8(group->name).string(), ti));
} }
size_t NTC = typeConfigs->configs.size(); size_t NTC = typeConfigs->configs.size();
for (size_t tci=0; tci<NTC; tci++) { for (size_t tci=0; tci<NTC; tci++) {
const ResTable_type* const ty = typeConfigs->configs[tci]; const ResTable_type* const ty = typeConfigs->configs[tci];
@@ -4086,9 +4086,9 @@ nope:
if (offset == ResTable_type::NO_ENTRY) { if (offset == ResTable_type::NO_ENTRY) {
continue; continue;
} }
offset += typeOffset; offset += typeOffset;
if (offset > (dtohl(ty->header.size)-sizeof(ResTable_entry))) { if (offset > (dtohl(ty->header.size)-sizeof(ResTable_entry))) {
ALOGW("ResTable_entry at %d is beyond type chunk data %d", ALOGW("ResTable_entry at %d is beyond type chunk data %d",
offset, dtohl(ty->header.size)); offset, dtohl(ty->header.size));
@@ -4102,7 +4102,7 @@ nope:
String8(name, nameLen).string()); String8(name, nameLen).string());
return 0; return 0;
} }
const ResTable_entry* const entry = (const ResTable_entry*) const ResTable_entry* const entry = (const ResTable_entry*)
(((const uint8_t*)ty) + offset); (((const uint8_t*)ty) + offset);
if (dtohs(entry->size) < sizeof(*entry)) { if (dtohs(entry->size) < sizeof(*entry)) {
@@ -4259,7 +4259,7 @@ static bool parse_unit(const char* str, Res_value* outValue,
if (*realEnd != 0) { if (*realEnd != 0) {
return false; return false;
} }
const unit_entry* cur = unitNames; const unit_entry* cur = unitNames;
while (cur->name) { while (cur->name) {
if (len == cur->len && strncmp(cur->name, str, len) == 0) { if (len == cur->len && strncmp(cur->name, str, len) == 0) {
@@ -4410,7 +4410,7 @@ bool ResTable::stringToFloat(const char16_t* s, size_t len, Res_value* outValue)
if (neg) { if (neg) {
mantissa = (-mantissa) & Res_value::COMPLEX_MANTISSA_MASK; mantissa = (-mantissa) & Res_value::COMPLEX_MANTISSA_MASK;
} }
outValue->data |= outValue->data |=
(radix<<Res_value::COMPLEX_RADIX_SHIFT) (radix<<Res_value::COMPLEX_RADIX_SHIFT)
| (mantissa<<Res_value::COMPLEX_MANTISSA_SHIFT); | (mantissa<<Res_value::COMPLEX_MANTISSA_SHIFT);
//printf("Input value: %f 0x%016Lx, mult: %f, radix: %d, shift: %d, final: 0x%08x\n", //printf("Input value: %f 0x%016Lx, mult: %f, radix: %d, shift: %d, final: 0x%08x\n",
@@ -4523,7 +4523,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
// Note: we don't check attrType here because the reference can // Note: we don't check attrType here because the reference can
// be to any other type; we just need to count on the client making // be to any other type; we just need to count on the client making
// sure the referenced type is correct. // sure the referenced type is correct.
//printf("Looking up ref: %s\n", String8(s, len).string()); //printf("Looking up ref: %s\n", String8(s, len).string());
// It's a reference! // It's a reference!
@@ -4610,7 +4610,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
} }
} }
} }
if (*s == '#') { if (*s == '#') {
// It's a color! Convert to an integer of the form 0xaarrggbb. // It's a color! Convert to an integer of the form 0xaarrggbb.
uint32_t color = 0; uint32_t color = 0;
@@ -4710,7 +4710,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
// String8(package).string(), String8(type).string(), // String8(package).string(), String8(type).string(),
// String8(name).string()); // String8(name).string());
uint32_t specFlags = 0; uint32_t specFlags = 0;
uint32_t rid = uint32_t rid =
identifierForName(name.string(), name.size(), identifierForName(name.string(), name.size(),
type.string(), type.size(), type.string(), type.size(),
package.string(), package.size(), &specFlags); package.string(), package.size(), &specFlags);
@@ -4875,7 +4875,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
return true; return true;
} }
} }
} }
bag++; bag++;
cnt--; cnt--;
@@ -5240,43 +5240,43 @@ ssize_t ResTable::getEntry(
entryIndex, (int)allTypes->entryCount); entryIndex, (int)allTypes->entryCount);
return BAD_TYPE; return BAD_TYPE;
} }
const ResTable_type* type = NULL; const ResTable_type* type = NULL;
uint32_t offset = ResTable_type::NO_ENTRY; uint32_t offset = ResTable_type::NO_ENTRY;
ResTable_config bestConfig; ResTable_config bestConfig;
memset(&bestConfig, 0, sizeof(bestConfig)); // make the compiler shut up memset(&bestConfig, 0, sizeof(bestConfig)); // make the compiler shut up
const size_t NT = allTypes->configs.size(); const size_t NT = allTypes->configs.size();
for (size_t i=0; i<NT; i++) { for (size_t i=0; i<NT; i++) {
const ResTable_type* const thisType = allTypes->configs[i]; const ResTable_type* const thisType = allTypes->configs[i];
if (thisType == NULL) continue; if (thisType == NULL) continue;
ResTable_config thisConfig; ResTable_config thisConfig;
thisConfig.copyFromDtoH(thisType->config); thisConfig.copyFromDtoH(thisType->config);
TABLE_GETENTRY(ALOGI("Match entry 0x%x in type 0x%x (sz 0x%x): %s\n", TABLE_GETENTRY(ALOGI("Match entry 0x%x in type 0x%x (sz 0x%x): %s\n",
entryIndex, typeIndex+1, dtohl(thisType->config.size), entryIndex, typeIndex+1, dtohl(thisType->config.size),
thisConfig.toString().string())); thisConfig.toString().string()));
// Check to make sure this one is valid for the current parameters. // Check to make sure this one is valid for the current parameters.
if (config && !thisConfig.match(*config)) { if (config && !thisConfig.match(*config)) {
TABLE_GETENTRY(ALOGI("Does not match config!\n")); TABLE_GETENTRY(ALOGI("Does not match config!\n"));
continue; continue;
} }
// Check if there is the desired entry in this type. // Check if there is the desired entry in this type.
const uint8_t* const end = ((const uint8_t*)thisType) const uint8_t* const end = ((const uint8_t*)thisType)
+ dtohl(thisType->header.size); + dtohl(thisType->header.size);
const uint32_t* const eindex = (const uint32_t*) const uint32_t* const eindex = (const uint32_t*)
(((const uint8_t*)thisType) + dtohs(thisType->header.headerSize)); (((const uint8_t*)thisType) + dtohs(thisType->header.headerSize));
uint32_t thisOffset = dtohl(eindex[entryIndex]); uint32_t thisOffset = dtohl(eindex[entryIndex]);
if (thisOffset == ResTable_type::NO_ENTRY) { if (thisOffset == ResTable_type::NO_ENTRY) {
TABLE_GETENTRY(ALOGI("Skipping because it is not defined!\n")); TABLE_GETENTRY(ALOGI("Skipping because it is not defined!\n"));
continue; continue;
} }
if (type != NULL) { if (type != NULL) {
// Check if this one is less specific than the last found. If so, // Check if this one is less specific than the last found. If so,
// we will skip it. We check starting with things we most care // we will skip it. We check starting with things we most care
@@ -5286,19 +5286,19 @@ ssize_t ResTable::getEntry(
continue; continue;
} }
} }
type = thisType; type = thisType;
offset = thisOffset; offset = thisOffset;
bestConfig = thisConfig; bestConfig = thisConfig;
TABLE_GETENTRY(ALOGI("Best entry so far -- using it!\n")); TABLE_GETENTRY(ALOGI("Best entry so far -- using it!\n"));
if (!config) break; if (!config) break;
} }
if (type == NULL) { if (type == NULL) {
TABLE_GETENTRY(ALOGI("No value found for requested entry!\n")); TABLE_GETENTRY(ALOGI("No value found for requested entry!\n"));
return BAD_INDEX; return BAD_INDEX;
} }
offset += dtohl(type->entriesStart); offset += dtohl(type->entriesStart);
TABLE_NOISY(aout << "Looking in resource table " << package->header->header TABLE_NOISY(aout << "Looking in resource table " << package->header->header
<< ", typeOff=" << ", typeOff="
@@ -5363,7 +5363,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
dtohl(pkg->keyStrings)); dtohl(pkg->keyStrings));
return (mError=BAD_TYPE); return (mError=BAD_TYPE);
} }
Package* package = NULL; Package* package = NULL;
PackageGroup* group = NULL; PackageGroup* group = NULL;
uint32_t id = idmap_id != 0 ? idmap_id : dtohl(pkg->id); uint32_t id = idmap_id != 0 ? idmap_id : dtohl(pkg->id);
@@ -5372,12 +5372,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
// always loaded alongside their idmaps, but during idmap creation // always loaded alongside their idmaps, but during idmap creation
// the package is temporarily loaded by itself. // the package is temporarily loaded by itself.
if (id < 256) { if (id < 256) {
package = new Package(this, header, pkg); package = new Package(this, header, pkg);
if (package == NULL) { if (package == NULL) {
return (mError=NO_MEMORY); return (mError=NO_MEMORY);
} }
size_t idx = mPackageMap[id]; size_t idx = mPackageMap[id];
if (idx == 0) { if (idx == 0) {
idx = mPackageGroups.size()+1; idx = mPackageGroups.size()+1;
@@ -5411,7 +5411,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
return (mError=err); return (mError=err);
} }
group->basePackage = package; group->basePackage = package;
mPackageMap[id] = (uint8_t)idx; mPackageMap[id] = (uint8_t)idx;
} else { } else {
group = mPackageGroups.itemAt(idx-1); group = mPackageGroups.itemAt(idx-1);
@@ -5428,10 +5428,10 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
return NO_ERROR; return NO_ERROR;
} }
// Iterate through all chunks. // Iterate through all chunks.
size_t curPackage = 0; size_t curPackage = 0;
const ResChunk_header* chunk = const ResChunk_header* chunk =
(const ResChunk_header*)(((const uint8_t*)pkg) (const ResChunk_header*)(((const uint8_t*)pkg)
+ dtohs(pkg->header.headerSize)); + dtohs(pkg->header.headerSize));
@@ -5450,9 +5450,9 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
if (err != NO_ERROR) { if (err != NO_ERROR) {
return (mError=err); return (mError=err);
} }
const size_t typeSpecSize = dtohl(typeSpec->header.size); const size_t typeSpecSize = dtohl(typeSpec->header.size);
LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n", LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n",
(void*)(base-(const uint8_t*)chunk), (void*)(base-(const uint8_t*)chunk),
dtohs(typeSpec->header.type), dtohs(typeSpec->header.type),
@@ -5468,12 +5468,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
(void*)typeSpecSize); (void*)typeSpecSize);
return (mError=BAD_TYPE); return (mError=BAD_TYPE);
} }
if (typeSpec->id == 0) { if (typeSpec->id == 0) {
ALOGW("ResTable_type has an id of 0."); ALOGW("ResTable_type has an id of 0.");
return (mError=BAD_TYPE); return (mError=BAD_TYPE);
} }
while (package->types.size() < typeSpec->id) { while (package->types.size() < typeSpec->id) {
package->types.add(NULL); package->types.add(NULL);
} }
@@ -5489,7 +5489,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
t->typeSpecFlags = (const uint32_t*)( t->typeSpecFlags = (const uint32_t*)(
((const uint8_t*)typeSpec) + dtohs(typeSpec->header.headerSize)); ((const uint8_t*)typeSpec) + dtohs(typeSpec->header.headerSize));
t->typeSpec = typeSpec; t->typeSpec = typeSpec;
} else if (ctype == RES_TABLE_TYPE_TYPE) { } else if (ctype == RES_TABLE_TYPE_TYPE) {
const ResTable_type* type = (const ResTable_type*)(chunk); const ResTable_type* type = (const ResTable_type*)(chunk);
err = validate_chunk(&type->header, sizeof(*type)-sizeof(ResTable_config)+4, err = validate_chunk(&type->header, sizeof(*type)-sizeof(ResTable_config)+4,
@@ -5497,9 +5497,9 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
if (err != NO_ERROR) { if (err != NO_ERROR) {
return (mError=err); return (mError=err);
} }
const uint32_t typeSize = dtohl(type->header.size); const uint32_t typeSize = dtohl(type->header.size);
LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n", LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n",
(void*)(base-(const uint8_t*)chunk), (void*)(base-(const uint8_t*)chunk),
dtohs(type->header.type), dtohs(type->header.type),
@@ -5523,7 +5523,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
ALOGW("ResTable_type has an id of 0."); ALOGW("ResTable_type has an id of 0.");
return (mError=BAD_TYPE); return (mError=BAD_TYPE);
} }
while (package->types.size() < type->id) { while (package->types.size() < type->id) {
package->types.add(NULL); package->types.add(NULL);
} }
@@ -5536,7 +5536,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
(int)dtohl(type->entryCount), (int)t->entryCount); (int)dtohl(type->entryCount), (int)t->entryCount);
return (mError=BAD_TYPE); return (mError=BAD_TYPE);
} }
TABLE_GETENTRY( TABLE_GETENTRY(
ResTable_config thisConfig; ResTable_config thisConfig;
thisConfig.copyFromDtoH(type->config); thisConfig.copyFromDtoH(type->config);
@@ -5557,7 +5557,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
if (group->typeCount == 0) { if (group->typeCount == 0) {
group->typeCount = package->types.size(); group->typeCount = package->types.size();
} }
return NO_ERROR; return NO_ERROR;
} }
@@ -5757,7 +5757,7 @@ static void print_complex(uint32_t complex, bool isFraction)
* RADIX_MULTS[(complex>>Res_value::COMPLEX_RADIX_SHIFT) * RADIX_MULTS[(complex>>Res_value::COMPLEX_RADIX_SHIFT)
& Res_value::COMPLEX_RADIX_MASK]; & Res_value::COMPLEX_RADIX_MASK];
printf("%f", value); printf("%f", value);
if (!isFraction) { if (!isFraction) {
switch ((complex>>Res_value::COMPLEX_UNIT_SHIFT)&Res_value::COMPLEX_UNIT_MASK) { switch ((complex>>Res_value::COMPLEX_UNIT_SHIFT)&Res_value::COMPLEX_UNIT_MASK) {
case Res_value::COMPLEX_UNIT_PX: printf("px"); break; case Res_value::COMPLEX_UNIT_PX: printf("px"); break;
@@ -5832,7 +5832,7 @@ void ResTable::print_value(const Package* pkg, const Res_value& value) const
} else { } else {
printf("(string) null\n"); printf("(string) null\n");
} }
} }
} else if (value.dataType == Res_value::TYPE_FLOAT) { } else if (value.dataType == Res_value::TYPE_FLOAT) {
printf("(float) %g\n", *(const float*)&value.data); printf("(float) %g\n", *(const float*)&value.data);
} else if (value.dataType == Res_value::TYPE_DIMENSION) { } else if (value.dataType == Res_value::TYPE_DIMENSION) {
@@ -5875,7 +5875,7 @@ void ResTable::print(bool inclValues) const
printf("Package Group %d id=%d packageCount=%d name=%s\n", printf("Package Group %d id=%d packageCount=%d name=%s\n",
(int)pgIndex, pg->id, (int)pg->packages.size(), (int)pgIndex, pg->id, (int)pg->packages.size(),
String8(pg->name).string()); String8(pg->name).string());
size_t pkgCount = pg->packages.size(); size_t pkgCount = pg->packages.size();
for (size_t pkgIndex=0; pkgIndex<pkgCount; pkgIndex++) { for (size_t pkgIndex=0; pkgIndex<pkgCount; pkgIndex++) {
const Package* pkg = pg->packages[pkgIndex]; const Package* pkg = pg->packages[pkgIndex];
@@ -5942,17 +5942,17 @@ void ResTable::print(bool inclValues) const
continue; continue;
} }
for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) { for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) {
const uint8_t* const end = ((const uint8_t*)type) const uint8_t* const end = ((const uint8_t*)type)
+ dtohl(type->header.size); + dtohl(type->header.size);
const uint32_t* const eindex = (const uint32_t*) const uint32_t* const eindex = (const uint32_t*)
(((const uint8_t*)type) + dtohs(type->header.headerSize)); (((const uint8_t*)type) + dtohs(type->header.headerSize));
uint32_t thisOffset = dtohl(eindex[entryIndex]); uint32_t thisOffset = dtohl(eindex[entryIndex]);
if (thisOffset == ResTable_type::NO_ENTRY) { if (thisOffset == ResTable_type::NO_ENTRY) {
continue; continue;
} }
uint32_t resID = (0xff000000 & ((pkg->package->id)<<24)) uint32_t resID = (0xff000000 & ((pkg->package->id)<<24))
| (0x00ff0000 & ((typeIndex+1)<<16)) | (0x00ff0000 & ((typeIndex+1)<<16))
| (0x0000ffff & (entryIndex)); | (0x0000ffff & (entryIndex));
@@ -5985,7 +5985,7 @@ void ResTable::print(bool inclValues) const
entriesStart, thisOffset, typeSize); entriesStart, thisOffset, typeSize);
continue; continue;
} }
const ResTable_entry* ent = (const ResTable_entry*) const ResTable_entry* ent = (const ResTable_entry*)
(((const uint8_t*)type) + entriesStart + thisOffset); (((const uint8_t*)type) + entriesStart + thisOffset);
if (((entriesStart + thisOffset)&0x3) != 0) { if (((entriesStart + thisOffset)&0x3) != 0) {
@@ -5993,7 +5993,7 @@ void ResTable::print(bool inclValues) const
(entriesStart + thisOffset)); (entriesStart + thisOffset));
continue; continue;
} }
uintptr_t esize = dtohs(ent->size); uintptr_t esize = dtohs(ent->size);
if ((esize&0x3) != 0) { if ((esize&0x3) != 0) {
printf("NON-INTEGER ResTable_entry SIZE: 0x%x\n", esize); printf("NON-INTEGER ResTable_entry SIZE: 0x%x\n", esize);
@@ -6004,7 +6004,7 @@ void ResTable::print(bool inclValues) const
entriesStart, thisOffset, esize, typeSize); entriesStart, thisOffset, esize, typeSize);
continue; continue;
} }
const Res_value* valuePtr = NULL; const Res_value* valuePtr = NULL;
const ResTable_map_entry* bagPtr = NULL; const ResTable_map_entry* bagPtr = NULL;
Res_value value; Res_value value;
@@ -6019,12 +6019,12 @@ void ResTable::print(bool inclValues) const
(int)value.dataType, (int)value.data, (int)value.dataType, (int)value.data,
(int)value.size, (int)value.res0); (int)value.size, (int)value.res0);
} }
if ((dtohs(ent->flags)&ResTable_entry::FLAG_PUBLIC) != 0) { if ((dtohs(ent->flags)&ResTable_entry::FLAG_PUBLIC) != 0) {
printf(" (PUBLIC)"); printf(" (PUBLIC)");
} }
printf("\n"); printf("\n");
if (inclValues) { if (inclValues) {
if (valuePtr != NULL) { if (valuePtr != NULL) {
printf(" "); printf(" ");

View File

@@ -127,7 +127,7 @@ static const unsigned long kReadBufSize = 32768;
goto z_bail; goto z_bail;
} }
/* output buffer holds all, so no need to write the output */ /* output buffer holds all, so no need to write the output */
} while (zerr == Z_OK); } while (zerr == Z_OK);
assert(zerr == Z_STREAM_END); /* other errors should've been caught */ assert(zerr == Z_STREAM_END); /* other errors should've been caught */
@@ -197,7 +197,7 @@ public:
{ {
} }
long read(unsigned char** nextBuffer, long readSize) { long read(unsigned char** nextBuffer, long /*readSize*/) {
if (!mBufferReturned) { if (!mBufferReturned) {
mBufferReturned = true; mBufferReturned = true;
*nextBuffer = mInput; *nextBuffer = mInput;