Skip to contentSkip to conversation

libtraceevent: Do not print message if wakeup success field is missing

PATCH New Steven Rostedt 1 participant 1 message Aug 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Do not print message if wakeup success field is missing

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

The "success" field for sched wakeup has been hardcoded as "1" for years now, because it is no longer anything but successful. The sched wakeup plugin had the "err" parameter of tep_get_field_val() backwards, where it had no message for fields it expects to see, but will show a error message for the success field, which may not be there.

Fixes 4f6857aa ("tools lib traceevent: Add sched_switch plugin")
---
 plugins/plugin_sched_switch.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
plugins/plugin_sched_switch.c +6 -6
index e12fa10..73145ff 100644
@@ -67,13 +67,13 @@ static int sched_wakeup_handler(struct trace_seq *s,
 	}
 	trace_seq_printf(s, "%lld", val);
 
-	if (tep_get_field_val(s, event, "prio", record, &val, 0) == 0)
+	if (tep_get_field_val(s, event, "prio", record, &val, 1) == 0)
 		trace_seq_printf(s, " [%lld]", val);
 
-	if (tep_get_field_val(s, event, "success", record, &val, 1) == 0)
+	if (tep_get_field_val(s, event, "success", record, &val, 0) == 0)
 		trace_seq_printf(s, " success=%lld", val);
 
-	if (tep_get_field_val(s, event, "target_cpu", record, &val, 0) == 0)
+	if (tep_get_field_val(s, event, "target_cpu", record, &val, 1) == 0)
 		trace_seq_printf(s, " CPU:%03llu", val);
 
 	return 0;
@@ -96,10 +96,10 @@ static int sched_switch_handler(struct trace_seq *s,
 	}
 	trace_seq_printf(s, "%lld ", val);
 
-	if (tep_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
+	if (tep_get_field_val(s, event, "prev_prio", record, &val, 1) == 0)
 		trace_seq_printf(s, "[%d] ", (int) val);
 
-	if (tep_get_field_val(s,  event, "prev_state", record, &val, 0) == 0)
+	if (tep_get_field_val(s,  event, "prev_state", record, &val, 1) == 0)
 		write_state(s, val);
 
 	trace_seq_puts(s, " ==> ");
@@ -114,7 +114,7 @@ static int sched_switch_handler(struct trace_seq *s,
 	}
 	trace_seq_printf(s, "%lld", val);
 
-	if (tep_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
+	if (tep_get_field_val(s, event, "next_prio", record, &val, 1) == 0)
 		trace_seq_printf(s, " [%d]", (int) val);
 
 	return 0;
Signature · 1 line
2.31.1