Skip to content

Commit 1d8d014

Browse files
stefanhaRHmstsirkin
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent b52fa0e commit 1d8d014

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

hw/virtio/vhost.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -1388,18 +1388,16 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
13881388
error_report("vhost backend memory slots limit is less"
13891389
" than current number of present memory slots");
13901390
r = -1;
1391-
if (busyloop_timeout) {
1392-
goto fail_busyloop;
1393-
} else {
1394-
goto fail;
1395-
}
1391+
goto fail_busyloop;
13961392
}
13971393

13981394
return 0;
13991395

14001396
fail_busyloop:
1401-
while (--i >= 0) {
1402-
vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
1397+
if (busyloop_timeout) {
1398+
while (--i >= 0) {
1399+
vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
1400+
}
14031401
}
14041402
fail:
14051403
hdev->nvqs = n_initialized_vqs;

0 commit comments

Comments
 (0)