aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-26 13:20:20 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-26 13:25:51 -0400
commitd4bed025ed6de39e517422b076b5af9d7b31abb7 (patch)
treef526383fe6ebe2702f46cf34233327fc75b38a0e /src/command.c
parenta82e949c00aceaedd9d9a76ddcc3c88c9cad3d80 (diff)
downloadkutter-d4bed025ed6de39e517422b076b5af9d7b31abb7.tar.gz
kutter-d4bed025ed6de39e517422b076b5af9d7b31abb7.tar.xz
kutter-d4bed025ed6de39e517422b076b5af9d7b31abb7.zip
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>
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c11
1 files changed, 3 insertions, 8 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 };