command: Store the command parsing information directly in array

Instead of defining an array of pointers, just define the array
directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-05-26 13:20:20 -04:00
parent a82e949c00
commit d4bed025ed
4 changed files with 27 additions and 29 deletions

View file

@ -213,14 +213,9 @@ DECL_SHUTDOWN(sendf_shutdown);
static const struct command_parser *
command_get_handler(uint8_t cmdid)
{
if (cmdid >= READP(command_index_size))
goto error;
const struct command_parser *cp = READP(command_index[cmdid]);
if (!cp)
goto error;
return cp;
error:
shutdown("Invalid command");
if (!cmdid || cmdid >= READP(command_index_size))
shutdown("Invalid command");
return &command_index[cmdid];
}
enum { CF_NEED_SYNC=1<<0, CF_NEED_VALID=1<<1 };