[PATCH v1] libtracefs: Fix the read file failure code checking
Haiyue Wang <[email protected]> Fri, 14 Feb 2025 20:35:17 +0800
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
The failure error code '-1' will be treated as 'true'. Only nonzero number has buffer data returned successfully. Signed-off-by: Haiyue Wang <[email protected]> --- src/tracefs-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-record.c b/src/tracefs-record.c index a2dcfc2..6abc3aa 100644 --- a/src/tracefs-record.c +++ b/src/tracefs-record.c @@ -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); -- 2.48.1