aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2023-11-20 15:32:57 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-01-05 16:20:15 +0100
commit9c878ad6fbfc7934c9c4f6ba607c0842202afdbb (patch)
tree21441e4eb19b3411e343cd84e17082842fe8c4c3 /hw/virtio
parentb622ee98bf784b093494a81c46667bd6e6324f1a (diff)
misc: Simplify qemu_prealloc_mem() calls
Since qemu_prealloc_mem() returns whether or not an error occured, we don't need to check the @errp pointer. Remove local_err uses when we can return directly. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Reviewed-by: Gavin Shan <gshan@redhat.com> Message-Id: <20231120213301.24349-20-philmd@linaro.org>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-mem.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index dc4709790f..99ab989852 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -605,8 +605,7 @@ static int virtio_mem_set_block_state(VirtIOMEM *vmem, uint64_t start_gpa,
int fd = memory_region_get_fd(&vmem->memdev->mr);
Error *local_err = NULL;
- qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err);
- if (local_err) {
+ if (!qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err)) {
static bool warned;
/*
@@ -1249,8 +1248,7 @@ static int virtio_mem_prealloc_range_cb(VirtIOMEM *vmem, void *arg,
int fd = memory_region_get_fd(&vmem->memdev->mr);
Error *local_err = NULL;
- qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err);
- if (local_err) {
+ if (!qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err)) {
error_report_err(local_err);
return -ENOMEM;
}