Browse Source

test_ppm: add argc check

sbg
Beat Küng 7 years ago committed by Lorenz Meier
parent
commit
ad587def24
  1. 17
      src/drivers/test_ppm/test_ppm.cpp

17
src/drivers/test_ppm/test_ppm.cpp

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

Loading…
Cancel
Save