Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v2] selftests: splice: Add usage() to splice_read.c
@ 2024-08-31  5:14 Rong Tao
  2024-09-03 22:07 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Rong Tao @ 2024-08-31  5:14 UTC (permalink / raw)
  To: shuah; +Cc: rongtao, Rong Tao, open list:KERNEL SELFTEST FRAMEWORK, open list

From: Rong Tao <rongtao@cestc.cn>

Give the programmer more help information to inform the program on how to
use it.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 tools/testing/selftests/splice/splice_read.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/splice/splice_read.c b/tools/testing/selftests/splice/splice_read.c
index 46dae6a25cfb..73a8bc146f97 100644
--- a/tools/testing/selftests/splice/splice_read.c
+++ b/tools/testing/selftests/splice/splice_read.c
@@ -9,6 +9,12 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+void usage(const char *prog)
+{
+	fprintf(stderr, "Usage: %s INPUT [BYTES]\n", prog);
+	fprintf(stderr, "       %s /etc/os-release | cat\n", prog);
+}
+
 int main(int argc, char *argv[])
 {
 	int fd;
@@ -16,7 +22,7 @@ int main(int argc, char *argv[])
 	ssize_t spliced;
 
 	if (argc < 2) {
-		fprintf(stderr, "Usage: %s INPUT [BYTES]\n", argv[0]);
+		usage(argv[0]);
 		return EXIT_FAILURE;
 	}
 
@@ -49,6 +55,7 @@ int main(int argc, char *argv[])
 		      size, SPLICE_F_MOVE);
 	if (spliced < 0) {
 		perror("splice");
+		usage(argv[0]);
 		return EXIT_FAILURE;
 	}
 
-- 
2.46.0


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

end of thread, other threads:[~2024-09-03 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-31  5:14 [PATCH v2] selftests: splice: Add usage() to splice_read.c Rong Tao
2024-09-03 22:07 ` Shuah Khan

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