Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/virtio: Use tools/include/list.h instead of stubs

It should not make any significant difference but reduce stub code.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Link: https://lore.kernel.org/r/20200418102217.32327-9-eperezma@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Eugenio Pérez and committed by
Michael S. Tsirkin
cb91909e 1d8bf5c3

+6 -9
+1 -6
tools/virtio/linux/kernel.h
··· 11 11 12 12 #include <linux/compiler.h> 13 13 #include <linux/types.h> 14 + #include <linux/list.h> 14 15 #include <linux/printk.h> 15 16 #include <linux/bug.h> 16 17 #include <errno.h> ··· 135 134 typeof(y) _min2 = (y); \ 136 135 (void) (&_min1 == &_min2); \ 137 136 _min1 < _min2 ? _min1 : _min2; }) 138 - 139 - /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ 140 - #define list_add_tail(a, b) do {} while (0) 141 - #define list_del(a) do {} while (0) 142 - #define list_for_each_entry(a, b, c) while (0) 143 - /* end of stubs */ 144 137 145 138 #endif /* KERNEL_H */
+2 -3
tools/virtio/linux/virtio.h
··· 11 11 struct virtio_device { 12 12 struct device dev; 13 13 u64 features; 14 + struct list_head vqs; 14 15 }; 15 16 16 17 struct virtqueue { 17 - /* TODO: commented as list macros are empty stubs for now. 18 - * Broken but enough for virtio_ring.c 19 - * struct list_head list; */ 18 + struct list_head list; 20 19 void (*callback)(struct virtqueue *vq); 21 20 const char *name; 22 21 struct virtio_device *vdev;
+1
tools/virtio/virtio_test.c
··· 129 129 int r; 130 130 memset(dev, 0, sizeof *dev); 131 131 dev->vdev.features = features; 132 + INIT_LIST_HEAD(&dev->vdev.vqs); 132 133 dev->buf_size = 1024; 133 134 dev->buf = malloc(dev->buf_size); 134 135 assert(dev->buf);
+2
tools/virtio/vringh_test.c
··· 307 307 close(to_host[0]); 308 308 309 309 gvdev.vdev.features = features; 310 + INIT_LIST_HEAD(&gvdev.vdev.vqs); 310 311 gvdev.to_host_fd = to_host[1]; 311 312 gvdev.notifies = 0; 312 313 ··· 454 453 455 454 getrange = getrange_iov; 456 455 vdev.features = 0; 456 + INIT_LIST_HEAD(&vdev.vqs); 457 457 458 458 while (argv[1]) { 459 459 if (strcmp(argv[1], "--indirect") == 0)