From: Wander Lairson Costa Date: Mon, 9 Mar 2026 19:46:15 +0000 (-0300) Subject: rtla: Use strdup() to simplify code X-Git-Tag: v7.1-rc1~139^2~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8f7f49a23897fc772373da513a1cb6d51e5958e;p=thirdparty%2Fkernel%2Flinux.git rtla: Use strdup() to simplify code The actions_add_trace_output() and actions_add_shell() functions were using calloc() followed by strcpy() to allocate and copy a string. This can be simplified by using strdup(), which allocates memory and copies the string in a single step. Replace the calloc() and strcpy() calls with strdup(), making the code more concise and readable. Signed-off-by: Wander Lairson Costa Link: https://lore.kernel.org/r/20260309195040.1019085-3-wander@redhat.com Signed-off-by: Tomas Glozar --- diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c index 22b8283a183f3..0ac42ffd734a3 100644 --- a/tools/tracing/rtla/src/actions.c +++ b/tools/tracing/rtla/src/actions.c @@ -69,8 +69,7 @@ actions_add_trace_output(struct actions *self, const char *trace_output) self->present[ACTION_TRACE_OUTPUT] = true; action->type = ACTION_TRACE_OUTPUT; - action->trace_output = calloc_fatal(strlen(trace_output) + 1, sizeof(char)); - strcpy(action->trace_output, trace_output); + action->trace_output = strdup_fatal(trace_output); } /* @@ -97,8 +96,7 @@ actions_add_shell(struct actions *self, const char *command) self->present[ACTION_SHELL] = true; action->type = ACTION_SHELL; - action->command = calloc_fatal(strlen(command) + 1, sizeof(char)); - strcpy(action->command, command); + action->command = strdup_fatal(command); } /*