diff mbox series

[08/10] trace-cmd library: Return the result of tracefs_cpu_stop()

Message ID 20230106183930.12565-9-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 102d78c5198f407de2f7015ae0ce4a6c0894b911
Headers show
Series trace-cmd: Fix trace-cmd stream | expand

Commit Message

Steven Rostedt Jan. 6, 2023, 6:39 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Ideally, tracefs_cpu_stop() is suppose to return zero if it guaranteed to
stop the recorders (but this may not be true if called from a signal
handler). Return the result of tracefs_cpu_stop() in
tracecmd_stop_recording().

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/include/private/trace-cmd-private.h |  2 +-
 lib/trace-cmd/trace-recorder.c                    | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index e8b0989ac67e..05c084ceea41 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -377,7 +377,7 @@  struct tracecmd_recorder *tracecmd_create_buffer_recorder(const char *file, int
 struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb(const char *file, int cpu, unsigned flags, struct tracefs_instance *instance, int maxkb);
 
 int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long sleep);
-void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
+int tracecmd_stop_recording(struct tracecmd_recorder *recorder);
 long tracecmd_flush_recording(struct tracecmd_recorder *recorder, bool finish);
 
 enum tracecmd_msg_flags {
diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
index db159e5e5d14..23499f308156 100644
--- a/lib/trace-cmd/trace-recorder.c
+++ b/lib/trace-cmd/trace-recorder.c
@@ -102,9 +102,9 @@  void tracecmd_free_recorder(struct tracecmd_recorder *recorder)
 	free(recorder);
 }
 
-static void set_nonblock(struct tracecmd_recorder *recorder)
+static int set_nonblock(struct tracecmd_recorder *recorder)
 {
-	tracefs_cpu_stop(recorder->tcpu);
+	return tracefs_cpu_stop(recorder->tcpu);
 }
 
 static struct tracecmd_recorder *
@@ -437,12 +437,12 @@  int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long s
 	return 0;
 }
 
-void tracecmd_stop_recording(struct tracecmd_recorder *recorder)
+int tracecmd_stop_recording(struct tracecmd_recorder *recorder)
 {
 	if (!recorder)
-		return;
-
-	set_nonblock(recorder);
+		return -1;
 
 	recorder->stop = 1;
+
+	return set_nonblock(recorder);
 }