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
|
@ -85,6 +85,15 @@ Menu::run(void)
|
|||
_argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B !
|
||||
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)
|
||||
for (i = 0; i < _entries; i++) {
|
||||
|
|
Loading…
Reference in New Issue