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 <[email protected]> Cc: Luis Goncalves <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Chang Yin <[email protected]> Cc: Costa Shulyupin <[email protected]> Cc: Crystal Wood <[email protected]> Cc: Gabriele Monaco <[email protected]> Link: https://lore.kernel.org/[email protected] Fixes: 6ea082b ("rtla/timerlat: Add action on threshold feature") Signed-off-by: Wander Lairson Costa <[email protected]> Reviewed-by: Tomas Glozar <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
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)