Re: [PATCH v2] selftests: splice: Add usage() to splice_read.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/30/24 23:14, Rong Tao wrote:
From: Rong Tao <rongtao@xxxxxxxx>

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

Signed-off-by: Rong Tao <rongtao@xxxxxxxx>
---
  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);

How does replacing %s INPUT [BYTES]\n", prog with /etc/os-release | cat\n" do?
Also what happens on distros that don't have os-release file?

+}
+
  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;
  	}

I don't understand how this change helps user.

thanks,
-- Shuah




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux