diff mbox series

[4/4] trace-cmd stat: Use tracefs_instances() instead of walking them

Message ID 20241011182752.357499-5-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 908d122e3682146b135d77852fc263d10a960c95
Headers show
Series trace-cmd: Various updates | expand

Commit Message

Steven Rostedt Oct. 11, 2024, 6:26 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Use the new tracefs_instances() function to retrieve a list of instances
on the system instead of calling tracefs_instance_walk() and having a
helper function do the printing. This simplifies the code a bit.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-stat.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index 1d95d9934b47..7ac62f2a3076 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -113,23 +113,23 @@  static void report_file(struct buffer_instance *instance,
 	free(str);
 }
 
-static int report_instance(const char *name, void *data)
+static void report_instances(void)
 {
-	bool *first = (bool *)data;
+	char **list;
+	int i;
 
-	if (*first) {
-		*first = false;
-		printf("\nInstances:\n");
-	}
-	printf(" %s\n", name);
-	return 0;
-}
+	list = tracefs_instances(NULL);
 
-static void report_instances(void)
-{
-	bool first = true;
+	if (!list || !list[0])
+		goto out;
+
+	printf("\nInstances:\n");
 
-	tracefs_instances_walk(report_instance, &first);
+	for (i = 0; list[i]; i++)
+		printf(" %s\n", list[i]);
+
+ out:
+	tracefs_list_free(list);
 }
 
 struct event_iter *trace_event_iter_alloc(const char *path)