From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx> 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@xxxxxxxxxxx> --- tracecmd/trace-list.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) 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); } -- 2.45.2