summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-12-19 14:51:15 -0800
committerMark Salyzyn <salyzyn@google.com>2016-12-19 15:06:42 -0800
commitb545e1c9e3d5989e2e889e65436524fdcfed930e (patch)
tree61a0eeadd37c2cf62aa72068fb36b2c7b8ed7edc /logd
parentd966e226809bd446bb33651b71d7934887787c1d (diff)
downloadsystem_core-b545e1c9e3d5989e2e889e65436524fdcfed930e.tar.gz
system_core-b545e1c9e3d5989e2e889e65436524fdcfed930e.tar.bz2
system_core-b545e1c9e3d5989e2e889e65436524fdcfed930e.zip
logd: trailing spaces in log statistics (part deux)
Test: manual Bug: 30118730 Change-Id: Iafda6f95e1b1377649e01868c81c0056c116e01b
Diffstat (limited to 'logd')
-rw-r--r--logd/LogStatistics.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index 8bf655b01..1d687bcb5 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -17,11 +17,12 @@
#ifndef _LOGD_LOG_STATISTICS_H__
#define _LOGD_LOG_STATISTICS_H__
-#include <memory>
+#include <ctype.h>
#include <stdlib.h>
#include <sys/types.h>
#include <algorithm> // std::max
+#include <memory>
#include <string> // std::string
#include <unordered_map>
@@ -211,14 +212,16 @@ struct EntryBase {
EntryBaseConstants::total_len
- name.length() - drop_len - 1);
- if (pruned.length()) {
- return android::base::StringPrintf("%s%*s%*s\n", name.c_str(),
- (int)size_len, size.c_str(),
- (int)drop_len, pruned.c_str());
- } else {
- return android::base::StringPrintf("%s%*s\n", name.c_str(),
- (int)size_len, size.c_str());
- }
+ std::string ret = android::base::StringPrintf("%s%*s%*s",
+ name.c_str(),
+ (int)size_len, size.c_str(),
+ (int)drop_len, pruned.c_str());
+ // remove any trailing spaces
+ size_t pos = ret.size();
+ size_t len = 0;
+ while (pos && isspace(ret[--pos])) ++len;
+ if (len) ret.erase(pos + 1, len);
+ return ret + "\n";
}
};