From 32b5f633769c1d28bfa42f041e8299973fdec07c Mon Sep 17 00:00:00 2001 From: ck <84600276+critkitten@users.noreply.github.com> Date: Sun, 18 Jun 2023 17:56:17 +0200 Subject: [PATCH] fix ssize_t bytes_written; if (receive_file != -1) { bytes_written = write(receive_file, buf, length); if (bytes_written != length) { // handle the error, e.g., print an error message or break the loop error("write() failed: fix ssize_t bytes_written; if (receive_file != -1) { bytes_written = write(receive_file, buf, length); if (bytes_written != length) { // handle the error, e.g., print an error message or brea --- amidi/amidi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/amidi/amidi.c b/amidi/amidi.c index ae2143c..d67dffb 100644 --- a/amidi/amidi.c +++ b/amidi/amidi.c @@ -728,9 +728,18 @@ int main(int argc, char *argv[]) if (length == 0) continue; read += length; + + ssize_t bytes_written; + + if (receive_file != -1) { + bytes_written = write(receive_file, buf, length); + if (bytes_written != length) { + // handle the error, e.g., print an error message or break the loop + error("write() failed: %s", strerror(errno)); + break; + } + } - if (receive_file != -1) - write(receive_file, buf, length); if (dump) { for (i = 0; i < length; ++i) print_byte(buf[i], &ts);