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.
This commit is contained in:
Jacob Erlbeck 2013-09-16 11:20:29 +02:00 committed by Harald Welte
parent 6d96dd7477
commit e6d56159a6
1 changed files with 9 additions and 1 deletions

View File

@ -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;