mirror of https://github.com/ArduPilot/ardupilot
Default un-supplied command arguments to the empty string and zero rather than leaving them potentially un-initialised. This makes it safe for commands to compare argument strings without adding the expense of checking argc first.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@760 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
1adfde9ff6
commit
c39639045c
|
@ -86,6 +86,15 @@ Menu::run(void)
|
||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// populate arguments that have not been specified with "" and 0
|
||||||
|
// this is safer than NULL in the case where commands may look
|
||||||
|
// without testing argc
|
||||||
|
while (argc <= MENU_ARGS_MAX) {
|
||||||
|
_argv[argc].str = "";
|
||||||
|
_argv[argc].i = 0;
|
||||||
|
_argv[argc].f = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// look for a command matching the first word (note that it may be empty)
|
// look for a command matching the first word (note that it may be empty)
|
||||||
for (i = 0; i < _entries; i++) {
|
for (i = 0; i < _entries; i++) {
|
||||||
if (!strcasecmp_P(_argv[0].str, _commands[i].command)) {
|
if (!strcasecmp_P(_argv[0].str, _commands[i].command)) {
|
||||||
|
|
Loading…
Reference in New Issue