[PATCH 2/2] libtracefs: Reset errno to success on EAGAIN for the flush functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

The functions tracefs_cpu_flush() and tracefs_cpu_flush_write() both
usually end with errno = EAGAIN. This should not be passed to the calling
function, so reset it to 0.

Fixes: 26b8893efda7c ("libtracefs: Add reading of per cpu files")
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 src/tracefs-record.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/tracefs-record.c b/src/tracefs-record.c
index 71d1df99bb02..428bec0dfe3d 100644
--- a/src/tracefs-record.c
+++ b/src/tracefs-record.c
@@ -308,8 +308,11 @@ int tracefs_cpu_read(struct tracefs_cpu *tcpu, void *buffer, bool nonblock)
 	ret = read(tcpu->fd, buffer, tcpu->subbuf_size);
 
 	/* It's OK if there's no data to read */
-	if (ret < 0 && errno == EAGAIN)
+	if (ret < 0 && errno == EAGAIN) {
+		/* Reset errno */
+		errno = 0;
 		ret = 0;
+	}
 
 	return ret;
 }
@@ -470,8 +473,11 @@ int tracefs_cpu_flush(struct tracefs_cpu *tcpu, void *buffer)
 		tcpu->buffered -= ret;
 
 	/* It's OK if there's no data to read */
-	if (ret < 0 && errno == EAGAIN)
+	if (ret < 0 && errno == EAGAIN) {
+		/* Reset errno */
+		errno = 0;
 		ret = 0;
+	}
 
 	return ret;
 }
-- 
2.35.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux