Commit 1b4a018e authored by Dominik Charousset's avatar Dominik Charousset

Fix build with ASAN version of Clang

parent 72c449ec
...@@ -241,8 +241,9 @@ void logger::init(actor_system_config& cfg) { ...@@ -241,8 +241,9 @@ void logger::init(actor_system_config& cfg) {
void logger::render_fun_prefix(std::ostream& out, const char* pretty_fun) { void logger::render_fun_prefix(std::ostream& out, const char* pretty_fun) {
auto first = pretty_fun; auto first = pretty_fun;
// set end to beginning of arguments // set end to beginning of arguments
auto last = std::find_if(first, static_cast<const char*>(nullptr), const char* last = strchr(pretty_fun, '(');
[](char x) { return x == '(' || x == '\0'; }); if (last == nullptr)
return;
auto strsize = static_cast<size_t>(last - first); auto strsize = static_cast<size_t>(last - first);
auto jump_to_next_whitespace = [&] { auto jump_to_next_whitespace = [&] {
// leave `first` unchanged if no whitespaces is present, // leave `first` unchanged if no whitespaces is present,
...@@ -274,16 +275,15 @@ void logger::render_fun_prefix(std::ostream& out, const char* pretty_fun) { ...@@ -274,16 +275,15 @@ void logger::render_fun_prefix(std::ostream& out, const char* pretty_fun) {
void logger::render_fun_name(std::ostream& out, const char* pretty_fun) { void logger::render_fun_name(std::ostream& out, const char* pretty_fun) {
// Find the end of the function name by looking for the opening parenthesis // Find the end of the function name by looking for the opening parenthesis
// trailing it. // trailing it.
const char* e = nullptr; // safe, because pretty_fun is null-terminated CAF_ASSERT(pretty_fun != nullptr);
auto i = std::find_if(pretty_fun, e, const char* e = strchr(pretty_fun, '(');
[](char x) { return x == '(' || x == '\0'; }); if (e == nullptr)
if (*i == '\0')
return; return;
/// Now look for the beginning of the function name. /// Now look for the beginning of the function name.
using rev_iter = std::reverse_iterator<const char*>; using rev_iter = std::reverse_iterator<const char*>;
auto b = std::find_if(rev_iter(i), rev_iter(pretty_fun), auto b = std::find_if(rev_iter(e), rev_iter(pretty_fun),
[](char x) { return x == ':' || x == ' '; }); [](char x) { return x == ':' || x == ' '; });
out.write(b.base(), i - b.base()); out.write(b.base(), e - b.base());
} }
void logger::render_time_diff(std::ostream& out, timestamp t0, timestamp tn) { void logger::render_time_diff(std::ostream& out, timestamp t0, timestamp tn) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment