[01/38] trace-cmd recorder: Check if pipe_size was modified by fcntl(F_GETPIPE_SZ)
diff mbox series

Message ID 20180103175334.859984736@goodmis.org
State New, archived
Headers show
Series
  • trace-cmd: Simplify the msg handling
Related show

Commit Message

Steven Rostedt Jan. 3, 2018, 5:52 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If fcntl() does not support F_GETPIPE_SZ, it may still return success, but
not modify the page_size variable that was passed to it. Initialize the
page_size variable to zero, and if it is not modified by fcntl() then set it
to page_size as well.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 trace-recorder.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/trace-recorder.c b/trace-recorder.c
index 08bd90528b7a..75290285d82f 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -121,7 +121,7 @@  tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
 {
 	struct tracecmd_recorder *recorder;
 	char *path = NULL;
-	int pipe_size;
+	int pipe_size = 0;
 	int ret;
 
 	recorder = malloc(sizeof(*recorder));
@@ -183,9 +183,10 @@  tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
 		/*
 		 * F_GETPIPE_SZ was introduced in 2.6.35, ftrace was introduced
 		 * in 2.6.31. If we are running on an older kernel, just fall
-		 * back to using page_size for splice().
+		 * back to using page_size for splice(). It could also return
+		 * success, but not modify pipe_size.
 		 */
-		if (ret < 0)
+		if (ret < 0 || !pipe_size)
 			pipe_size = recorder->page_size;
 
 		recorder->pipe_size = pipe_size;