cli: Add return value in cli_inband
Even when a CLI command called through the cli_inband API failed
the API would return 0 (SUCCESS). This patch fixes that,
but since most CLI handlers return error->code == 0,
in most failure cases it will return -1 (UNSPECIFIED ERROR).
Type: fix
Change-Id: Ic83f3b23e8e8954bb8aa211301baba24e8c20ef6
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 4e8f3ae..835cb87 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -684,7 +684,7 @@
}
/* Process CLI input. */
-void
+int
vlib_cli_input (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_output_function_t * function, uword function_arg)
@@ -694,6 +694,7 @@
clib_error_t *error;
vlib_cli_output_function_t *save_function;
uword save_function_arg;
+ int rv = 0;
save_function = cp->output_function;
save_function_arg = cp->output_function_arg;
@@ -713,11 +714,15 @@
{
vlib_cli_output (vm, "%v", error->what);
vlib_unix_error_report (vm, error);
+ /* clib_error_return is unfortunately often called with a '0'
+ return code */
+ rv = error->code != 0 ? error->code : -1;
clib_error_free (error);
}
cp->output_function = save_function;
cp->output_function_arg = save_function_arg;
+ return rv;
}
/* Output to current CLI connection. */