diff options
author | Max <msuraev@sysmocom.de> | 2017-05-02 16:24:12 +0200 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2017-05-08 08:36:50 +0000 |
commit | 33c7ba693416bca679c60e15b31cf425bda75a2f (patch) | |
tree | d896253ac519bb6704ff434fcc08023570825ba9 /src/ctrl/fsm_ctrl_commands.c | |
parent | 85a6af213e8ccc0eb177b994db4137cf5b3089a4 (diff) |
Simplify ctrl cmd lookup
Replace if-else ladder & gotos with single switch statement & explicit
return to make reading code easier.
Change-Id: Ida1b389b571c60c26813cd29e61b3e4423c5df0f
Diffstat (limited to 'src/ctrl/fsm_ctrl_commands.c')
-rw-r--r-- | src/ctrl/fsm_ctrl_commands.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/ctrl/fsm_ctrl_commands.c b/src/ctrl/fsm_ctrl_commands.c index 64324f2d..95d5fca6 100644 --- a/src/ctrl/fsm_ctrl_commands.c +++ b/src/ctrl/fsm_ctrl_commands.c @@ -27,10 +27,10 @@ static int fsm_ctrl_node_lookup(void *data, vector vline, int *node_type, (*i)++; fsm_name = vector_lookup(vline, *i); if (!fsm_name) - goto err_index; + return -ERANGE; fsm = osmo_fsm_find_by_name(fsm_name); if (!fsm) - goto err_missing; + return -ENODEV; *node_data = fsm; *node_type = CTRL_NODE_FSM; } else @@ -43,10 +43,10 @@ static int fsm_ctrl_node_lookup(void *data, vector vline, int *node_type, (*i)++; inst_name = vector_lookup(vline, *i); if (!inst_name) - goto err_index; + return -ERANGE; fi = osmo_fsm_inst_find_by_name(fsm, inst_name); if (!fi) - goto err_missing; + return -ENODEV; *node_data = fi; *node_type = CTRL_NODE_FSM_INST; } else if (!strcmp(token, "id")) { @@ -54,10 +54,10 @@ static int fsm_ctrl_node_lookup(void *data, vector vline, int *node_type, (*i)++; inst_id = vector_lookup(vline, *i); if (!inst_id) - goto err_index; + return -ERANGE; fi = osmo_fsm_inst_find_by_id(fsm, inst_id); if (!fi) - goto err_missing; + return -ENODEV; *node_data = fi; *node_type = CTRL_NODE_FSM_INST; } @@ -67,11 +67,6 @@ static int fsm_ctrl_node_lookup(void *data, vector vline, int *node_type, } return 1; - -err_index: - return -ERANGE; -err_missing: - return -ENODEV; } static int get_fsm_inst_state(struct ctrl_cmd *cmd, void *data) |