Fix an uninitialized value warning.
Warning from the static analyzer:
build/tools/zipalign/ZipFile.cpp:503:5: warning: Function call argument
is an uninitialized value
pEntry->setDataInfo(uncompressedLen, endPosn - startPosn, crc,
Specifically, it's referencing `crc`, which would be uninitialized if we
hit either of these two error cases, since we'd return `NO_ERROR`.
Note that the warning is still there, but that's only because the static
analyzer can't see the asserts. If we #undef NDEBUG in the file, then
the warning disappears.
Bug: none
Test: With NDEBUG undefined, the warning is gone.
Change-Id: Iaed66127746c38add2c842ab027f2e1982d0e2fd
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 4edf0aa..98d02e0 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -919,6 +919,7 @@
getSize = fread(inBuf, 1, kBufSize, srcFp);
if (ferror(srcFp)) {
ALOGD("deflate read failed (errno=%d)\n", errno);
+ result = UNKNOWN_ERROR;
delete[] inBuf;
goto bail;
}
@@ -937,6 +938,7 @@
ALOGV("+++ writing %d bytes\n", (int)outSize);
if (fwrite(outBuf, 1, outSize, dstFp) != outSize) {
ALOGD("write %d failed in deflate\n", (int)outSize);
+ result = UNKNOWN_ERROR;
goto bail;
}