diff mbox series

libtracefs: Fix event_enable_disable() return value

Message ID 20210528113731.167831-1-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series libtracefs: Fix event_enable_disable() return value | expand

Commit Message

Yordan Karadzhov May 28, 2021, 11:37 a.m. UTC
event_enable_disable() is a static method used internally by the
tracefs_event_enable/disable() API. The returned value do not obey
the description given in the documentation for some specific use-cases.

Fixes: fc94d1a (libtracefs: Add tracefs_event_enable/disable() API)
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/tracefs-events.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 55316c6..9adfd25 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -833,12 +833,12 @@  static int event_enable_disable(struct tracefs_instance *instance,
 	regex_t system_re, event_re;
 	char **systems;
 	char **events = NULL;
-	int ret = -1;
+	int ret;
 	int s, e;
 
 	/* Handle all events first */
 	if (!system && !event)
-		return enable_disable_all(instance, enable);
+		return enable_disable_all(instance, enable) < 0 ? -1 : 0;
 
 	systems = tracefs_event_systems(NULL);
 	if (!systems)
@@ -858,6 +858,7 @@  static int event_enable_disable(struct tracefs_instance *instance,
 		}
 	}
 
+	ret = -1;
 	for (s = 0; systems[s]; s++) {
 		if (system && !match(systems[s], &system_re))
 			continue;