From 610e7c73a12d629d00113e7d16dd00cda7b1d49f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 15 Oct 2013 13:04:42 +0000 Subject: [PATCH] tsan: refactor overly-complex logical condition git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192698 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_libignore.cc | 56 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/sanitizer_common/sanitizer_libignore.cc b/lib/sanitizer_common/sanitizer_libignore.cc index 82841318a..9e1781996 100644 --- a/lib/sanitizer_common/sanitizer_libignore.cc +++ b/lib/sanitizer_common/sanitizer_libignore.cc @@ -46,39 +46,45 @@ void LibIgnore::OnLibraryLoaded(const char *name) { BlockingMutexLock lock(&mutex_); MemoryMappingLayout proc_maps(/*cache_enabled*/false); - InternalScopedBuffer fn(4096); + InternalScopedBuffer module(4096); for (uptr i = 0; i < count_; i++) { Lib *lib = &libs_[i]; bool loaded = false; proc_maps.Reset(); uptr b, e, off, prot; - while (proc_maps.Next(&b, &e, &off, fn.data(), fn.size(), &prot)) { + while (proc_maps.Next(&b, &e, &off, module.data(), module.size(), &prot)) { + if ((prot & MemoryMappingLayout::kProtectionExecute) == 0) + continue; + bool matched = false; bool symlink = false; - if (((prot & MemoryMappingLayout::kProtectionExecute) != 0) && - (TemplateMatch(lib->templ, fn.data()) || - // Resolve symlinks. - (real_name != 0 && real_name[0] != 0 && + if (TemplateMatch(lib->templ, module.data())) + matched = true; + // Resolve symlinks. + if (real_name != 0 && real_name[0] != 0 && TemplateMatch(lib->templ, name) && - internal_strcmp(real_name, fn.data()) == 0 && - (symlink = true)))) { - if (loaded) { - Report("%s: called_from_lib suppression '%s' is matched against" - " 2 libraries: '%s' and '%s'\n", - SanitizerToolName, lib->templ, lib->name, fn.data()); - Die(); - } - loaded = true; - if (!lib->loaded) { - lib->loaded = true; - lib->name = internal_strdup(fn.data()); - if (symlink) - lib->real_name = internal_strdup(real_name); - const uptr idx = atomic_load(&loaded_count_, memory_order_relaxed); - code_ranges_[idx].begin = b; - code_ranges_[idx].end = e; - atomic_store(&loaded_count_, idx + 1, memory_order_release); - } + internal_strcmp(real_name, module.data()) == 0) { + matched = true; + symlink = true; } + if (!matched) + continue; + if (loaded) { + Report("%s: called_from_lib suppression '%s' is matched against" + " 2 libraries: '%s' and '%s'\n", + SanitizerToolName, lib->templ, lib->name, module.data()); + Die(); + } + loaded = true; + if (lib->loaded) + continue; + lib->loaded = true; + lib->name = internal_strdup(module.data()); + if (symlink) + lib->real_name = internal_strdup(real_name); + const uptr idx = atomic_load(&loaded_count_, memory_order_relaxed); + code_ranges_[idx].begin = b; + code_ranges_[idx].end = e; + atomic_store(&loaded_count_, idx + 1, memory_order_release); } if (lib->loaded && !loaded) { Report("%s: library '%s' that was matched against called_from_lib" -- 2.11.4.GIT