aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorNikita Ivanov <nivanov@cloudlinux.com>2022-10-23 12:04:22 +0300
committerThomas Huth <thuth@redhat.com>2023-01-09 13:50:47 +0100
commit37b0b24e933c18269dddbf6b83f91823cacf8105 (patch)
treeb36ac8d45a9e188604e44998974d27cf6185e0f3 /block
parent8b6aa69365ca6e9bbc3bf557a6ccc5ed2b468bec (diff)
error handling: Use RETRY_ON_EINTR() macro where applicable
There is a defined RETRY_ON_EINTR() macro in qemu/osdep.h which handles the same while loop. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/415 Signed-off-by: Nikita Ivanov <nivanov@cloudlinux.com> Message-Id: <20221023090422.242617-3-nivanov@cloudlinux.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [thuth: Dropped the hunk that changed socket_accept() in libqtest.c] Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/file-posix.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index b9647c5ffc..b9955db205 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1229,9 +1229,7 @@ static int hdev_get_max_segments(int fd, struct stat *st)
ret = -errno;
goto out;
}
- do {
- ret = read(sysfd, buf, sizeof(buf) - 1);
- } while (ret == -1 && errno == EINTR);
+ ret = RETRY_ON_EINTR(read(sysfd, buf, sizeof(buf) - 1));
if (ret < 0) {
ret = -errno;
goto out;
@@ -1379,9 +1377,9 @@ static int handle_aiocb_ioctl(void *opaque)
RawPosixAIOData *aiocb = opaque;
int ret;
- do {
- ret = ioctl(aiocb->aio_fildes, aiocb->ioctl.cmd, aiocb->ioctl.buf);
- } while (ret == -1 && errno == EINTR);
+ ret = RETRY_ON_EINTR(
+ ioctl(aiocb->aio_fildes, aiocb->ioctl.cmd, aiocb->ioctl.buf)
+ );
if (ret == -1) {
return -errno;
}
@@ -1463,18 +1461,17 @@ static ssize_t handle_aiocb_rw_vector(RawPosixAIOData *aiocb)
{
ssize_t len;
- do {
- if (aiocb->aio_type & QEMU_AIO_WRITE)
- len = qemu_pwritev(aiocb->aio_fildes,
- aiocb->io.iov,
- aiocb->io.niov,
- aiocb->aio_offset);
- else
- len = qemu_preadv(aiocb->aio_fildes,
- aiocb->io.iov,
- aiocb->io.niov,
- aiocb->aio_offset);
- } while (len == -1 && errno == EINTR);
+ len = RETRY_ON_EINTR(
+ (aiocb->aio_type & QEMU_AIO_WRITE) ?
+ qemu_pwritev(aiocb->aio_fildes,
+ aiocb->io.iov,
+ aiocb->io.niov,
+ aiocb->aio_offset) :
+ qemu_preadv(aiocb->aio_fildes,
+ aiocb->io.iov,
+ aiocb->io.niov,
+ aiocb->aio_offset)
+ );
if (len == -1) {
return -errno;
@@ -1899,9 +1896,7 @@ static int allocate_first_block(int fd, size_t max_size)
buf = qemu_memalign(max_align, write_size);
memset(buf, 0, write_size);
- do {
- n = pwrite(fd, buf, write_size, 0);
- } while (n == -1 && errno == EINTR);
+ n = RETRY_ON_EINTR(pwrite(fd, buf, write_size, 0));
ret = (n == -1) ? -errno : 0;