Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <wander@redhat.com>
Link: https://lore.kernel.org/r/20260309195040.1019085-3-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>

authored by

Wander Lairson Costa and committed by
Tomas Glozar
b8f7f49a 009a8e68

+2 -4
+2 -4
tools/tracing/rtla/src/actions.c
··· 69 69 70 70 self->present[ACTION_TRACE_OUTPUT] = true; 71 71 action->type = ACTION_TRACE_OUTPUT; 72 - action->trace_output = calloc_fatal(strlen(trace_output) + 1, sizeof(char)); 73 - strcpy(action->trace_output, trace_output); 72 + action->trace_output = strdup_fatal(trace_output); 74 73 } 75 74 76 75 /* ··· 96 97 97 98 self->present[ACTION_SHELL] = true; 98 99 action->type = ACTION_SHELL; 99 - action->command = calloc_fatal(strlen(command) + 1, sizeof(char)); 100 - strcpy(action->command, command); 100 + action->command = strdup_fatal(command); 101 101 } 102 102 103 103 /*