Skip to contentSkip to conversation

libtracefs: Fix the read file failure code checking

PATCH New Haiyue Wang 1 participant 1 message Feb 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Fix the read file failure code checking

The failure error code '-1' will be treated as 'true'. Only nonzero number has buffer data returned successfully.

---
 src/tracefs-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-record.c +1 -1
index a2dcfc2..6abc3aa 100644
@@ -550,7 +550,7 @@ static int init_splice(struct tracefs_cpu *tcpu)
 	if (ret < 0)
 		return ret;
 
-	if (tfs_str_read_file("/proc/sys/fs/pipe-max-size", &buf, false)) {
+	if (tfs_str_read_file("/proc/sys/fs/pipe-max-size", &buf, false) > 0) {
 		int size = atoi(buf);
 		fcntl(tcpu->splice_pipe[0], F_SETPIPE_SZ, &size);
 		free(buf);
Signature · 1 line
2.48.1