diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2018-05-11 15:52:49 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2018-05-11 23:22:10 +0000 |
commit | dc36bb6dea837608c29c177a7ea8cf46b6a0cd53 (patch) | |
tree | b2665fb535d0583511349cdf5d00052a705dd2ab /tools/aapt | |
parent | ef43ea3238e55ddca0658059a05c7a53db50d621 (diff) |
For Win32, don't cast ssize_t while printing
Bug: http://b/69933068
This is a partial revert of
https://android-review.googlesource.com/c/platform/frameworks/base/+/109433
so we can use Clang for windows cross compilation.
Clang does not allow a cast to 'signed size_t' and both Clang and
current MinGW accept a ssize_t to the '%zd' format specifier.
Test: m native-host, m native-host-cross with both MinGW and Clang
Change-Id: I5366622b91be1433f6c533c55a9ae429b57c7a27
Diffstat (limited to 'tools/aapt')
-rw-r--r-- | tools/aapt/ResourceTable.cpp | 11 | ||||
-rw-r--r-- | tools/aapt/StringPool.cpp | 11 | ||||
-rw-r--r-- | tools/aapt/XMLNode.cpp | 7 |
3 files changed, 8 insertions, 21 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 52b93a945433..06eb84dfb906 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -18,13 +18,10 @@ #include <utils/TypeHelpers.h> #include <stdarg.h> -// SSIZE: mingw does not have signed size_t == ssize_t. // STATUST: mingw does seem to redefine UNKNOWN_ERROR from our enum value, so a cast is necessary. #if !defined(_WIN32) -# define SSIZE(x) x # define STATUST(x) x #else -# define SSIZE(x) (signed size_t)x # define STATUST(x) (status_t)x #endif @@ -3040,7 +3037,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>& sp<AaptFile> strFile = p->getTypeStringsData(); ssize_t amt = data->writeData(strFile->getData(), strFile->getSize()); if (kPrintStringMetrics) { - fprintf(stderr, "**** type strings: %zd\n", SSIZE(amt)); + fprintf(stderr, "**** type strings: %zd\n", amt); } strAmt += amt; if (amt < 0) { @@ -3050,7 +3047,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>& strFile = p->getKeyStringsData(); amt = data->writeData(strFile->getData(), strFile->getSize()); if (kPrintStringMetrics) { - fprintf(stderr, "**** key strings: %zd\n", SSIZE(amt)); + fprintf(stderr, "**** key strings: %zd\n", amt); } strAmt += amt; if (amt < 0) { @@ -3322,8 +3319,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>& ssize_t amt = (dest->getSize()-strStart); strAmt += amt; if (kPrintStringMetrics) { - fprintf(stderr, "**** value strings: %zd\n", SSIZE(amt)); - fprintf(stderr, "**** total strings: %zd\n", SSIZE(strAmt)); + fprintf(stderr, "**** value strings: %zd\n", amt); + fprintf(stderr, "**** total strings: %zd\n", amt); } for (pi=0; pi<flatPackages.size(); pi++) { diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp index 866291a3b678..37b61bfdffbd 100644 --- a/tools/aapt/StringPool.cpp +++ b/tools/aapt/StringPool.cpp @@ -12,13 +12,6 @@ #include "ResourceTable.h" -// SSIZE: mingw does not have signed size_t == ssize_t. -#if !defined(_WIN32) -# define SSIZE(x) x -#else -# define SSIZE(x) (signed size_t)x -#endif - // Set to true for noisy debug output. static const bool kIsDebug = false; @@ -202,7 +195,7 @@ ssize_t StringPool::add(const String16& value, if (kIsDebug) { printf("Adding string %s to pool: pos=%zd eidx=%zd vidx=%zd\n", - String8(value).string(), SSIZE(pos), SSIZE(eidx), SSIZE(vidx)); + String8(value).string(), pos, eidx, vidx); } return pos; @@ -598,7 +591,7 @@ ssize_t StringPool::offsetForString(const String16& val) const const Vector<size_t>* indices = offsetsForString(val); ssize_t res = indices != NULL && indices->size() > 0 ? indices->itemAt(0) : -1; if (kIsDebug) { - printf("Offset for string %s: %zd (%s)\n", String8(val).string(), SSIZE(res), + printf("Offset for string %s: %zd (%s)\n", String8(val).string(), res, res >= 0 ? String8(mEntries[mEntryArray[res]].value).string() : String8()); } return res; diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp index 15ec4afa52dd..861efd5077fe 100644 --- a/tools/aapt/XMLNode.cpp +++ b/tools/aapt/XMLNode.cpp @@ -16,13 +16,10 @@ #define O_BINARY 0 #endif -// SSIZE: mingw does not have signed size_t == ssize_t. // STATUST: mingw does seem to redefine UNKNOWN_ERROR from our enum value, so a cast is necessary. #if !defined(_WIN32) -# define SSIZE(x) x # define STATUST(x) x #else -# define SSIZE(x) (signed size_t)x # define STATUST(x) (status_t)x #endif @@ -1426,7 +1423,7 @@ status_t XMLNode::collect_attr_strings(StringPool* outPool, idx = outPool->add(attr.name); if (kIsDebug) { printf("Adding attr %s (resid 0x%08x) to pool: idx=%zd\n", - String8(attr.name).string(), id, SSIZE(idx)); + String8(attr.name).string(), id, idx); } if (id != 0) { while ((ssize_t)outResIds->size() <= idx) { @@ -1437,7 +1434,7 @@ status_t XMLNode::collect_attr_strings(StringPool* outPool, } attr.namePoolIdx = idx; if (kIsDebug) { - printf("String %s offset=0x%08zd\n", String8(attr.name).string(), SSIZE(idx)); + printf("String %s offset=0x%08zd\n", String8(attr.name).string(), idx); } } } |