aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-04-20 17:26:18 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2022-04-21 17:09:09 +0400
commitd0dedf2f4c116293d82d0bda510e4bb4d7dfac26 (patch)
tree586d01133845a34913637ba26d2a1eca3bb11991 /util
parentc3e5704af19ac6e28098a73849a65cad83b80d00 (diff)
downloadqemu-d0dedf2f4c116293d82d0bda510e4bb4d7dfac26.zip
qemu-d0dedf2f4c116293d82d0bda510e4bb4d7dfac26.tar.gz
qemu-d0dedf2f4c116293d82d0bda510e4bb4d7dfac26.tar.bz2
util: simplify write in signal handler
Use qemu_write_full() instead of open-coding a write loop. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220420132624.2439741-36-marcandre.lureau@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/compatfd.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/util/compatfd.c b/util/compatfd.c
index ab810c4..55b6e0b 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -42,25 +42,11 @@ static void *sigwait_compat(void *opaque)
}
} else {
struct qemu_signalfd_siginfo buffer;
- size_t offset = 0;
-
memset(&buffer, 0, sizeof(buffer));
buffer.ssi_signo = sig;
- while (offset < sizeof(buffer)) {
- ssize_t len;
-
- len = write(info->fd, (char *)&buffer + offset,
- sizeof(buffer) - offset);
- if (len == -1 && errno == EINTR) {
- continue;
- }
-
- if (len <= 0) {
- return NULL;
- }
-
- offset += len;
+ if (qemu_write_full(info->fd, &buffer, sizeof(buffer)) != sizeof(buffer)) {
+ return NULL;
}
}
}