On Wed, 5 May 2021 09:42:47 -0400 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > +static int event_enable_disable(struct tracefs_instance *instance, > + const char *system, const char *event, > + bool enable) > +{ > + regex_t system_re, event_re; > + char **systems; > + char **events = NULL; > + int ret = -1; > + int s, e; > + > + /* Handle all events first */ > + if (!system && !event) > + return enable_disable_all(instance, enable); > + > + systems = tracefs_event_systems(NULL); > + if (!systems) > + goto out_free; > + > + if (system) { > + ret = regcomp(&system_re, system, REG_ICASE|REG_NOSUB); > + if (ret < 0) > + goto out_free; > + } > + if (event) { > + ret = regcomp(&event_re, event, REG_ICASE|REG_NOSUB); > + if (ret < 0) { > + if (system) > + regfree(&system_re); > + goto out_free; > + } > + } > + > + for (s = 0; systems[s]; s++) { > + if (system && !match(systems[s], &system_re)) > + continue; > + > + /* Check for the short cut first */ > + if (!event) { > + ret = enable_disable_system(instance, systems[s], enable); > + if (ret < 0) > + break; > + ret = 0; > + continue; > + } > + > + events = tracefs_system_events(NULL, systems[s]); > + if (!events) > + continue; /* Error? */ > + > + for (e = 0; events[e]; e++) { > + if (!match(events[e], &event_re)) > + continue; > + ret = enable_disable_event(instance, systems[s], > + events[e], enable); > + if (ret < 0) > + break; > + ret = 0; > + } > + tracefs_list_free(events); > + events = NULL; > + } Bah, I need to free both the system and event regex here. Will send v2. -- Steve > + > + out_free: > + tracefs_list_free(systems); > + tracefs_list_free(events); > + return ret; > +}