[PATCH 4/4] ctrl: Fix generic reply when verification fails

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Wed Sep 11 08:46:58 UTC 2013


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





More information about the OpenBSC mailing list