From 611ab3cbf3094411865dd3d38e9ddc448cbe2d94 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 10 Nov 2024 11:24:35 +0100 Subject: [PATCH] nvttest: Improve help And do help stuff like in nvtsrv. --- nvttest/nvttest.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/nvttest/nvttest.c b/nvttest/nvttest.c index 68eac69..9619f08 100644 --- a/nvttest/nvttest.c +++ b/nvttest/nvttest.c @@ -16,8 +16,17 @@ #include "lib/nvt_log.h" -#define HELP \ - "Usage: nvttest -dqr [-n loops] [-t threads]\n" +/**INDENT-OFF**/ +static const char help_text[] = + "Usage: nvttest OPTIONS...\n" + "OPTIONS:\n" + " -d : Enable debug\n" + " -n loops : Test loops per thread\n" + " -q : Quiet\n" + " -r : Insert random delay in loops\n" + " -t threads : N. threads\n" + ; +/**INDENT-ON**/ static const char *dev = "/dev/ttyNVT0"; @@ -28,6 +37,13 @@ typedef struct { bool opt_rand_delay; } topts_t; + +static void _usage(int rc) +{ + printf(help_text); + exit(rc); +} + static void *_worker(void *arg) { topts_t *topts = arg; @@ -120,8 +136,8 @@ int main(int argc, char **argv) switch (opt) { default: /* '?' */ - fprintf(stderr, HELP); - exit(EXIT_FAILURE); + _usage(1); + break; case 'd': debug += 1; break;