[PATCH] tools/virtio: virtio_test -h,--help should return directly

From: Rong Tao
Date: Fri Feb 24 2023 - 09:30:41 EST


From: Rong Tao <rongtao@xxxxxxxx>

When we get help information, we should return directly, and we should not
execute test cases. At the same time, the code indentation issue was fixed
and virtio-trace/trace-agent was added to .gitignore.

Signed-off-by: Rong Tao <rongtao@xxxxxxxx>
---
tools/virtio/.gitignore | 1 +
tools/virtio/virtio_test.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/virtio/.gitignore b/tools/virtio/.gitignore
index 075588c4da08..9934d48d9a55 100644
--- a/tools/virtio/.gitignore
+++ b/tools/virtio/.gitignore
@@ -2,3 +2,4 @@
*.d
virtio_test
vringh_test
+virtio-trace/trace-agent
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 120062f94590..6370cdada396 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -134,7 +134,7 @@ static void vdev_info_init(struct vdev_info* dev, unsigned long long features)
dev->buf_size = 1024;
dev->buf = malloc(dev->buf_size);
assert(dev->buf);
- dev->control = open("/dev/vhost-test", O_RDWR);
+ dev->control = open("/dev/vhost-test", O_RDWR);
assert(dev->control >= 0);
r = ioctl(dev->control, VHOST_SET_OWNER, NULL);
assert(r >= 0);
@@ -142,7 +142,7 @@ static void vdev_info_init(struct vdev_info* dev, unsigned long long features)
sizeof dev->mem->regions[0]);
assert(dev->mem);
memset(dev->mem, 0, offsetof(struct vhost_memory, regions) +
- sizeof dev->mem->regions[0]);
+ sizeof dev->mem->regions[0]);
dev->mem->nregions = 1;
dev->mem->regions[0].guest_phys_addr = (long)dev->buf;
dev->mem->regions[0].userspace_addr = (long)dev->buf;
@@ -361,7 +361,7 @@ int main(int argc, char **argv)
break;
case 'h':
help();
- goto done;
+ exit(0);
case 'i':
features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC);
break;
--
2.39.2