diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2018-10-12 22:07:54 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2018-10-12 22:07:54 +0000 |
| commit | 9ab897dcb577d2d9044dbf13f6c7dc78bd659487 (patch) | |
| tree | d6f3c5f93285878a6e84ecf5db9cb1a9360a03c2 /compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc | |
| parent | 3e76b2d7364a7167562a58125c7646e882573032 (diff) | |
| download | bcm5719-llvm-9ab897dcb577d2d9044dbf13f6c7dc78bd659487.tar.gz bcm5719-llvm-9ab897dcb577d2d9044dbf13f6c7dc78bd659487.zip | |
[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
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc index 796a054858b..ab42b216771 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() { |

