Message ID | 20250214123531.13883-1-haiyuewa@163.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v1] libtracefs: Fix the read file failure code checking | expand |
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);
The failure error code '-1' will be treated as 'true'. Only nonzero number has buffer data returned successfully. Signed-off-by: Haiyue Wang <haiyuewa@163.com> --- src/tracefs-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)