aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-09-16 11:20:29 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-09-16 14:07:20 +0200
commit4f13d03213f5a121c437a261d6fcb522049df180 (patch)
tree8dce9ddbfc87808743bb577c565821047379da5e /openbsc/src
parent0760a83910a487e0bdd4e958829616fd491d95ba (diff)
ctrl: Set a generic reply when it hasn'n been set
When verification failed and the reply string was not updated, the message "Someone forgot to fill in the reply." was shown instead of the default "Value failed verification." message. This patch changes the default reply handling in ctrl_cmd_handle() by setting the reply to NULL initially and then checking it at the end. If it hasn't been set, a generic message is assigned and an error is logged.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/libctrl/control_if.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index b31f34fc6..b5db31da2 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -147,7 +147,7 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data)
vector vline, cmdvec, cmds_vec;
ret = CTRL_CMD_ERROR;
- cmd->reply = "Someone forgot to fill in the reply.";
+ cmd->reply = NULL;
node = CTRL_NODE_ROOT;
cmd->node = net;
@@ -238,6 +238,14 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data)
cmd_free_strvec(vline);
err:
+ if (!cmd->reply) {
+ LOGP(DCTRL, LOGL_ERROR, "cmd->reply has not been set.\n");
+ if (ret == CTRL_CMD_ERROR)
+ cmd->reply = "An error has occured.";
+ else
+ cmd->reply = "Command has been handled.";
+ }
+
if (ret == CTRL_CMD_ERROR)
cmd->type = CTRL_TYPE_ERROR;
return ret;