Skip to contentSkip to conversation

libtraceevent: Add support for nested ?: conditionals

PATCH New Steven Rostedt 1 participant 1 message Apr 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Add support for nested ?: conditionals

From: "Steven Rostedt (Google)" <[email protected]>

It was reported that nested ?: conditionals were broken in libtraceevent. Specifically, the following did not parse correctly:

	REC->severity == AER_CORRECTABLE ? "Corrected" :
		REC->severity == AER_FATAL ?
		"Fatal" : "Uncorrected, non-fatal",

That was due to the second half of the ':' operator was not being evaluated.

---
 src/event-parse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
src/event-parse.c +10 -0
index ba6e42b..aa16d83 100644
@@ -2083,6 +2083,16 @@ process_cond(struct tep_event *event, struct tep_print_arg *top, char **tok)
 
 	type = process_arg(event, right, &token);
 
+ againagain:
+	if (type == TEP_EVENT_ERROR)
+		goto out_free;
+
+	/* Handle other operations in the results */
+	if (type == TEP_EVENT_OP) {
+		type = process_op(event, right, &token);
+		goto againagain;
+	}
+
 	top->op.right = arg;
 
 	*tok = token;
Signature · 1 line
2.47.2