diff options
author | 2016-10-19 10:23:59 -0700 | |
---|---|---|
committer | 2016-10-19 16:29:13 -0700 | |
commit | 13c41d3c7b20c6890889509dbf36b23bd7c20121 (patch) | |
tree | ec8bd64e6c76804818d3824926b4bda47c84cab2 /libs/binder/TextOutput.cpp | |
parent | 69eaed3663318ca4b7f881c2fa85b59958160ca0 (diff) |
Fix log function for potential overflow
On LP64 system, unsigned long can be 64bit
Also clean out unused static variables.
Test: flash on ARM64 device
Bug: 32181382
Change-Id: I44b7ea8a6588c475a3979d7bddeb08da7f54c27a
Diffstat (limited to 'libs/binder/TextOutput.cpp')
-rw-r--r-- | libs/binder/TextOutput.cpp | 101 |
1 files changed, 2 insertions, 99 deletions
diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp index 2ed51887b1..101eba318f 100644 --- a/libs/binder/TextOutput.cpp +++ b/libs/binder/TextOutput.cpp @@ -29,111 +29,14 @@ namespace android { // --------------------------------------------------------------------------- -TextOutput::TextOutput() { +TextOutput::TextOutput() { } -TextOutput::~TextOutput() { +TextOutput::~TextOutput() { } // --------------------------------------------------------------------------- -TextOutput& operator<<(TextOutput& to, bool val) -{ - if (val) to.print("true", 4); - else to.print("false", 5); - return to; -} - -TextOutput& operator<<(TextOutput& to, int val) -{ - char buf[16]; - sprintf(buf, "%d", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, long val) -{ - char buf[16]; - sprintf(buf, "%ld", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, unsigned int val) -{ - char buf[16]; - sprintf(buf, "%u", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, unsigned long val) -{ - char buf[16]; - sprintf(buf, "%lu", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, long long val) -{ - char buf[32]; - sprintf(buf, "%Ld", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, unsigned long long val) -{ - char buf[32]; - sprintf(buf, "%Lu", val); - to.print(buf, strlen(buf)); - return to; -} - -static TextOutput& print_float(TextOutput& to, double value) -{ - char buf[64]; - sprintf(buf, "%g", value); - if( !strchr(buf, '.') && !strchr(buf, 'e') && - !strchr(buf, 'E') ) { - strncat(buf, ".0", sizeof(buf)-1); - } - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, float val) -{ - return print_float(to,val); -} - -TextOutput& operator<<(TextOutput& to, double val) -{ - return print_float(to,val); -} - -TextOutput& operator<<(TextOutput& to, const void* val) -{ - char buf[32]; - snprintf(buf, sizeof(buf), "%p", val); - to.print(buf, strlen(buf)); - return to; -} - -TextOutput& operator<<(TextOutput& to, const String8& val) -{ - to << val.string(); - return to; -} - -TextOutput& operator<<(TextOutput& to, const String16& val) -{ - to << String8(val).string(); - return to; -} - static void textOutputPrinter(void* cookie, const char* txt) { ((TextOutput*)cookie)->print(txt, strlen(txt)); |