Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 34d11e5

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Avoid calling snprintf in bionic_trace_begin."
2 parents 7d961a1 + e1d121b commit 34d11e5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libc/bionic/bionic_systrace.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "private/bionic_systrace.h"
2525
#include "private/CachedProperty.h"
2626

27+
#include <async_safe/log.h>
2728
#include <cutils/trace.h> // For ATRACE_TAG_BIONIC.
2829

2930
#define WRITE_OFFSET 32
@@ -65,7 +66,7 @@ void bionic_trace_begin(const char* message) {
6566
// kernel trace_marker.
6667
int length = strlen(message);
6768
char buf[length + WRITE_OFFSET];
68-
size_t len = snprintf(buf, length + WRITE_OFFSET, "B|%d|%s", getpid(), message);
69+
size_t len = async_safe_format_buffer(buf, length + WRITE_OFFSET, "B|%d|%s", getpid(), message);
6970

7071
// Tracing may stop just after checking property and before writing the message.
7172
// So the write is acceptable to fail. See b/20666100.

0 commit comments

Comments
 (0)