diff options
Diffstat (limited to 'libs/androidfw/BackupHelpers.cpp')
-rw-r--r-- | libs/androidfw/BackupHelpers.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp index b8d3f48..52dce9f 100644 --- a/libs/androidfw/BackupHelpers.cpp +++ b/libs/androidfw/BackupHelpers.cpp @@ -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 // [ 116 : 8 ] gid -- ignored in Android format - snprintf(buf + 108, 8, "0%lo", s.st_uid); - snprintf(buf + 116, 8, "0%lo", s.st_gid); + snprintf(buf + 108, 8, "0%lo", (unsigned long)s.st_uid); + snprintf(buf + 116, 8, "0%lo", (unsigned long)s.st_gid); // [ 124 : 12 ] file size in bytes if (s.st_size > 077777777777LL) { @@ -639,7 +639,7 @@ int write_tarfile(const String8& packageName, const String8& domain, // size header -- calc len in digits by actually rendering the number // to a string - brute force but simple - snprintf(sizeStr, sizeof(sizeStr), "%lld", s.st_size); + snprintf(sizeStr, sizeof(sizeStr), "%lld", (long long)s.st_size); p += write_pax_header_entry(p, "size", sizeStr); // fullname was generated above with the ustar paths @@ -661,7 +661,7 @@ int write_tarfile(const String8& packageName, const String8& domain, // [ 124 : 12 ] size of pax extended header data memset(paxHeader + 124, 0, 12); - snprintf(paxHeader + 124, 12, "%011o", p - paxData); + snprintf(paxHeader + 124, 12, "%011o", (unsigned int)(p - paxData)); // Checksum and write the pax block header calc_tar_checksum(paxHeader); @@ -681,7 +681,10 @@ int write_tarfile(const String8& packageName, const String8& domain, if (!isdir) { off64_t toWrite = s.st_size; while (toWrite > 0) { - size_t toRead = (toWrite < BUFSIZE) ? toWrite : BUFSIZE; + size_t toRead = toWrite; + if (toRead > BUFSIZE) { + toRead = BUFSIZE; + } ssize_t nRead = read(fd, buf, toRead); if (nRead < 0) { err = errno; @@ -778,7 +781,7 @@ RestoreHelperBase::WriteFile(const String8& filename, BackupDataReader* in) ALOGW("Could not open file %s -- %s", filename.string(), strerror(errno)); return errno; } - + while ((amt = in->ReadEntityData(buf, RESTORE_BUF_SIZE)) > 0) { err = write(fd, buf, amt); if (err != amt) { @@ -1083,7 +1086,7 @@ backup_helper_test_four() } if (readSnapshot.size() != 4) { - fprintf(stderr, "readSnapshot should be length 4 is %d\n", readSnapshot.size()); + fprintf(stderr, "readSnapshot should be length 4 is %zu\n", readSnapshot.size()); return 1; } @@ -1095,8 +1098,8 @@ backup_helper_test_four() if (name != filenames[i] || states[i].modTime_sec != state.modTime_sec || states[i].modTime_nsec != state.modTime_nsec || states[i].mode != state.mode || states[i].size != state.size || states[i].crc32 != states[i].crc32) { - fprintf(stderr, "state %d expected={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n" - " actual={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n", i, + fprintf(stderr, "state %zu expected={%d/%d, %04o, 0x%08x, 0x%08x, %3zu} '%s'\n" + " actual={%d/%d, %04o, 0x%08x, 0x%08x, %3d} '%s'\n", i, states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size, states[i].crc32, name.length(), filenames[i].string(), state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32, @@ -1194,7 +1197,7 @@ int test_read_header_and_entity(BackupDataReader& reader, const char* str) { int err; - int bufSize = strlen(str)+1; + size_t bufSize = strlen(str)+1; char* buf = (char*)malloc(bufSize); String8 string; int cookie = 0x11111111; @@ -1229,9 +1232,9 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str) err = EINVAL; goto finished; } - if ((int)actualSize != bufSize) { - fprintf(stderr, "ReadEntityHeader expected dataSize 0x%08x got 0x%08x\n", bufSize, - actualSize); + if (actualSize != bufSize) { + fprintf(stderr, "ReadEntityHeader expected dataSize %zu got %zu\n", + bufSize, actualSize); err = EINVAL; goto finished; } |