diff options
author | Ashok Bhat <ashok.bhat@arm.com> | 2014-03-25 20:51:35 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-03-27 12:30:42 +0000 |
commit | f5df700e6ce056ebfa322314d970e52d6facc35a (patch) | |
tree | 5a3e1f8dc1089601389509f54d2eef98ec2528a8 /libs/androidfw/BackupHelpers.cpp | |
parent | 57f2764bf104b0fe7b5cd67ad5b2cae9bc8352ed (diff) |
AArch64: Make frameworks/base code more portable
Changes in this patch include
[x] Use %zu for size_t, %zd for ssize_t
[x] Some minor changes have been done to conform with
standard JNI practice (e.g. use of jint instead of int
in JNI function prototypes)
Change-Id: Id1aaa7894a7d0b85ac7ecd7b2bfd8cc40374261f
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Diffstat (limited to 'libs/androidfw/BackupHelpers.cpp')
-rw-r--r-- | libs/androidfw/BackupHelpers.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp index ab837ad71cbf..52dce9f7f5c5 100644 --- a/libs/androidfw/BackupHelpers.cpp +++ b/libs/androidfw/BackupHelpers.cpp @@ -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; @@ -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 %zu expected={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n" - " actual={%d/%d, 0x%08x, %04o, 0x%08x, %3zu} '%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%08zx\n", bufSize, - actualSize); + if (actualSize != bufSize) { + fprintf(stderr, "ReadEntityHeader expected dataSize %zu got %zu\n", + bufSize, actualSize); err = EINVAL; goto finished; } |