[compiler-rt] r344426 - [sanitizer] Avoid extra newlines in syslog.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 12 15:07:54 PDT 2018
Author: eugenis
Date: Fri Oct 12 15:07:54 2018
New Revision: 344426
URL: http://llvm.org/viewvc/llvm-project?rev=344426&view=rev
Log:
[sanitizer] Avoid extra newlines in syslog.
Fix line splitting logic to avoid sending empty lines to syslog, as
that adds extra newlines.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc?rev=344426&r1=344425&r2=344426&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc Fri Oct 12 15:07:54 2018
@@ -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() {
More information about the llvm-commits
mailing list