]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: cli: rename dynamic error printing state
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Nov 2022 10:47:36 +0000 (11:47 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Nov 2022 15:42:47 +0000 (16:42 +0100)
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.

addons/ot/src/cli.c
include/haproxy/cli-t.h
include/haproxy/cli.h
src/cli.c

index 9132fe907c7bfa7aa45af5bd02ef93d4355f973b..0080dbd436e26d5b77deae8943d729df3c578a53 100644 (file)
@@ -97,7 +97,7 @@ static int flt_ot_cli_parse_debug(char **args, char *payload, struct appctx *app
                (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 @@ static int flt_ot_cli_parse_disabled(char **args, char *payload, struct appctx *
                (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 @@ static int flt_ot_cli_parse_option(char **args, char *payload, struct appctx *ap
                (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 @@ static int flt_ot_cli_parse_logging(char **args, char *payload, struct appctx *a
                } 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 @@ static int flt_ot_cli_parse_rate(char **args, char *payload, struct appctx *appc
                } 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 @@ static int flt_ot_cli_parse_status(char **args, char *payload, struct appctx *ap
                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);
 }
index 3a61656ce6eb428afa3b81e956683dc2784fabbe..7570954b29fd8e3b06323adabb339498a5625115 100644 (file)
@@ -57,7 +57,7 @@ enum {
        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 @@ enum {
 /* 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 */
 };
 
index 379bc3863de17ffa6bea784a616f426616982253..bb5c23c9874b1dbe4f5d70fc94d67bf49587b9a8 100644 (file)
@@ -104,7 +104,7 @@ static inline int cli_dynerr(struct appctx *appctx, char *err)
        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;
 }
 
index 5635ea8263dfe74da7ee5b3ea89916789b829398..406b850ce2d498efe091b65e705f14404fccab01 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1041,7 +1041,7 @@ static void cli_io_handler(struct appctx *appctx)
                        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 @@ static void cli_io_handler(struct appctx *appctx)
                                                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 @@ static void cli_io_handler(struct appctx *appctx)
                                }
 
                                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 @@ static void cli_release_handler(struct appctx *appctx)
                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);