Skip to content

[Sanitizer][NFC] Replaces a few InternalScopedString::AppendF with InternalScopedString::Append #80574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler-rt/lib/asan/asan_descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr,
InternalScopedString str;
str.AppendF(" [%zd, %zd)", var.beg, var_end);
// Render variable name.
str.AppendF(" '");
str.Append(" '");
for (uptr i = 0; i < var.name_len; ++i) {
str.AppendF("%c", var.name_pos[i]);
}
str.AppendF("'");
str.Append("'");
if (var.line > 0) {
str.AppendF(" (line %zd)", var.line);
}
Expand All @@ -260,7 +260,7 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr,
str.AppendF("%s <== Memory access at offset %zd %s this variable%s\n",
d.Location(), addr, pos_descr, d.Default());
} else {
str.AppendF("\n");
str.Append("\n");
}
Printf("%s", str.data());
}
Expand Down
22 changes: 11 additions & 11 deletions compiler-rt/lib/hwasan/hwasan_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static void PrintTagInfoAroundAddr(uptr addr, uptr num_rows,
print_tag(s, row + i);
s.Append(row + i == addr ? "]" : " ");
}
s.AppendF("\n");
s.Append("\n");
}
}

Expand Down Expand Up @@ -418,10 +418,10 @@ static void PrintTagsAroundAddr(uptr addr, GetTag get_tag,
tag_t short_tag = get_short_tag(tag_addr);
s.AppendF("%02x", short_tag);
} else {
s.AppendF("..");
s.Append("..");
}
});
s.AppendF(
s.Append(
"See "
"https://clang.llvm.org/docs/"
"HardwareAssistedAddressSanitizerDesign.html#short-granules for a "
Expand Down Expand Up @@ -947,16 +947,16 @@ TailOverwrittenReport::~TailOverwrittenReport() {

InternalScopedString s;
u8 *tail = tail_copy;
s.AppendF("Tail contains: ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF(".. ");
s.Append("Tail contains: ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.Append(".. ");
for (uptr i = 0; i < tail_size; i++) s.AppendF("%02x ", tail[i]);
s.AppendF("\n");
s.AppendF("Expected: ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF(".. ");
s.Append("\n");
s.Append("Expected: ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.Append(".. ");
for (uptr i = 0; i < tail_size; i++) s.AppendF("%02x ", actual_expected[i]);
s.AppendF("\n");
s.AppendF(" ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF(" ");
s.Append("\n");
s.Append(" ");
for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.Append(" ");
for (uptr i = 0; i < tail_size; i++)
s.AppendF("%s ", actual_expected[i] != tail[i] ? "^^" : " ");

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/memprof/memprof_descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void DescribeThread(MemprofThreadContext *context) {
InternalScopedString str;
str.AppendF("Thread %s", MemprofThreadIdAndName(context).c_str());
if (context->parent_tid == kInvalidTid) {
str.AppendF(" created by unknown thread\n");
str.Append(" created by unknown thread\n");
Printf("%s", str.data());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StackTraceTextPrinter {

if (dedup_frames_-- > 0) {
if (dedup_token_->length())
dedup_token_->AppendF("--");
dedup_token_->Append("--");
if (stack->info.function)
dedup_token_->Append(stack->info.function);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ void StackTrace::PrintTo(InternalScopedString *output) const {
output, &dedup_token);

if (trace == nullptr || size == 0) {
output->AppendF(" <empty stack>\n\n");
output->Append(" <empty stack>\n\n");
return;
}

Expand All @@ -111,7 +111,7 @@ void StackTrace::PrintTo(InternalScopedString *output) const {
}

// Always add a trailing empty line after stack trace.
output->AppendF("\n");
output->Append("\n");

// Append deduplication token, if non-empty.
if (dedup_token.length())
Expand Down Expand Up @@ -198,7 +198,7 @@ void __sanitizer_symbolize_pc(uptr pc, const char *fmt, char *out_buf,
StackTraceTextPrinter printer(fmt, '\0', &output, nullptr);
if (!printer.ProcessAddressFrames(pc)) {
output.clear();
output.AppendF("<can't symbolize>");
output.Append("<can't symbolize>");
}
CopyStringToBuffer(output, out_buf, out_buf_size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ static void MaybeBuildIdToBuffer(const AddressInfo &info, bool PrefixSpace,
InternalScopedString *buffer) {
if (info.uuid_size) {
if (PrefixSpace)
buffer->AppendF(" ");
buffer->AppendF("(BuildId: ");
buffer->Append(" ");
buffer->Append("(BuildId: ");
for (uptr i = 0; i < info.uuid_size; ++i) {
buffer->AppendF("%02x", info.uuid[i]);
}
buffer->AppendF(")");
buffer->Append(")");
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@ void FormattedStackTracePrinter::RenderFrame(InternalScopedString *buffer,
MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
#endif
} else {
buffer->AppendF("(<unknown module>)");
buffer->Append("(<unknown module>)");
}
break;
case 'M':
Expand Down Expand Up @@ -339,7 +339,7 @@ void StackTracePrinter::RenderSourceLocation(InternalScopedString *buffer,
buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
if (column > 0)
buffer->AppendF(",%d", column);
buffer->AppendF(")");
buffer->Append(")");
return;
}

Expand Down