All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] libtraceevent: Avoid a simple asprintf case
@ 2024-05-09  5:13 Ian Rogers
  2024-05-16 22:02 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2024-05-09  5:13 UTC (permalink / raw)
  To: linux-trace-devel, Steven Rostedt; +Cc: Ian Rogers

Avoid an asprintf for the single character TEP_EVENT_NEWLINE and
TEP_EVENT_DELIM case.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 src/event-parse.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index b6ae67e..16fdb46 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -1232,9 +1232,11 @@ static enum tep_event_type __read_token(struct tep_handle *tep, char **tok)
 	switch (type) {
 	case TEP_EVENT_NEWLINE:
 	case TEP_EVENT_DELIM:
-		if (asprintf(tok, "%c", ch) < 0)
+		*tok = malloc(2);
+		if (!*tok)
 			return TEP_EVENT_ERROR;
-
+		(*tok)[0] = ch;
+		(*tok)[1] = '\0';
 		return type;
 
 	case TEP_EVENT_OP:
-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-28 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09  5:13 [PATCH v1] libtraceevent: Avoid a simple asprintf case Ian Rogers
2024-05-16 22:02 ` Steven Rostedt
2024-05-16 22:09   ` Ian Rogers
2024-05-16 23:51     ` Steven Rostedt
2024-05-28 15:51       ` Ian Rogers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.