From dffb8bb62c12c36c8cfe409a6111dfa7c9df29ba Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Wed, 25 Mar 2015 10:57:58 -0700 Subject: [PATCH] MuORB: handle case on no args passed if only uorb is called with no other args it crashes. Handle the case where no args are passed. Signed-off-by: Mark Charlebois --- src/modules/uORB/MuORB.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/uORB/MuORB.cpp b/src/modules/uORB/MuORB.cpp index 9dcab26b1c..548b36d029 100644 --- a/src/modules/uORB/MuORB.cpp +++ b/src/modules/uORB/MuORB.cpp @@ -1021,6 +1021,11 @@ info() } // namespace +static void usage() +{ + warnx("Usage: uorb 'start', 'test', 'latency_test' or 'status'"); +} + /* * uORB server 'main'. */ @@ -1029,6 +1034,11 @@ extern "C" { __EXPORT int uorb_main(int argc, char *argv[]); } int uorb_main(int argc, char *argv[]) { + if (argc < 2) { + usage(); + return -EINVAL; + } + /* * Start/load the driver. * @@ -1086,7 +1096,7 @@ uorb_main(int argc, char *argv[]) if (!strcmp(argv[1], "status")) return info(); - warnx("unrecognized command, try 'start', 'test', 'latency_test' or 'status'"); + usage(); return -EINVAL; }