Fix or suppress some google-runtime-int warnings.
Bug: 112478838
Test: build with WITH_TIDY=1
Change-Id: Ie3b15a85770b5806cddfd49a475aaf0553f9ec78
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index d56ac29..c4d6fc4 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -102,7 +102,7 @@
* file position in the new file will be equal to the file
* position in the original.
*/
- long newOffset = pEntry->getFileOffset() + bias;
+ off_t newOffset = pEntry->getFileOffset() + bias;
padding = (alignTo - (newOffset % alignTo)) % alignTo;
//printf("--- %s: orig at %ld(+%d) len=%ld, adding pad=%d\n",
@@ -190,23 +190,23 @@
pEntry = zipFile.getEntryByIndex(i);
if (pEntry->isCompressed()) {
if (verbose) {
- printf("%8ld %s (OK - compressed)\n",
- (long) pEntry->getFileOffset(), pEntry->getFileName());
+ printf("%8jd %s (OK - compressed)\n",
+ (intmax_t) pEntry->getFileOffset(), pEntry->getFileName());
}
} else {
- long offset = pEntry->getFileOffset();
+ off_t offset = pEntry->getFileOffset();
const int alignTo = getAlignment(pageAlignSharedLibs, alignment, pEntry);
if ((offset % alignTo) != 0) {
if (verbose) {
- printf("%8ld %s (BAD - %ld)\n",
- (long) offset, pEntry->getFileName(),
+ printf("%8jd %s (BAD - %ld)\n",
+ (intmax_t) offset, pEntry->getFileName(),
offset % alignTo);
}
foundBad = true;
} else {
if (verbose) {
- printf("%8ld %s (OK)\n",
- (long) offset, pEntry->getFileName());
+ printf("%8jd %s (OK)\n",
+ (intmax_t) offset, pEntry->getFileName());
}
}
}
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index 63d75d1..c3c833e 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -41,7 +41,7 @@
status_t ZipEntry::initFromCDE(FILE* fp)
{
status_t result;
- long posn;
+ long posn; // NOLINT(google-runtime-int), for ftell/fseek
bool hasDD;
//ALOGV("initFromCDE ---\n");
@@ -258,8 +258,8 @@
/*
* Set some information about a file after we add it.
*/
-void ZipEntry::setDataInfo(long uncompLen, long compLen, uint32_t crc32,
- int compressionMethod)
+void ZipEntry::setDataInfo(uint32_t uncompLen, uint32_t compLen, uint32_t crc32,
+ uint32_t compressionMethod)
{
mCDE.mCompressionMethod = compressionMethod;
mCDE.mCRC32 = crc32;
@@ -367,7 +367,7 @@
struct tm* ptm;
/* round up to an even number of seconds */
- even = (time_t)(((unsigned long)(when) + 1) & (~1));
+ even = (when & 1) ? (when + 1) : when;
/* expand */
#if !defined(_WIN32)
diff --git a/tools/zipalign/ZipEntry.h b/tools/zipalign/ZipEntry.h
index 247cf69..4c7e18c 100644
--- a/tools/zipalign/ZipEntry.h
+++ b/tools/zipalign/ZipEntry.h
@@ -179,8 +179,8 @@
/*
* Set information about the data for this entry.
*/
- void setDataInfo(long uncompLen, long compLen, uint32_t crc32,
- int compressionMethod);
+ void setDataInfo(uint32_t uncompLen, uint32_t compLen, uint32_t crc32,
+ uint32_t compressionMethod);
/*
* Set the modification date.
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 43bc9bf..9e44956 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -804,7 +804,7 @@
* On exit, "srcFp" will be seeked to the end of the file, and "dstFp"
* will be seeked immediately past the data just written.
*/
-status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
+status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, size_t length,
uint32_t* pCRC32)
{
uint8_t tmpBuf[32768];
@@ -814,14 +814,14 @@
*pCRC32 = crc32(0L, Z_NULL, 0);
while (length) {
- long readSize;
+ size_t readSize;
readSize = sizeof(tmpBuf);
if (readSize > length)
readSize = length;
count = fread(tmpBuf, 1, readSize, srcFp);
- if ((long) count != readSize) { // error or unexpected EOF
+ if (count != readSize) { // error or unexpected EOF
ALOGD("fread %d bytes failed\n", (int) readSize);
return UNKNOWN_ERROR;
}
diff --git a/tools/zipalign/ZipFile.h b/tools/zipalign/ZipFile.h
index d5ace7c..11d20c5 100644
--- a/tools/zipalign/ZipFile.h
+++ b/tools/zipalign/ZipFile.h
@@ -224,7 +224,7 @@
status_t copyDataToFp(FILE* dstFp,
const void* data, size_t size, uint32_t* pCRC32);
/* copy some of "srcFp" into "dstFp" */
- status_t copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
+ status_t copyPartialFpToFp(FILE* dstFp, FILE* srcFp, size_t length,
uint32_t* pCRC32);
/* like memmove(), but on parts of a single file */
status_t filemove(FILE* fp, off_t dest, off_t src, size_t n);