Skip to content

Commit 2227f27

Browse files
walacrostedt
authored andcommitted
rtla/actions: Fix condition for buffer reallocation
The condition to check if the actions buffer needs to be resized was incorrect. The check `self->size >= self->len` would evaluate to true on almost every call to `actions_new()`, causing the buffer to be reallocated unnecessarily each time an action was added. Fix the condition to `self->len >= self.size`, ensuring that the buffer is only resized when it is actually full. Cc: John Kacur <jkacur@redhat.com> Cc: Luis Goncalves <lgoncalv@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Chang Yin <cyin@redhat.com> Cc: Costa Shulyupin <costa.shul@redhat.com> Cc: Crystal Wood <crwood@redhat.com> Cc: Gabriele Monaco <gmonaco@redhat.com> Link: https://lore.kernel.org/20250915181101.52513-1-wander@redhat.com Fixes: 6ea082b ("rtla/timerlat: Add action on threshold feature") Signed-off-by: Wander Lairson Costa <wander@redhat.com> Reviewed-by: Tomas Glozar <tglozar@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent b1e0ff7 commit 2227f27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/tracing/rtla/src/actions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ actions_destroy(struct actions *self)
4949
static struct action *
5050
actions_new(struct actions *self)
5151
{
52-
if (self->size >= self->len) {
52+
if (self->len >= self->size) {
5353
self->size *= 2;
5454
self->list = realloc(self->list, self->size * sizeof(struct action));
5555
}

0 commit comments

Comments
 (0)