summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
Diffstat (limited to 'liblog')
-rw-r--r--liblog/include/log/log_main.h4
-rw-r--r--liblog/local_logger.c1
-rw-r--r--liblog/logprint.c1
-rw-r--r--liblog/tests/liblog_test.cpp20
-rw-r--r--liblog/tests/log_id_test.cpp4
5 files changed, 16 insertions, 14 deletions
diff --git a/liblog/include/log/log_main.h b/liblog/include/log/log_main.h
index 68c2e9af6..339a06d86 100644
--- a/liblog/include/log/log_main.h
+++ b/liblog/include/log/log_main.h
@@ -354,11 +354,11 @@ int __android_log_is_loggable_len(int prio, const char* tag, size_t len,
354 354
355#if LOG_NDEBUG /* Production */ 355#if LOG_NDEBUG /* Production */
356#define android_testLog(prio, tag) \ 356#define android_testLog(prio, tag) \
357 (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \ 357 (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \
358 ANDROID_LOG_DEBUG) != 0) 358 ANDROID_LOG_DEBUG) != 0)
359#else 359#else
360#define android_testLog(prio, tag) \ 360#define android_testLog(prio, tag) \
361 (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \ 361 (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \
362 ANDROID_LOG_VERBOSE) != 0) 362 ANDROID_LOG_VERBOSE) != 0)
363#endif 363#endif
364 364
diff --git a/liblog/local_logger.c b/liblog/local_logger.c
index 522867d4f..563cb3f9b 100644
--- a/liblog/local_logger.c
+++ b/liblog/local_logger.c
@@ -222,6 +222,7 @@ static int LogBufferLog(struct LogBuffer* log,
222 log->last[logId] = node->prev; 222 log->last[logId] = node->prev;
223 } 223 }
224 list_remove(node); 224 list_remove(node);
225 LOG_ALWAYS_FATAL_IF(node == log->last[logId], "corrupted list");
225 free(e); 226 free(e);
226 } 227 }
227 /* add entry to list */ 228 /* add entry to list */
diff --git a/liblog/logprint.c b/liblog/logprint.c
index b62f8b446..a2839bfb6 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -250,6 +250,7 @@ LIBLOG_ABI_PUBLIC void android_log_format_free(AndroidLogFormat* p_format) {
250 while (!list_empty(&convertHead)) { 250 while (!list_empty(&convertHead)) {
251 struct listnode* node = list_head(&convertHead); 251 struct listnode* node = list_head(&convertHead);
252 list_remove(node); 252 list_remove(node);
253 LOG_ALWAYS_FATAL_IF(node == list_head(&convertHead), "corrupted list");
253 free(node); 254 free(node);
254 } 255 }
255} 256}
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index 56dbf1f2e..597a6bb90 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))
108static std::string popenToString(std::string command) { 108static 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");
@@ -131,17 +131,17 @@ static bool isPmsgActive() {
131static bool isLogdwActive() { 131static bool isLogdwActive() {
132 std::string logdwSignature = 132 std::string logdwSignature =
133 popenToString("grep /dev/socket/logdw /proc/net/unix"); 133 popenToString("grep /dev/socket/logdw /proc/net/unix");
134 size_t beginning = logdwSignature.find(" "); 134 size_t beginning = logdwSignature.find(' ');
135 if (beginning == std::string::npos) return true; 135 if (beginning == std::string::npos) return true;
136 beginning = logdwSignature.find(" ", beginning + 1); 136 beginning = logdwSignature.find(' ', beginning + 1);
137 if (beginning == std::string::npos) return true; 137 if (beginning == std::string::npos) return true;
138 size_t end = logdwSignature.find(" ", beginning + 1); 138 size_t end = logdwSignature.find(' ', beginning + 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 end = logdwSignature.find(" ", end + 1); 144 end = logdwSignature.find(' ', end + 1);
145 if (end == std::string::npos) return true; 145 if (end == std::string::npos) return true;
146 std::string allLogdwEndpoints = popenToString( 146 std::string allLogdwEndpoints = popenToString(
147 "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) + 147 "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) +
@@ -161,7 +161,7 @@ static bool isLogdwActive() {
161 161
162 // NB: fgrep with multiple strings is broken in Android 162 // NB: fgrep with multiple strings is broken in Android
163 for (beginning = 0; 163 for (beginning = 0;
164 (end = allLogdwEndpoints.find("\n", beginning)) != std::string::npos; 164 (end = allLogdwEndpoints.find('\n', beginning)) != std::string::npos;
165 beginning = end + 1) { 165 beginning = end + 1) {
166 if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) != 166 if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) !=
167 std::string::npos) 167 std::string::npos)
@@ -3189,7 +3189,7 @@ static bool isZero(const std::string& content, std::string::size_type pos,
3189 return (offset != std::string::npos) && 3189 return (offset != std::string::npos) &&
3190 ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) != 3190 ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) !=
3191 std::string::npos) && 3191 std::string::npos) &&
3192 (content.find_first_not_of("0", offset) != offset); 3192 (content.find_first_not_of('0', offset) != offset);
3193} 3193}
3194 3194
3195// must not be: '<needle:> 0 kB' 3195// must not be: '<needle:> 0 kB'
@@ -3258,7 +3258,7 @@ static void event_log_tags_test_smap(pid_t pid) {
3258 filename = android::base::StringPrintf("/proc/%d/comm", pid); 3258 filename = android::base::StringPrintf("/proc/%d/comm", pid);
3259 android::base::ReadFileToString(filename, &content); 3259 android::base::ReadFileToString(filename, &content);
3260 content = android::base::StringPrintf( 3260 content = android::base::StringPrintf(
3261 "%d:%s", pid, content.substr(0, content.find("\n")).c_str()); 3261 "%d:%s", pid, content.substr(0, content.find('\n')).c_str());
3262 3262
3263 EXPECT_TRUE(IsOk(shared_ok, content)); 3263 EXPECT_TRUE(IsOk(shared_ok, content));
3264 EXPECT_TRUE(IsOk(private_ok, content)); 3264 EXPECT_TRUE(IsOk(private_ok, content));
diff --git a/liblog/tests/log_id_test.cpp b/liblog/tests/log_id_test.cpp
index c56fa8b8a..9fb5a2c75 100644
--- a/liblog/tests/log_id_test.cpp
+++ b/liblog/tests/log_id_test.cpp
@@ -89,12 +89,12 @@ TEST(liblog, concurrent_name(__android_log_buf_print, NUM_CONCURRENT)) {
89 ASSERT_EQ(0, pthread_create(&t[i], NULL, ConcurrentPrintFn, 89 ASSERT_EQ(0, pthread_create(&t[i], NULL, ConcurrentPrintFn,
90 reinterpret_cast<void*>(i))); 90 reinterpret_cast<void*>(i)));
91 } 91 }
92 int ret = 0; 92 int ret = 1;
93 for (i = 0; i < NUM_CONCURRENT; i++) { 93 for (i = 0; i < NUM_CONCURRENT; i++) {
94 void* result; 94 void* result;
95 ASSERT_EQ(0, pthread_join(t[i], &result)); 95 ASSERT_EQ(0, pthread_join(t[i], &result));
96 int this_result = reinterpret_cast<uintptr_t>(result); 96 int this_result = reinterpret_cast<uintptr_t>(result);
97 if ((0 == ret) && (0 != this_result)) { 97 if ((0 < ret) && (ret != this_result)) {
98 ret = this_result; 98 ret = this_result;
99 } 99 }
100 } 100 }