Index: compiler-rt/trunk/lib/asan/asan_malloc_mac.cc =================================================================== --- compiler-rt/trunk/lib/asan/asan_malloc_mac.cc +++ compiler-rt/trunk/lib/asan/asan_malloc_mac.cc @@ -90,9 +90,9 @@ ENSURE_ASAN_INITED(); // Allocate |strlen("asan-") + 1 + internal_strlen(name)| bytes. size_t buflen = 6 + (name ? internal_strlen(name) : 0); - InternalScopedBuffer new_name(buflen); + InternalScopedString new_name(buflen); if (name && zone->introspect == asan_zone.introspect) { - internal_snprintf(new_name.data(), buflen, "asan-%s", name); + new_name.append("asan-%s", name); name = new_name.data(); } Index: compiler-rt/trunk/lib/lsan/lsan_common.cc =================================================================== --- compiler-rt/trunk/lib/lsan/lsan_common.cc +++ compiler-rt/trunk/lib/lsan/lsan_common.cc @@ -590,10 +590,9 @@ bytes += leaks_[i].total_size; allocations += leaks_[i].hit_count; } - InternalScopedBuffer summary(kMaxSummaryLength); - internal_snprintf(summary.data(), summary.size(), - "%zu byte(s) leaked in %zu allocation(s).", bytes, - allocations); + InternalScopedString summary(kMaxSummaryLength); + summary.append("%zu byte(s) leaked in %zu allocation(s).", bytes, + allocations); ReportErrorSummary(summary.data()); } Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc @@ -166,9 +166,8 @@ void ReportErrorSummary(const char *error_message) { if (!common_flags()->print_summary) return; - InternalScopedBuffer 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 @@ int line, const char *function) { if (!common_flags()->print_summary) return; - InternalScopedBuffer 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()); } Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -339,19 +339,17 @@ // If packed = true and name != 0: .. (name is // user-supplied). static int CovOpenFile(bool packed, const char* name) { - InternalScopedBuffer 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 @@ SortArray(vb, size); MemoryMappingLayout proc_maps(/*cache_enabled*/true); uptr mb, me, off, prot; - InternalScopedBuffer module(kMaxPathLength); - InternalScopedBuffer 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 @@ } } 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)); Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc @@ -71,11 +71,9 @@ return; InternalScopedString text(kMaxTextSize); - InternalScopedBuffer modules_data(kMaxNumberOfModules * - sizeof(LoadedModule)); - LoadedModule *modules = (LoadedModule *)modules_data.data(); - CHECK(modules); - int n_modules = GetListOfModules(modules, kMaxNumberOfModules, + InternalScopedBuffer modules(kMaxNumberOfModules); + CHECK(modules.data()); + int n_modules = GetListOfModules(modules.data(), kMaxNumberOfModules, /* filter */ 0); text.append("%d\n", sizeof(uptr) * 8); Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libignore.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libignore.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libignore.cc @@ -42,9 +42,9 @@ void LibIgnore::OnLibraryLoaded(const char *name) { BlockingMutexLock lock(&mutex_); // Try to match suppressions with symlink target. - InternalScopedBuffer 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 @@ // Scan suppressions list and find newly loaded and unloaded libraries. MemoryMappingLayout proc_maps(/*cache_enabled*/false); - InternalScopedBuffer module(kMaxPathLength); + InternalScopedString module(kMaxPathLength); for (uptr i = 0; i < count_; i++) { Lib *lib = &libs_[i]; bool loaded = false; Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -370,16 +370,15 @@ DlIteratePhdrData *data = (DlIteratePhdrData*)arg; if (data->current_n == data->max_n) return 0; - InternalScopedBuffer 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; Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc @@ -293,9 +293,8 @@ if (pid == stoptheworld_tracer_pid) pid = stoptheworld_tracer_ppid; if (report_fd_pid == pid) return; - InternalScopedBuffer 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; Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_common.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_common.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_common.cc @@ -119,7 +119,7 @@ string_predicate_t filter) { Reset(); uptr cur_beg, cur_end, cur_offset, prot; - InternalScopedBuffer 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(), Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc @@ -160,7 +160,7 @@ string_predicate_t filter) { Reset(); uptr cur_beg, cur_end, prot; - InternalScopedBuffer 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(), Index: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc =================================================================== --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc @@ -143,9 +143,8 @@ } else if (internal_strcmp(flags()->profile_memory, "stderr") == 0) { mprof_fd = 2; } else { - InternalScopedBuffer filename(4096); - internal_snprintf(filename.data(), filename.size(), "%s.%d", - flags()->profile_memory, (int)internal_getpid()); + InternalScopedString filename(kMaxPathLength); + filename.append("%s.%d", flags()->profile_memory, (int)internal_getpid()); uptr openrv = OpenFile(filename.data(), true); if (internal_iserror(openrv)) { Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",