From: Evgeniy Stepanov Date: Fri, 12 Oct 2018 22:07:54 +0000 (+0000) Subject: [sanitizer] Avoid extra newlines in syslog. X-Git-Tag: llvmorg-8.0.0-rc1~6610 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ab897dcb577d2d9044dbf13f6c7dc78bd659487;p=platform%2Fupstream%2Fllvm.git [sanitizer] Avoid extra newlines in syslog. Fix line splitting logic to avoid sending empty lines to syslog, as that adds extra newlines. llvm-svn: 344426 --- diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc index 796a054..ab42b2167 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -100,14 +100,17 @@ void WriteToSyslog(const char *msg) { // Print one line at a time. // syslog, at least on Android, has an implicit message length limit. - do { - q = internal_strchr(p, '\n'); - if (q) - *q = '\0'; + while ((q = internal_strchr(p, '\n'))) { + *q = '\0'; + WriteOneLineToSyslog(p); + p = q + 1; + } + // Print remaining characters, if there are any. + // Note that this will add an extra newline at the end. + // FIXME: buffer extra output. This would need a thread-local buffer, which + // on Android requires plugging into the tools (ex. ASan's) Thread class. + if (*p) WriteOneLineToSyslog(p); - if (q) - p = q + 1; - } while (q); } void MaybeStartBackgroudThread() {