Skip to content

Commit 4a37487

Browse files
committed
[NFC][sanitizer] Replace a few AppendF with Append
1 parent df97922 commit 4a37487

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

compiler-rt/lib/asan/asan_descriptions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void DescribeThread(AsanThreadContext *context) {
5151
InternalScopedString str;
5252
str.AppendF("Thread %s", AsanThreadIdAndName(context).c_str());
5353
if (context->parent_tid == kInvalidTid) {
54-
str.AppendF(" created by unknown thread\n");
54+
str.Append(" created by unknown thread\n");
5555
Printf("%s", str.data());
5656
return;
5757
}
@@ -126,7 +126,7 @@ static void GetAccessToHeapChunkInformation(ChunkAccess *descr,
126126
static void PrintHeapChunkAccess(uptr addr, const ChunkAccess &descr) {
127127
Decorator d;
128128
InternalScopedString str;
129-
str.AppendF("%s", d.Location());
129+
str.Append(d.Location());
130130
switch (descr.access_type) {
131131
case kAccessTypeLeft:
132132
str.AppendF("%p is located %zd bytes before", (void *)descr.bad_addr,
@@ -148,7 +148,7 @@ static void PrintHeapChunkAccess(uptr addr, const ChunkAccess &descr) {
148148
str.AppendF(" %zu-byte region [%p,%p)\n", descr.chunk_size,
149149
(void *)descr.chunk_begin,
150150
(void *)(descr.chunk_begin + descr.chunk_size));
151-
str.AppendF("%s", d.Default());
151+
str.Append(d.Default());
152152
Printf("%s", str.data());
153153
}
154154

@@ -277,7 +277,7 @@ static void DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
277277
const __asan_global &g) {
278278
InternalScopedString str;
279279
Decorator d;
280-
str.AppendF("%s", d.Location());
280+
str.Append(d.Location());
281281
if (addr < g.beg) {
282282
str.AppendF("%p is located %zd bytes before", (void *)addr, g.beg - addr);
283283
} else if (addr + access_size > g.beg + g.size) {
@@ -293,7 +293,7 @@ static void DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
293293
MaybeDemangleGlobalName(g.name));
294294
PrintGlobalLocation(&str, g);
295295
str.AppendF("' (0x%zx) of size %zu\n", g.beg, g.size);
296-
str.AppendF("%s", d.Default());
296+
str.Append(d.Default());
297297
PrintGlobalNameIfASCII(&str, g);
298298
Printf("%s", str.data());
299299
}

compiler-rt/lib/hwasan/hwasan_report.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,12 @@ static void PrintTagInfoAroundAddr(tag_t *tag_ptr, uptr num_rows,
528528
tag_t *end_row = center_row_beg + row_len * ((num_rows + 1) / 2);
529529
InternalScopedString s;
530530
for (tag_t *row = beg_row; row < end_row; row += row_len) {
531-
s.AppendF("%s", row == center_row_beg ? "=>" : " ");
531+
s.Append(row == center_row_beg ? "=>" : " ");
532532
s.AppendF("%p:", (void *)ShadowToMem(reinterpret_cast<uptr>(row)));
533533
for (uptr i = 0; i < row_len; i++) {
534-
s.AppendF("%s", row + i == tag_ptr ? "[" : " ");
534+
s.Append(row + i == tag_ptr ? "[" : " ");
535535
print_tag(s, &row[i]);
536-
s.AppendF("%s", row + i == tag_ptr ? "]" : " ");
536+
s.Append(row + i == tag_ptr ? "]" : " ");
537537
}
538538
s.AppendF("\n");
539539
}

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ void MaybeStartBackgroudThread() {}
119119
#endif
120120

121121
void WriteToSyslog(const char *msg) {
122+
if (!msg)
123+
return;
122124
InternalScopedString msg_copy;
123-
msg_copy.AppendF("%s", msg);
125+
msg_copy.Append(msg);
124126
const char *p = msg_copy.data();
125127

126128
// Print one line at a time.

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class StackTraceTextPrinter {
6363
if (dedup_frames_-- > 0) {
6464
if (dedup_token_->length())
6565
dedup_token_->AppendF("--");
66-
if (stack->info.function != nullptr)
67-
dedup_token_->AppendF("%s", stack->info.function);
66+
if (stack->info.function)
67+
dedup_token_->Append(stack->info.function);
6868
}
6969
}
7070

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
160160
p++;
161161
switch (*p) {
162162
case '%':
163-
buffer->AppendF("%%");
163+
buffer->Append("%");
164164
break;
165165
// Frame number and all fields of AddressInfo structure.
166166
case 'n':
@@ -283,7 +283,7 @@ void RenderData(InternalScopedString *buffer, const char *format,
283283
p++;
284284
switch (*p) {
285285
case '%':
286-
buffer->AppendF("%%");
286+
buffer->Append("%");
287287
break;
288288
case 's':
289289
buffer->AppendF("%s", StripPathPrefix(DI->file, strip_path_prefix));

compiler-rt/lib/ubsan/ubsan_diag.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void RenderText(InternalScopedString *Buffer, const char *Message,
223223
#else
224224
snprintf(FloatBuffer, sizeof(FloatBuffer), "%Lg", (long double)A.Float);
225225
#endif
226-
Buffer->AppendF("%s", FloatBuffer);
226+
Buffer->Append(FloatBuffer);
227227
break;
228228
}
229229
case Diag::AK_Pointer:
@@ -289,7 +289,7 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc,
289289
Buffer.AppendF("\n");
290290

291291
// Emit highlights.
292-
Buffer.AppendF("%s", Decor.Highlight());
292+
Buffer.Append(Decor.Highlight());
293293
Range *InRange = upperBound(Min, Ranges, NumRanges);
294294
for (uptr P = Min; P != Max; ++P) {
295295
char Pad = ' ', Byte = ' ';
@@ -358,7 +358,7 @@ Diag::~Diag() {
358358
Buffer.clear();
359359
}
360360

361-
Buffer.AppendF("%s", Decor.Bold());
361+
Buffer.Append(Decor.Bold());
362362
RenderLocation(&Buffer, Loc);
363363
Buffer.AppendF(":");
364364

compiler-rt/lib/ubsan/ubsan_monitor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ UndefinedBehaviorReport::UndefinedBehaviorReport(const char *IssueKind,
2323
RegisterUndefinedBehaviorReport(this);
2424

2525
// Make a copy of the diagnostic.
26-
Buffer.AppendF("%s", Msg.data());
26+
if (Msg.length())
27+
Buffer.Append(Msg.data());
2728

2829
// Let the monitor know that a report is available.
2930
__ubsan_on_report();

0 commit comments

Comments
 (0)