From: Timo Sirainen Date: Wed, 26 Mar 2025 10:04:38 +0000 (+0200) Subject: config: Move most boolean fields in config_parser_context to flags enum X-Git-Tag: 2.4.2~99 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8de666e9d4c7892da8689a343b214e92e5d95c5;p=thirdparty%2Fdovecot%2Fcore.git config: Move most boolean fields in config_parser_context to flags enum Preserve expand_values since it's used all over the place. --- diff --git a/src/config/config-parser-private.h b/src/config/config-parser-private.h index 082c1c02e6..960947e2b3 100644 --- a/src/config/config-parser-private.h +++ b/src/config/config-parser-private.h @@ -81,6 +81,7 @@ HASH_TABLE_DEFINE_TYPE(include_group, const char *, struct config_parser_context { pool_t pool; const char *path; + enum config_parse_flags flags; ARRAY_TYPE(config_path) seen_paths; HASH_TABLE_TYPE(config_key) all_keys; @@ -109,10 +110,6 @@ struct config_parser_context { struct config_filter_context *filter; bool dump_defaults:1; bool expand_values:1; - bool hide_errors:1; - bool delay_errors:1; - bool hide_obsolete_warnings:1; - bool ignore_unknown:1; /* All config_filter_parsers have reverse_default_sibling set. */ bool reverse_parsers_set:1; }; diff --git a/src/config/config-parser.c b/src/config/config-parser.c index d69db34854..15e27f3a45 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -349,7 +349,7 @@ config_apply_error(struct config_parser_context *ctx, const char *key) { struct config_parser_key *config_key; - if (!ctx->delay_errors) + if ((ctx->flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) == 0) return -1; /* Couldn't get value for the setting, but we're delaying error @@ -1321,7 +1321,7 @@ again: } ctx->cur_section->filter_parser = orig_filter_parser; if (ret == 0) { - if (ctx->ignore_unknown) + if ((ctx->flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0) return 0; config_set_unknown_key_error(ctx, key); return -1; @@ -1826,7 +1826,7 @@ config_filter_parser_check(struct config_parser_context *ctx, if (!ok) { /* be sure to assert-crash early if error is missing */ i_assert(error != NULL); - if (!ctx->delay_errors) { + if ((ctx->flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) == 0) { /* the errors are still slightly delayed so we get the full list of them. */ error = p_strdup(new_config->pool, error); @@ -3216,7 +3216,7 @@ void config_parser_apply_line(struct config_parser_context *ctx, break; } if (hash_table_lookup(ctx->all_keys, key) == NULL) { - if (ctx->ignore_unknown) + if ((ctx->flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0) break; if (attempts != NULL) str_append(attempts, " not found either.)"); @@ -3373,10 +3373,7 @@ int config_parse_file(const char *path, enum config_parse_flags flags, ctx.pool = pool_alloconly_create(MEMPOOL_GROWING"config file parser", 1024*256); ctx.path = path; ctx.dump_defaults = dump_defaults; - ctx.hide_obsolete_warnings = - (flags & CONFIG_PARSE_FLAG_HIDE_OBSOLETE_WARNINGS) != 0; - ctx.delay_errors = (flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) != 0; - ctx.ignore_unknown = (flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0; + ctx.flags = flags; hash_table_create(&ctx.all_keys, ctx.pool, 500, str_hash, strcmp); p_array_init(&ctx.seen_paths, ctx.pool, 8); if (fd != -1) { diff --git a/src/config/old-set-parser.c b/src/config/old-set-parser.c index ee2cb513c9..e957d6d925 100644 --- a/src/config/old-set-parser.c +++ b/src/config/old-set-parser.c @@ -13,7 +13,7 @@ obsolete(struct config_parser_context *ctx, const char *str, ...) static bool seen_obsoletes = FALSE; va_list args; - if (ctx->hide_obsolete_warnings) + if ((ctx->flags & CONFIG_PARSE_FLAG_HIDE_OBSOLETE_WARNINGS) != 0) return; if (!seen_obsoletes) {