From ad587def240f7efb75e50686888b818f09c99554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 4 Jun 2018 14:32:25 +0200 Subject: [PATCH] test_ppm: add argc check --- src/drivers/test_ppm/test_ppm.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/drivers/test_ppm/test_ppm.cpp b/src/drivers/test_ppm/test_ppm.cpp index ba1445a36c..f9fc7997fe 100644 --- a/src/drivers/test_ppm/test_ppm.cpp +++ b/src/drivers/test_ppm/test_ppm.cpp @@ -249,23 +249,26 @@ usage() int test_ppm_main(int argc, char *argv[]) { + if (argc < 2) { + test_ppm::usage(); + return -1; + } + const char *verb = argv[1]; unsigned channels = 7; /* * Start/load the driver. - */ - if (!strcmp(verb, "start")) { test_ppm::start(channels); - exit(0); + return 0; } if (!strcmp(verb, "stop")) { test_ppm::stop(); - exit(0); + return 0; } /* @@ -280,11 +283,9 @@ test_ppm_main(int argc, char *argv[]) unsigned value = strtol(argv[3], NULL, 0); test_ppm::set(channel, value); - exit(0); + return 0; } - - test_ppm::usage(); - exit(1); + return -1; }