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 modifies the implementation to set the default message
if and only if verification fails and the reply hasn't been changed.
---
openbsc/src/libctrl/control_cmd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c
index 3c4efc0..4d93c75 100644
--- a/openbsc/src/libctrl/control_cmd.c
+++ b/openbsc/src/libctrl/control_cmd.c
@@ -135,10 +135,12 @@ int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector
node, void *dat
goto out;
}
if (cmd_el->verify) {
+ const char *old_reply = command->reply;
+
if ((ret = cmd_el->verify(command, command->value, data))) {
ret = CTRL_CMD_ERROR;
/* If verify() set an appropriate error message, don't change it. */
- if (!command->reply)
+ if (command->reply == old_reply)
command->reply = "Value failed verification.";
goto out;
}
--
1.7.9.5