From: Rong Tao <[email protected]>
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 <[email protected]>
---
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
On Fri, Feb 24, 2023 at 10:30:30PM +0800, Rong Tao wrote:
>From: Rong Tao <[email protected]>
>
>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.
Thanks for this cleanup, but you mentioned 3 independent things that
this patch does, so it would be better to split it into 3 separate
patches.
>
>Signed-off-by: Rong Tao <[email protected]>
>---
> 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]);
This did not seem to me to be an indentation issue, there are 2 tabs and
1 space to line it up with the opening of the parenthesis of the line
above.
> 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);
Maybe we can move the exit() directly into the help() function and
remove it from case '?'.
I would return a value different from 0 (like in the case '?').
Thanks,
Stefano
> case 'i':
> features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC);
> break;
>--
>2.39.2
>
Split patch [0] into 3 separate patches [1][2][3].
[0] https://lore.kernel.org/lkml/[email protected]/
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
Thanks,
Rong