[1/3] trace-cmd: Fix check for trigger file in create_event()
diff mbox series

Message ID 20200325140829.184651-2-tz.stoyanov@gmail.com
State Accepted
Commit 7f21e017511dadbfaad808bef6d033713fe8edf9
Delegated to: Steven Rostedt
Headers show
  • Fix applying triggers to multiple events
Related show

Commit Message

Tzvetomir Stoyanov (VMware) March 25, 2020, 2:08 p.m. UTC
When a trigger is configured on an event with trace-cmd "-R"
option there is a check in create_event() if the trigger file
exist, using the stat() call. It returns 0 if the file exists
or -1 in case of an error. The check of the stat()'s return code
is for positive number, which is always false and errors are never

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
 tracecmd/trace-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff mbox series

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index c8c853f8..ec3bcae9 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2707,7 +2707,7 @@  create_event(struct buffer_instance *instance, char *path, struct event_list *ol
 		if (ret < 0)
 			die("Failed to allocate trigger path for %s", path);
 		ret = stat(p, &st);
-		if (ret > 0)
+		if (ret < 0)
 			die("trigger specified but not supported by this kernel");
 		event->trigger_file = p;