diff mbox series

[1/4] trace-cmd list: Use tracefs_filter_functions()

Message ID 20241011182752.357499-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 39acb4cc1b16dbdbd3903c3ce588826391171023
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>

Instead of reading the available_filter_functions file and parsing it
manually, simply call tarcefs_filter_functions() and report what it wrote
as it does the work for us.

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

Patch

diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index fbf2882e1a83..0fbb8eabd44b 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -236,16 +236,6 @@  static void process_events(process_file_func func, const char *re, int flags)
 		regfree(&event_reg);
 }
 
-static int show_file_write(char *buf, int len, int flags)
-{
-	return fwrite(buf, 1, len, stdout);
-}
-
-static void show_file_re(const char *name, const char *re)
-{
-	process_file_re(show_file_write, name, re, 0);
-}
-
 static char *get_event_file(const char *type, char *buf, int len)
 {
 	char *system;
@@ -476,10 +466,19 @@  static void show_clocks(void)
 
 static void show_functions(const char *funcre)
 {
-	if (funcre)
-		show_file_re("available_filter_functions", funcre);
-	else
+	char **list;
+	int i;
+
+	if (!funcre) {
 		show_file("available_filter_functions");
+		return;
+	}
+
+	if (tracefs_filter_functions(funcre, NULL, &list) < 0)
+		die("Failed to read filte functions");
+	for (i = 0; list[i]; i++)
+		printf("%s\n", list[i]);
+	tracefs_list_free(list);
 }