From 0b6e0800cefc417ea1e013f524ace8f54cd4e2ce Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 27 Jun 2024 01:17:59 +0100 Subject: [PATCH] default log level to LOG_WARN write message to stderr if -D flag out of range --- src/vmrcli.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vmrcli.c b/src/vmrcli.c index fa43b6b..d14c0d0 100644 --- a/src/vmrcli.c +++ b/src/vmrcli.c @@ -42,10 +42,10 @@ int main(int argc, char *argv[]) if (argc == 1) { help(); - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); } - log_set_level(LOG_INFO); + log_set_level(LOG_WARN); while ((opt = getopt(argc, argv, "k:ihD:")) != -1) { @@ -62,10 +62,18 @@ int main(int argc, char *argv[]) help(); exit(EXIT_SUCCESS); case 'D': - if ((dvalue = atoi(optarg)) && dvalue >= LOG_TRACE && dvalue <= LOG_FATAL) + dvalue = atoi(optarg); + if (dvalue >= LOG_TRACE && dvalue <= LOG_FATAL) { log_set_level(dvalue); } + else + { + fputs( + "-D arg out of range, expected value from 0 up to 5\n" + "Log level will default to LOG_WARN (3).\n", + stderr); + } break; default: abort(); @@ -224,7 +232,7 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command) puts(res.val.s); break; default: - fputs("Unknown result...", stderr); + fputs("Unexpected result type", stderr); break; } }