mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] tools/virtio: virtio_test -h,--help should return directly
@ 2023-03-09  8:42 Rong Tao
  2023-03-09  8:49 ` Stefano Garzarella
  2023-03-09  9:09 ` [PATCH v2] " Stefano Garzarella
  0 siblings, 2 replies; 5+ messages in thread
From: Rong Tao @ 2023-03-09  8:42 UTC (permalink / raw)
  To: sgarzare
  Cc: Rong Tao, Michael S. Tsirkin, Jason Wang,
	open list:VIRTIO CORE AND NET DRIVERS, open list

From: Rong Tao <rongtao@cestc.cn>

When we get help information, we should return directly, and we should not
execute test cases. Move the exit() directly into the help() function and
remove it from case '?'.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
v2: help(): exit with a value different from 0 (e.g. 2).
v1: https://lore.kernel.org/lkml/tencent_4B5122C4158323A1D1ACA04B3295F1579207@qq.com/
---
 tools/virtio/virtio_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 120062f94590..33e17307441f 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -327,7 +327,7 @@ const struct option longopts[] = {
 	}
 };
 
-static void help(void)
+static void help(int status)
 {
 	fprintf(stderr, "Usage: virtio_test [--help]"
 		" [--no-indirect]"
@@ -337,6 +337,8 @@ static void help(void)
 		" [--batch=random/N]"
 		" [--reset=N]"
 		"\n");
+
+	exit(status);
 }
 
 int main(int argc, char **argv)
@@ -354,14 +356,12 @@ int main(int argc, char **argv)
 		case -1:
 			goto done;
 		case '?':
-			help();
-			exit(2);
+			help(2);
 		case 'e':
 			features &= ~(1ULL << VIRTIO_RING_F_EVENT_IDX);
 			break;
 		case 'h':
-			help();
-			goto done;
+			help(0);
 		case 'i':
 			features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC);
 			break;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-09  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09  8:42 [PATCH v2] tools/virtio: virtio_test -h,--help should return directly Rong Tao
2023-03-09  8:49 ` Stefano Garzarella
2023-03-09  8:56   ` [PATCH] " Rong Tao
2023-03-09  9:08     ` Stefano Garzarella
2023-03-09  9:09 ` [PATCH v2] " Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®