diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 11 | ||||
-rw-r--r-- | src/command.h | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/command.c b/src/command.c index 2a248f16..ae2b10fe 100644 --- a/src/command.c +++ b/src/command.c @@ -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 }; diff --git a/src/command.h b/src/command.h index 609becd9..5bd6faf4 100644 --- a/src/command.h +++ b/src/command.h @@ -50,7 +50,7 @@ enum { PT_uint32, PT_int32, PT_uint16, PT_int16, PT_byte, PT_string, PT_progmem_buffer, PT_buffer, }; -extern const struct command_parser * const command_index[]; +extern const struct command_parser command_index[]; extern const uint8_t command_index_size; extern const uint8_t command_identify_data[]; extern const uint32_t command_identify_size; |