Move zipalign off NO_ERROR.

I really only care about code that's built for Windows, but I may as
well clean up anywhere that's easy to clean up too...

Bug: N/A
Test: builds
Change-Id: I3ef34fb12ac90e9411b6421e9c23dd8524f056ae
gugelfrei-debug
Elliott Hughes 6 years ago
parent c18b2b28c2
commit ad7d562d27

@ -111,7 +111,7 @@ static int copyAndAlign(ZipFile* pZin, ZipFile* pZout, int alignment, bool zopfl
status = pZout->add(pZin, pEntry, padding, &pNewEntry);
}
if (status != NO_ERROR)
if (status != OK)
return 1;
bias += padding;
//printf(" added '%s' at %ld (pad=%d)\n",
@ -146,13 +146,13 @@ static int process(const char* inFileName, const char* outFileName,
return 1;
}
if (zin.open(inFileName, ZipFile::kOpenReadOnly) != NO_ERROR) {
if (zin.open(inFileName, ZipFile::kOpenReadOnly) != OK) {
fprintf(stderr, "Unable to open '%s' as zip archive\n", inFileName);
return 1;
}
if (zout.open(outFileName,
ZipFile::kOpenReadWrite|ZipFile::kOpenCreate|ZipFile::kOpenTruncate)
!= NO_ERROR)
!= OK)
{
fprintf(stderr, "Unable to open '%s' as zip archive\n", outFileName);
return 1;
@ -178,7 +178,7 @@ static int verify(const char* fileName, int alignment, bool verbose,
if (verbose)
printf("Verifying alignment of %s (%d)...\n", fileName, alignment);
if (zipFile.open(fileName, ZipFile::kOpenReadOnly) != NO_ERROR) {
if (zipFile.open(fileName, ZipFile::kOpenReadOnly) != OK) {
fprintf(stderr, "Unable to open '%s' for verification\n", fileName);
return 1;
}

@ -48,7 +48,7 @@ status_t ZipEntry::initFromCDE(FILE* fp)
/* read the CDE */
result = mCDE.read(fp);
if (result != NO_ERROR) {
if (result != OK) {
ALOGD("mCDE.read failed\n");
return result;
}
@ -64,7 +64,7 @@ status_t ZipEntry::initFromCDE(FILE* fp)
}
result = mLFH.read(fp);
if (result != NO_ERROR) {
if (result != OK) {
ALOGD("mLFH.read failed\n");
return result;
}
@ -103,7 +103,7 @@ status_t ZipEntry::initFromCDE(FILE* fp)
* can defer worrying about that to when we're extracting data.
*/
return NO_ERROR;
return OK;
}
/*
@ -189,7 +189,7 @@ status_t ZipEntry::initFromExternal(const ZipEntry* pEntry)
mLFH.mExtraFieldLength+1);
}
return NO_ERROR;
return OK;
}
/*
@ -225,7 +225,7 @@ status_t ZipEntry::addPadding(int padding)
mLFH.mExtraFieldLength = padding;
}
return NO_ERROR;
return OK;
}
/*
@ -403,7 +403,7 @@ void ZipEntry::setModWhen(time_t when)
*/
status_t ZipEntry::LocalFileHeader::read(FILE* fp)
{
status_t result = NO_ERROR;
status_t result = OK;
uint8_t buf[kLFHLen];
assert(mFileName == NULL);
@ -499,7 +499,7 @@ status_t ZipEntry::LocalFileHeader::write(FILE* fp)
return UNKNOWN_ERROR;
}
return NO_ERROR;
return OK;
}
@ -537,7 +537,7 @@ void ZipEntry::LocalFileHeader::dump(void) const
*/
status_t ZipEntry::CentralDirEntry::read(FILE* fp)
{
status_t result = NO_ERROR;
status_t result = OK;
uint8_t buf[kCDELen];
/* no re-use */
@ -669,7 +669,7 @@ status_t ZipEntry::CentralDirEntry::write(FILE* fp)
return UNKNOWN_ERROR;
}
return NO_ERROR;
return OK;
}
/*

@ -120,7 +120,7 @@ status_t ZipFile::open(const char* zipFileName, int flags)
* have a need for empty zip files.)
*/
mNeedCDRewrite = true;
result = NO_ERROR;
result = OK;
}
if (flags & kOpenReadOnly)
@ -205,7 +205,7 @@ void ZipFile::discardEntries(void)
*/
status_t ZipFile::readCentralDir(void)
{
status_t result = NO_ERROR;
status_t result = OK;
uint8_t* buf = NULL;
off_t fileLength, seekStart;
long readAmount;
@ -267,7 +267,7 @@ status_t ZipFile::readCentralDir(void)
/* extract eocd values */
result = mEOCD.readBuf(buf + i, readAmount - i);
if (result != NO_ERROR) {
if (result != OK) {
ALOGD("Failure reading %ld bytes of EOCD values", readAmount - i);
goto bail;
}
@ -311,7 +311,7 @@ status_t ZipFile::readCentralDir(void)
ZipEntry* pEntry = new ZipEntry;
result = pEntry->initFromCDE(mZipFp);
if (result != NO_ERROR) {
if (result != OK) {
ALOGD("initFromCDE failed\n");
delete pEntry;
goto bail;
@ -361,7 +361,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
const char* storageName, int compressionMethod, ZipEntry** ppEntry)
{
ZipEntry* pEntry = NULL;
status_t result = NO_ERROR;
status_t result = OK;
long lfhPosn, startPosn, endPosn, uncompressedLen;
FILE* inputFp = NULL;
uint32_t crc;
@ -415,7 +415,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
if (compressionMethod == ZipEntry::kCompressDeflated) {
bool failed = false;
result = compressFpToFp(mZipFp, inputFp, data, size, &crc);
if (result != NO_ERROR) {
if (result != OK) {
ALOGD("compression failed, storing\n");
failed = true;
} else {
@ -447,7 +447,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
} else {
result = copyDataToFp(mZipFp, data, size, &crc);
}
if (result != NO_ERROR) {
if (result != OK) {
// don't need to truncate; happens in CDE rewrite
ALOGD("failed copying data in\n");
goto bail;
@ -535,11 +535,11 @@ status_t ZipFile::add(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
}
result = pEntry->initFromExternal(pSourceEntry);
if (result != NO_ERROR)
if (result != OK)
goto bail;
if (padding != 0) {
result = pEntry->addPadding(padding);
if (result != NO_ERROR)
if (result != OK)
goto bail;
}
@ -574,7 +574,7 @@ status_t ZipFile::add(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
copyLen += ZipEntry::kDataDescriptorLen;
if (copyPartialFpToFp(mZipFp, pSourceZip->mZipFp, copyLen, NULL)
!= NO_ERROR)
!= OK)
{
ALOGW("copy of '%s' failed\n", pEntry->mCDE.mFileName);
result = UNKNOWN_ERROR;
@ -603,7 +603,7 @@ status_t ZipFile::add(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
*ppEntry = pEntry;
pEntry = NULL;
result = NO_ERROR;
result = OK;
bail:
delete pEntry;
@ -642,7 +642,7 @@ status_t ZipFile::addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSour
}
result = pEntry->initFromExternal(pSourceEntry);
if (result != NO_ERROR)
if (result != OK)
goto bail;
/*
@ -682,7 +682,7 @@ status_t ZipFile::addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSour
}
long startPosn = ftell(mZipFp);
uint32_t crc;
if (compressFpToFp(mZipFp, NULL, buf, uncompressedLen, &crc) != NO_ERROR) {
if (compressFpToFp(mZipFp, NULL, buf, uncompressedLen, &crc) != OK) {
ALOGW("recompress of '%s' failed\n", pEntry->mCDE.mFileName);
result = UNKNOWN_ERROR;
free(buf);
@ -699,7 +699,7 @@ status_t ZipFile::addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSour
copyLen += ZipEntry::kDataDescriptorLen;
if (copyPartialFpToFp(mZipFp, pSourceZip->mZipFp, copyLen, NULL)
!= NO_ERROR)
!= OK)
{
ALOGW("copy of '%s' failed\n", pEntry->mCDE.mFileName);
result = UNKNOWN_ERROR;
@ -738,7 +738,7 @@ status_t ZipFile::addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSour
*ppEntry = pEntry;
pEntry = NULL;
result = NO_ERROR;
result = OK;
bail:
delete pEntry;
@ -773,7 +773,7 @@ status_t ZipFile::copyFpToFp(FILE* dstFp, FILE* srcFp, uint32_t* pCRC32)
}
}
return NO_ERROR;
return OK;
}
/*
@ -793,7 +793,7 @@ status_t ZipFile::copyDataToFp(FILE* dstFp,
}
}
return NO_ERROR;
return OK;
}
/*
@ -837,7 +837,7 @@ status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, size_t length,
length -= readSize;
}
return NO_ERROR;
return OK;
}
/*
@ -849,7 +849,7 @@ status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, size_t length,
status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
const void* data, size_t size, uint32_t* pCRC32)
{
status_t result = NO_ERROR;
status_t result = OK;
const size_t kBufSize = 1024 * 1024;
uint8_t* inBuf = NULL;
uint8_t* outBuf = NULL;
@ -933,7 +933,7 @@ status_t ZipFile::remove(ZipEntry* pEntry)
/* mark entry as deleted, and mark archive as dirty */
pEntry->setDeleted();
mNeedCDRewrite = true;
return NO_ERROR;
return OK;
}
/*
@ -944,19 +944,19 @@ status_t ZipFile::remove(ZipEntry* pEntry)
*/
status_t ZipFile::flush(void)
{
status_t result = NO_ERROR;
status_t result = OK;
long eocdPosn;
int i, count;
if (mReadOnly)
return INVALID_OPERATION;
if (!mNeedCDRewrite)
return NO_ERROR;
return OK;
assert(mZipFp != NULL);
result = crunchArchive();
if (result != NO_ERROR)
if (result != OK)
return result;
if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0)
@ -986,7 +986,7 @@ status_t ZipFile::flush(void)
/* should we clear the "newly added" flag in all entries now? */
mNeedCDRewrite = false;
return NO_ERROR;
return OK;
}
/*
@ -997,7 +997,7 @@ status_t ZipFile::flush(void)
*/
status_t ZipFile::crunchArchive(void)
{
status_t result = NO_ERROR;
status_t result = OK;
int i, count;
long delCount, adjust;
@ -1065,7 +1065,7 @@ status_t ZipFile::crunchArchive(void)
// pEntry->getFileName(), adjust);
result = filemove(mZipFp, pEntry->getLFHOffset() - adjust,
pEntry->getLFHOffset(), span);
if (result != NO_ERROR) {
if (result != OK) {
/* this is why you use a temp file */
ALOGE("error during crunch - archive is toast\n");
return result;
@ -1097,7 +1097,7 @@ status_t ZipFile::crunchArchive(void)
status_t ZipFile::filemove(FILE* fp, off_t dst, off_t src, size_t n)
{
if (dst == src || n <= 0)
return NO_ERROR;
return OK;
uint8_t readBuf[32768];
@ -1140,7 +1140,7 @@ status_t ZipFile::filemove(FILE* fp, off_t dst, off_t src, size_t n)
return UNKNOWN_ERROR;
}
return NO_ERROR;
return OK;
}
@ -1355,7 +1355,7 @@ status_t ZipFile::EndOfCentralDir::readBuf(const uint8_t* buf, int len)
memcpy(mComment, buf + kEOCDLen, mCommentLen);
}
return NO_ERROR;
return OK;
}
/*
@ -1382,7 +1382,7 @@ status_t ZipFile::EndOfCentralDir::write(FILE* fp)
return UNKNOWN_ERROR;
}
return NO_ERROR;
return OK;
}
/*

Loading…
Cancel
Save