From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v2 2/2] libtracecmd: Add missing error handling to trace-compress.c
Date: Sat, 12 Apr 2025 00:49:26 +0200 [thread overview]
Message-ID: <20250411225648.6498-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20250411225648.6498-1-iii@linux.ibm.com>
Add missing error handling to a few writes.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
lib/trace-cmd/trace-compress.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/trace-cmd/trace-compress.c b/lib/trace-cmd/trace-compress.c
index e18af3dd..2a7a3e24 100644
--- a/lib/trace-cmd/trace-compress.c
+++ b/lib/trace-cmd/trace-compress.c
@@ -715,7 +715,8 @@ int tracecmd_compress_copy_from(struct tracecmd_compression *handle, int fd, int
/* save the initial offset and write 0 as initial chunk count */
offset = lseek(handle->fd, 0, SEEK_CUR);
- write_fd(handle->fd, &chunks, 4);
+ if (write_fd(handle->fd, &chunks, 4) != 4)
+ return -1;
do {
all = 0;
@@ -780,7 +781,8 @@ int tracecmd_compress_copy_from(struct tracecmd_compression *handle, int fd, int
if (read_size_val(handle->tep, chunks, &endian4) < 0)
return -1;
/* write chunks count*/
- write_fd(handle->fd, &endian4, 4);
+ if (write_fd(handle->fd, &endian4, 4) != 4)
+ return -1;
end_offset = lseek(handle->fd, 0, SEEK_END);
if (end_offset == (off_t)-1)
return -1;
@@ -989,7 +991,8 @@ int tracecmd_uncompress_copy_to(struct tracecmd_compression *handle, int fd,
if (ret < 0)
break;
- write_fd(fd, bytes_out, ret);
+ if (write_fd(fd, bytes_out, ret) != ret)
+ break;
wsize += ret;
chunks--;
}
--
2.49.0
prev parent reply other threads:[~2025-04-11 22:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 22:49 [PATCH v2 0/2] trace-cmd record: Fix compression on big-endian systems Ilya Leoshkevich
2025-04-11 22:49 ` [PATCH v2 1/2] " Ilya Leoshkevich
2025-04-11 22:49 ` Ilya Leoshkevich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250411225648.6498-3-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).