ms5611: add argc check

This commit is contained in:
Beat Küng
2018-06-04 16:33:55 +02:00
committed by Lorenz Meier
parent 7e7905acd1
commit ae8439f0af
+8 -3
View File
@@ -50,7 +50,6 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/wqueue.h> #include <nuttx/wqueue.h>
@@ -1198,10 +1197,15 @@ ms5611_main(int argc, char *argv[])
default: default:
ms5611::usage(); ms5611::usage();
exit(0); return 0;
} }
} }
if (myoptind >= argc) {
ms5611::usage();
return -1;
}
const char *verb = argv[myoptind]; const char *verb = argv[myoptind];
/* /*
@@ -1232,5 +1236,6 @@ ms5611_main(int argc, char *argv[])
ms5611::info(); ms5611::info();
} }
errx(1, "unrecognised command, try 'start', 'test', 'reset' or 'info'"); PX4_ERR("unrecognised command, try 'start', 'test', 'reset' or 'info'");
return -1;
} }