CLEANUP: cli: replace all occurrences of manual handling of return messages
There were 221 places where a status message or an error message were built
to be returned on the CLI. All of them were replaced to use cli_err(),
cli_msg(), cli_dynerr() or cli_dynmsg() depending on what was expected.
This removed a lot of duplicated code because most of the times, 4 lines
are replaced by a single, safer one.
diff --git a/src/activity.c b/src/activity.c
index 5ffa662..8844e0c 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -67,12 +67,8 @@
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
return 1;
- if (strcmp(args[2], "tasks") != 0) {
- appctx->ctx.cli.severity = LOG_ERR;
- appctx->ctx.cli.msg = "Expects 'tasks'.\n";
- appctx->st0 = CLI_ST_PRINT;
- return 1;
- }
+ if (strcmp(args[2], "tasks") != 0)
+ return cli_err(appctx, "Expects 'tasks'.\n");
if (strcmp(args[3], "on") == 0) {
unsigned int old = profiling;
@@ -89,12 +85,9 @@
while (!_HA_ATOMIC_CAS(&profiling, &old, (old & ~HA_PROF_TASKS_MASK) | HA_PROF_TASKS_OFF))
;
}
- else {
- appctx->ctx.cli.severity = LOG_ERR;
- appctx->ctx.cli.msg = "Expects 'on', 'auto', or 'off'.\n";
- appctx->st0 = CLI_ST_PRINT;
- return 1;
- }
+ else
+ return cli_err(appctx, "Expects 'on', 'auto', or 'off'.\n");
+
return 1;
}