diff options
author | Chih-hung Hsieh | 2017-08-04 16:14:30 -0500 |
---|---|---|
committer | android-build-merger | 2017-08-04 16:14:30 -0500 |
commit | 18f9c66823f5a024c152f04c1acc404cf6632ab4 (patch) | |
tree | 020a89f3675eeab01f4144ced7cc5ed5c59b32a7 /liblog/tests | |
parent | 0908ca721a27eb4a9ae892839f9fed34e6dd0116 (diff) | |
parent | 69ff5009c7d02ba42f714f744c338f258db864bb (diff) | |
download | platform-system-core-18f9c66823f5a024c152f04c1acc404cf6632ab4.tar.gz platform-system-core-18f9c66823f5a024c152f04c1acc404cf6632ab4.tar.xz platform-system-core-18f9c66823f5a024c152f04c1acc404cf6632ab4.zip |
Merge "Fix clang-tidy performance warnings in system/core."
am: 69ff5009c7
Change-Id: I74373e9f0e7f83c9280f4700ea55b387c3384c2c
Diffstat (limited to 'liblog/tests')
-rw-r--r-- | liblog/tests/liblog_test.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp index 46ec5ef64..e2d5aeb46 100644 --- a/liblog/tests/liblog_test.cpp +++ b/liblog/tests/liblog_test.cpp | |||
@@ -105,7 +105,7 @@ TEST(liblog, __android_log_btwrite) { | |||
105 | } | 105 | } |
106 | 106 | ||
107 | #if (defined(__ANDROID__) && defined(USING_LOGGER_DEFAULT)) | 107 | #if (defined(__ANDROID__) && defined(USING_LOGGER_DEFAULT)) |
108 | static std::string popenToString(std::string command) { | 108 | static std::string popenToString(const std::string& command) { |
109 | std::string ret; | 109 | std::string ret; |
110 | 110 | ||
111 | FILE* fp = popen(command.c_str(), "r"); | 111 | FILE* fp = popen(command.c_str(), "r"); |
@@ -129,17 +129,17 @@ static bool isPmsgActive() { | |||
129 | static bool isLogdwActive() { | 129 | static bool isLogdwActive() { |
130 | std::string logdwSignature = | 130 | std::string logdwSignature = |
131 | popenToString("grep /dev/socket/logdw /proc/net/unix"); | 131 | popenToString("grep /dev/socket/logdw /proc/net/unix"); |
132 | size_t beginning = logdwSignature.find(" "); | 132 | size_t beginning = logdwSignature.find(' '); |
133 | if (beginning == std::string::npos) return true; | 133 | if (beginning == std::string::npos) return true; |
134 | beginning = logdwSignature.find(" ", beginning + 1); | 134 | beginning = logdwSignature.find(' ', beginning + 1); |
135 | if (beginning == std::string::npos) return true; | 135 | if (beginning == std::string::npos) return true; |
136 | size_t end = logdwSignature.find(" ", beginning + 1); | 136 | size_t end = logdwSignature.find(' ', beginning + 1); |
137 | if (end == std::string::npos) return true; | 137 | if (end == std::string::npos) return true; |
138 | end = logdwSignature.find(" ", end + 1); | 138 | end = logdwSignature.find(' ', end + 1); |
139 | if (end == std::string::npos) return true; | 139 | if (end == std::string::npos) return true; |
140 | end = logdwSignature.find(" ", end + 1); | 140 | end = logdwSignature.find(' ', end + 1); |
141 | if (end == std::string::npos) return true; | 141 | if (end == std::string::npos) return true; |
142 | end = logdwSignature.find(" ", end + 1); | 142 | end = logdwSignature.find(' ', end + 1); |
143 | if (end == std::string::npos) return true; | 143 | if (end == std::string::npos) return true; |
144 | std::string allLogdwEndpoints = popenToString( | 144 | std::string allLogdwEndpoints = popenToString( |
145 | "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) + | 145 | "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) + |
@@ -159,7 +159,7 @@ static bool isLogdwActive() { | |||
159 | 159 | ||
160 | // NB: fgrep with multiple strings is broken in Android | 160 | // NB: fgrep with multiple strings is broken in Android |
161 | for (beginning = 0; | 161 | for (beginning = 0; |
162 | (end = allLogdwEndpoints.find("\n", beginning)) != std::string::npos; | 162 | (end = allLogdwEndpoints.find('\n', beginning)) != std::string::npos; |
163 | beginning = end + 1) { | 163 | beginning = end + 1) { |
164 | if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) != | 164 | if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) != |
165 | std::string::npos) | 165 | std::string::npos) |
@@ -3170,7 +3170,7 @@ static bool isZero(const std::string& content, std::string::size_type pos, | |||
3170 | return (offset != std::string::npos) && | 3170 | return (offset != std::string::npos) && |
3171 | ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) != | 3171 | ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) != |
3172 | std::string::npos) && | 3172 | std::string::npos) && |
3173 | (content.find_first_not_of("0", offset) != offset); | 3173 | (content.find_first_not_of('0', offset) != offset); |
3174 | } | 3174 | } |
3175 | 3175 | ||
3176 | // must not be: '<needle:> 0 kB' | 3176 | // must not be: '<needle:> 0 kB' |
@@ -3239,7 +3239,7 @@ static void event_log_tags_test_smap(pid_t pid) { | |||
3239 | filename = android::base::StringPrintf("/proc/%d/comm", pid); | 3239 | filename = android::base::StringPrintf("/proc/%d/comm", pid); |
3240 | android::base::ReadFileToString(filename, &content); | 3240 | android::base::ReadFileToString(filename, &content); |
3241 | content = android::base::StringPrintf( | 3241 | content = android::base::StringPrintf( |
3242 | "%d:%s", pid, content.substr(0, content.find("\n")).c_str()); | 3242 | "%d:%s", pid, content.substr(0, content.find('\n')).c_str()); |
3243 | 3243 | ||
3244 | EXPECT_TRUE(IsOk(shared_ok, content)); | 3244 | EXPECT_TRUE(IsOk(shared_ok, content)); |
3245 | EXPECT_TRUE(IsOk(private_ok, content)); | 3245 | EXPECT_TRUE(IsOk(private_ok, content)); |