From 8c0e3e9dad2830d8c0f5ee3793df5ca124fc9dc1 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Tue, 16 Jul 2024 21:54:13 +0100 Subject: [PATCH] When checking how many bytes were written, place the constant to the left of the equality check to match the rest of the code (this avoids accidental assignment if one equals sign is accidentally written instead of two), and write the appropriate debug message depending on whether the write was interrupted or it was empty. --- src/pv/transfer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pv/transfer.c b/src/pv/transfer.c index 12389d5..61af8d4 100644 --- a/src/pv/transfer.c +++ b/src/pv/transfer.c @@ -798,8 +798,12 @@ static int pv__transfer_write(pvstate_t state, bool *eof_in, bool *eof_out, long * returned 0 (not an error), just wait a bit and then return zero, * since this was a transient error. */ - if ((nwritten == 0) || (EINTR == errno) || (EAGAIN == errno)) { - debug("%s: %s", "transient write error - waiting briefly", strerror(errno)); + if ((0 == nwritten) || (EINTR == errno) || (EAGAIN == errno)) { + if (0 == nwritten) { + debug("%s", "write returned zero - waiting briefly", strerror(errno)); + } else { + debug("%s: %s", "transient write error - waiting briefly", strerror(errno)); + } (void) is_data_ready(-1, NULL, -1, NULL, 10000); return 0; }