Skip to contentSkip to conversation

rtla/actions: Fix condition for buffer reallocation

PATCH In review Wander Lairson Costa 2 participants 3 messages Sep 15, 2025 – Sep 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

Fixes 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")

---
v1 -> v2
* Put the commit message in imperative language

---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/actions.c +1 -1
index aaf0808125d72..af5f76bd1821b 100644
@@ -49,7 +49,7 @@ actions_destroy(struct actions *self)
 static struct action *
 actions_new(struct actions *self)
 {
-	if (self->size >= self->len) {
+	if (self->len >= self->size) {
 		self->size *= 2;
 		self->list = realloc(self->list, self->size * sizeof(struct action));
 	}
Signature · 1 line
2.51.0
maintainer Reviewed-by on v2 1/1
#1 lore raw

po 15. 9. 2025 v 20:11 odesílatel Wander Lairson Costa <[email protected]> napsal:

Quoted 6 lines

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.

Quoted 6 lines

Fix the condition to self->len >= self.size, ensuring that the buffer is only resized when it is actually full.

Fixes 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")

The blame goes entirely on me for getting confused by my own naming of the fields. Thank you.

Tomas

maintainer
#2 lore raw
In reply to Wander Lairson Costa

Steven,

po 15. 9. 2025 v 20:11 odesílatel Wander Lairson Costa <[email protected]> napsal:

Quoted 12 lines

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.

Fixes 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
Quoted 8 lines

---
v1 -> v2
* Put the commit message in imperative language

---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Can you take this fix as well?

Thank you.

Tomas

PS: This should be all for RTLA now.