test_ppm: add argc check

This commit is contained in:
Beat Küng
2018-06-04 16:33:55 +02:00
committed by Lorenz Meier
parent dc7db9d793
commit ad587def24
+9 -8
View File
@@ -249,23 +249,26 @@ usage()
int int
test_ppm_main(int argc, char *argv[]) test_ppm_main(int argc, char *argv[])
{ {
if (argc < 2) {
test_ppm::usage();
return -1;
}
const char *verb = argv[1]; const char *verb = argv[1];
unsigned channels = 7; unsigned channels = 7;
/* /*
* Start/load the driver. * Start/load the driver.
*/ */
if (!strcmp(verb, "start")) { if (!strcmp(verb, "start")) {
test_ppm::start(channels); test_ppm::start(channels);
exit(0); return 0;
} }
if (!strcmp(verb, "stop")) { if (!strcmp(verb, "stop")) {
test_ppm::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); unsigned value = strtol(argv[3], NULL, 0);
test_ppm::set(channel, value); test_ppm::set(channel, value);
exit(0); return 0;
} }
test_ppm::usage(); test_ppm::usage();
exit(1); return -1;
} }