From: Stefan Hajnoczi Date: Mon, 22 Feb 2021 11:49:31 +0000 (+0000) Subject: vhost: simplify vhost_dev_init() fail_busyloop label X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1d8d014e936a49795de95a35a2a1ab8000ab2e5b;p=qmiga%2Fqemu.git vhost: simplify vhost_dev_init() fail_busyloop label Requiring a conditional for every goto is tedious: if (busyloop_timeout) { goto fail_busyloop; } else { goto fail; } Move the conditional to into the fail_busyloop label so that it's safe to jump to this label unconditionally. This change makes the migrate_add_blocker() error case more consistent. It jumped to fail_busyloop unconditionally whereas the memslots limits error case was conditional. Signed-off-by: Stefan Hajnoczi Message-Id: <20210222114931.272308-1-stefanha@redhat.com> Reviewed-by: Stefano Garzarella Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6e17d631f7..2a01662b08 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1388,18 +1388,16 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, error_report("vhost backend memory slots limit is less" " than current number of present memory slots"); r = -1; - if (busyloop_timeout) { - goto fail_busyloop; - } else { - goto fail; - } + goto fail_busyloop; } return 0; fail_busyloop: - while (--i >= 0) { - vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0); + if (busyloop_timeout) { + while (--i >= 0) { + vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0); + } } fail: hdev->nvqs = n_initialized_vqs;