CLEANUP: cli: rename dynamic error printing state
Rename CLI_ST_PRINT_FREE to CLI_ST_PRINT_DYNERR.
Most notably, this highlights that this is reserved to error printing.
This is done to ensure consistency between CLI_ST_PRINT/CLI_ST_PRINT_DYN
and CLI_ST_PRINT_ERR/CLI_ST_PRINT_DYNERR. The name is also consistent
with the function cli_dynerr() which activates it.
diff --git a/addons/ot/src/cli.c b/addons/ot/src/cli.c
index 9132fe9..0080dbd 100644
--- a/addons/ot/src/cli.c
+++ b/addons/ot/src/cli.c
@@ -97,7 +97,7 @@
(void)memprintf(&msg, FLT_OT_CLI_CMD " : current debug level is %hhu", value);
}
- cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
@@ -137,7 +137,7 @@
(void)memprintf(&msg, "%s%s" FLT_OT_CLI_CMD " : filter %sabled", FLT_OT_CLI_MSG_CAT(msg), value ? "dis" : "en");
} FLT_OT_PROXIES_LIST_END();
- cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
@@ -175,7 +175,7 @@
(void)memprintf(&msg, "%s%s" FLT_OT_CLI_CMD " : filter set %s-errors", FLT_OT_CLI_MSG_CAT(msg), value ? "hard" : "soft");
} FLT_OT_PROXIES_LIST_END();
- cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
@@ -238,7 +238,7 @@
} FLT_OT_PROXIES_LIST_END();
}
- cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
@@ -289,7 +289,7 @@
} FLT_OT_PROXIES_LIST_END();
}
- cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
@@ -343,7 +343,7 @@
nl = "\n";
} FLT_OT_PROXIES_LIST_END();
- cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
+ cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
FLT_OT_RETURN_INT(retval);
}
diff --git a/include/haproxy/cli-t.h b/include/haproxy/cli-t.h
index 3a61656..7570954 100644
--- a/include/haproxy/cli-t.h
+++ b/include/haproxy/cli-t.h
@@ -57,7 +57,7 @@
CLI_ST_PRINT, /* display const message in cli->msg */
CLI_ST_PRINT_ERR, /* display const error in cli->msg */
CLI_ST_PRINT_DYN, /* display dynamic message in cli->err. After the display, free the pointer */
- CLI_ST_PRINT_FREE, /* display dynamic error in cli->err. After the display, free the pointer */
+ CLI_ST_PRINT_DYNERR, /* display dynamic error in cli->err. After the display, free the pointer */
CLI_ST_CALLBACK, /* custom callback pointer */
};
@@ -72,7 +72,7 @@
/* CLI context for printing command responses. */
struct cli_print_ctx {
const char *msg; /* pointer to a persistent message to be returned in CLI_ST_PRINT state */
- char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_FREE state */
+ char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_DYN state */
int severity; /* severity of the message to be returned according to (syslog) rfc5424 */
};
diff --git a/include/haproxy/cli.h b/include/haproxy/cli.h
index 379bc38..bb5c23c 100644
--- a/include/haproxy/cli.h
+++ b/include/haproxy/cli.h
@@ -104,7 +104,7 @@
struct cli_print_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
ctx->err = err;
- appctx->st0 = CLI_ST_PRINT_FREE;
+ appctx->st0 = CLI_ST_PRINT_DYNERR;
return 1;
}
diff --git a/src/cli.c b/src/cli.c
index 5635ea8..406b850 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1041,7 +1041,7 @@
case CLI_ST_PRINT: /* print const message in msg */
case CLI_ST_PRINT_ERR: /* print const error in msg */
case CLI_ST_PRINT_DYN: /* print dyn message in msg, free */
- case CLI_ST_PRINT_FREE: /* print dyn error in err, free */
+ case CLI_ST_PRINT_DYNERR: /* print dyn error in err, free */
/* the message is in the svcctx */
ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
if (appctx->st0 == CLI_ST_PRINT || appctx->st0 == CLI_ST_PRINT_ERR) {
@@ -1049,8 +1049,8 @@
LOG_ERR : ctx->severity;
msg = ctx->msg;
}
- else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_FREE) {
- sev = appctx->st0 == CLI_ST_PRINT_FREE ?
+ else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_DYNERR) {
+ sev = appctx->st0 == CLI_ST_PRINT_DYNERR ?
LOG_ERR : ctx->severity;
msg = ctx->err;
if (!msg) {
@@ -1064,8 +1064,8 @@
}
if (cli_output_msg(res, msg, sev, cli_get_severity_output(appctx)) != -1) {
- if (appctx->st0 == CLI_ST_PRINT_FREE ||
- appctx->st0 == CLI_ST_PRINT_DYN) {
+ if (appctx->st0 == CLI_ST_PRINT_DYN ||
+ appctx->st0 == CLI_ST_PRINT_DYNERR) {
ha_free(&ctx->err);
}
appctx->st0 = CLI_ST_PROMPT;
@@ -1193,7 +1193,7 @@
appctx->io_release(appctx);
appctx->io_release = NULL;
}
- else if (appctx->st0 == CLI_ST_PRINT_FREE || appctx->st0 == CLI_ST_PRINT_DYN) {
+ else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_DYNERR) {
struct cli_print_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
ha_free(&ctx->err);