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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 tracecmd/trace-stat.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

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)
-- 
2.45.2





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux