mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 05:03:35 +08:00
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 <charlebm@gmail.com>
This commit is contained in:
@@ -1021,6 +1021,11 @@ info()
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
static void usage()
|
||||||
|
{
|
||||||
|
warnx("Usage: uorb 'start', 'test', 'latency_test' or 'status'");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* uORB server 'main'.
|
* uORB server 'main'.
|
||||||
*/
|
*/
|
||||||
@@ -1029,6 +1034,11 @@ extern "C" { __EXPORT int uorb_main(int argc, char *argv[]); }
|
|||||||
int
|
int
|
||||||
uorb_main(int argc, char *argv[])
|
uorb_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
if (argc < 2) {
|
||||||
|
usage();
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start/load the driver.
|
* Start/load the driver.
|
||||||
*
|
*
|
||||||
@@ -1086,7 +1096,7 @@ uorb_main(int argc, char *argv[])
|
|||||||
if (!strcmp(argv[1], "status"))
|
if (!strcmp(argv[1], "status"))
|
||||||
return info();
|
return info();
|
||||||
|
|
||||||
warnx("unrecognized command, try 'start', 'test', 'latency_test' or 'status'");
|
usage();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user