diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2014-12-02 22:20:11 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-12-02 22:20:11 +0000 |
| commit | 656c29b08f1d32071b63d413a209cd418b5240fa (patch) | |
| tree | a0e9d9e30323264a66b92415ffe744ac83a0237b /compiler-rt/lib/sanitizer_common | |
| parent | 5618e73a459a9144c1fc988f5a72d093b7f587eb (diff) | |
| download | bcm5719-llvm-656c29b08f1d32071b63d413a209cd418b5240fa.tar.gz bcm5719-llvm-656c29b08f1d32071b63d413a209cd418b5240fa.zip | |
Replace InternalScopedBuffer<char> with InternalScopedString where applicable.
Summary: No functionality change.
Test Plan: make check-all
Reviewers: kcc
Reviewed By: kcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D6472
llvm-svn: 223164
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
8 files changed, 31 insertions, 38 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc index c77e50e7069..737177c9d9b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc @@ -166,9 +166,8 @@ const char *StripModuleName(const char *module) { void ReportErrorSummary(const char *error_message) { if (!common_flags()->print_summary) return; - InternalScopedBuffer<char> buff(kMaxSummaryLength); - internal_snprintf(buff.data(), buff.size(), - "SUMMARY: %s: %s", SanitizerToolName, error_message); + InternalScopedString buff(kMaxSummaryLength); + buff.append("SUMMARY: %s: %s", SanitizerToolName, error_message); __sanitizer_report_error_summary(buff.data()); } @@ -176,11 +175,11 @@ void ReportErrorSummary(const char *error_type, const char *file, int line, const char *function) { if (!common_flags()->print_summary) return; - InternalScopedBuffer<char> buff(kMaxSummaryLength); - internal_snprintf( - buff.data(), buff.size(), "%s %s:%d %s", error_type, - file ? StripPathPrefix(file, common_flags()->strip_path_prefix) : "??", - line, function ? function : "??"); + InternalScopedString buff(kMaxSummaryLength); + buff.append("%s %s:%d %s", error_type, + file ? StripPathPrefix(file, common_flags()->strip_path_prefix) + : "??", + line, function ? function : "??"); ReportErrorSummary(buff.data()); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc index b14f5b73474..3fa8a18696f 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -339,19 +339,17 @@ static void CovWritePacked(int pid, const char *module, const void *blob, // If packed = true and name != 0: <name>.<sancov>.<packed> (name is // user-supplied). static int CovOpenFile(bool packed, const char* name) { - InternalScopedBuffer<char> path(kMaxPathLength); + InternalScopedString path(kMaxPathLength); if (!packed) { CHECK(name); - internal_snprintf((char *)path.data(), path.size(), "%s/%s.%zd.sancov", - common_flags()->coverage_dir, name, internal_getpid()); + path.append("%s/%s.%zd.sancov", common_flags()->coverage_dir, name, + internal_getpid()); } else { if (!name) - internal_snprintf((char *)path.data(), path.size(), - "%s/%zd.sancov.packed", common_flags()->coverage_dir, - internal_getpid()); + path.append("%s/%zd.sancov.packed", common_flags()->coverage_dir, + internal_getpid()); else - internal_snprintf((char *)path.data(), path.size(), "%s/%s.sancov.packed", - common_flags()->coverage_dir, name); + path.append("%s/%s.sancov.packed", common_flags()->coverage_dir, name); } uptr fd = OpenFile(path.data(), true); if (internal_iserror(fd)) { @@ -465,8 +463,8 @@ static void CovDump() { SortArray(vb, size); MemoryMappingLayout proc_maps(/*cache_enabled*/true); uptr mb, me, off, prot; - InternalScopedBuffer<char> module(kMaxPathLength); - InternalScopedBuffer<char> path(kMaxPathLength); + InternalScopedString module(kMaxPathLength); + InternalScopedString path(kMaxPathLength); for (int i = 0; proc_maps.Next(&mb, &me, &off, module.data(), module.size(), &prot); i++) { @@ -492,9 +490,9 @@ static void CovDump() { } } else { // One file per module per process. - internal_snprintf((char *)path.data(), path.size(), "%s/%s.%zd.sancov", - common_flags()->coverage_dir, module_name, - internal_getpid()); + path.clear(); + path.append("%s/%s.%zd.sancov", common_flags()->coverage_dir, + module_name, internal_getpid()); int fd = CovOpenFile(false /* packed */, module_name); if (fd > 0) { internal_write(fd, offsets.data(), offsets.size() * sizeof(u32)); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc index dddf2f0d5e6..fe72d06a2fb 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc @@ -71,11 +71,9 @@ void CovUpdateMapping(uptr caller_pc) { return; InternalScopedString text(kMaxTextSize); - InternalScopedBuffer<char> modules_data(kMaxNumberOfModules * - sizeof(LoadedModule)); - LoadedModule *modules = (LoadedModule *)modules_data.data(); - CHECK(modules); - int n_modules = GetListOfModules(modules, kMaxNumberOfModules, + InternalScopedBuffer<LoadedModule> modules(kMaxNumberOfModules); + CHECK(modules.data()); + int n_modules = GetListOfModules(modules.data(), kMaxNumberOfModules, /* filter */ 0); text.append("%d\n", sizeof(uptr) * 8); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cc b/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cc index 7567d6fbbe0..8df0467b1e9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cc @@ -42,9 +42,9 @@ void LibIgnore::Init(const SuppressionContext &supp) { void LibIgnore::OnLibraryLoaded(const char *name) { BlockingMutexLock lock(&mutex_); // Try to match suppressions with symlink target. - InternalScopedBuffer<char> buf(kMaxPathLength); + InternalScopedString buf(kMaxPathLength); if (name != 0 && internal_readlink(name, buf.data(), buf.size() - 1) > 0 && - buf.data()[0]) { + buf[0]) { for (uptr i = 0; i < count_; i++) { Lib *lib = &libs_[i]; if (!lib->loaded && lib->real_name == 0 && @@ -55,7 +55,7 @@ void LibIgnore::OnLibraryLoaded(const char *name) { // Scan suppressions list and find newly loaded and unloaded libraries. MemoryMappingLayout proc_maps(/*cache_enabled*/false); - InternalScopedBuffer<char> module(kMaxPathLength); + InternalScopedString module(kMaxPathLength); for (uptr i = 0; i < count_; i++) { Lib *lib = &libs_[i]; bool loaded = false; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc index 2ca55b48453..4e09081e7f5 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -370,16 +370,15 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) { DlIteratePhdrData *data = (DlIteratePhdrData*)arg; if (data->current_n == data->max_n) return 0; - InternalScopedBuffer<char> module_name(kMaxPathLength); - module_name.data()[0] = '\0'; + InternalScopedString module_name(kMaxPathLength); if (data->first) { data->first = false; // First module is the binary itself. ReadBinaryName(module_name.data(), module_name.size()); } else if (info->dlpi_name) { - internal_strncpy(module_name.data(), info->dlpi_name, module_name.size()); + module_name.append("%s", info->dlpi_name); } - if (module_name.data()[0] == '\0') + if (module_name[0] == '\0') return 0; if (data->filter && !data->filter(module_name.data())) return 0; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc index a15264ff0d8..23a92c5a51a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc @@ -293,9 +293,8 @@ void MaybeOpenReportFile() { if (pid == stoptheworld_tracer_pid) pid = stoptheworld_tracer_ppid; if (report_fd_pid == pid) return; - InternalScopedBuffer<char> report_path_full(kMaxPathLength); - internal_snprintf(report_path_full.data(), report_path_full.size(), - "%s.%zu", report_path_prefix, pid); + InternalScopedString report_path_full(kMaxPathLength); + report_path_full.append("%s.%zu", report_path_prefix, pid); uptr openrv = OpenFile(report_path_full.data(), true); if (internal_iserror(openrv)) { report_fd = kStderrFd; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc index 3b1a3112bfd..2ec08d7f127 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc @@ -119,7 +119,7 @@ uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules, string_predicate_t filter) { Reset(); uptr cur_beg, cur_end, cur_offset, prot; - InternalScopedBuffer<char> module_name(kMaxPathLength); + InternalScopedString module_name(kMaxPathLength); uptr n_modules = 0; for (uptr i = 0; n_modules < max_modules && Next(&cur_beg, &cur_end, &cur_offset, module_name.data(), diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc index 074b91a9b28..c0a86149788 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc @@ -160,7 +160,7 @@ uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules, string_predicate_t filter) { Reset(); uptr cur_beg, cur_end, prot; - InternalScopedBuffer<char> module_name(kMaxPathLength); + InternalScopedString module_name(kMaxPathLength); uptr n_modules = 0; for (uptr i = 0; n_modules < max_modules && Next(&cur_beg, &cur_end, 0, module_name.data(), |

