From: Timo Sirainen Date: Wed, 10 Feb 2021 19:20:25 +0000 (+0200) Subject: config: Use array_foreach_elem() where possible X-Git-Tag: 2.3.16~192 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bf42b1140a840866023ae13a2375a904154af5c;p=thirdparty%2Fdovecot%2Fcore.git config: Use array_foreach_elem() where possible --- diff --git a/src/config/config-filter.c b/src/config/config-filter.c index 3d08e5e4e8..336380d547 100644 --- a/src/config/config-filter.c +++ b/src/config/config-filter.c @@ -176,10 +176,10 @@ config_filter_parser_cmp_rev(struct config_filter_parser *const *p1, static bool str_array_contains(ARRAY_TYPE(const_string) *arr, const char *str) { - const char *const *p; + const char *p; - array_foreach(arr, p) { - if (strcmp(*p, str) == 0) + array_foreach_elem(arr, p) { + if (strcmp(p, str) == 0) return TRUE; } return FALSE; diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 0a0df795cf..9d3679621f 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -233,11 +233,9 @@ static struct config_filter_parser * config_filter_parser_find(struct config_parser_context *ctx, const struct config_filter *filter) { - struct config_filter_parser *const *parsers; - - array_foreach(&ctx->all_parsers, parsers) { - struct config_filter_parser *parser = *parsers; + struct config_filter_parser *parser; + array_foreach_elem(&ctx->all_parsers, parser) { if (config_filters_equal(&parser->filter, filter)) return parser; } diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 5d903ec114..a32fedf223 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -487,8 +487,8 @@ config_dump_human_output(struct config_dump_human_context *ctx, /* flush output before writing errors */ o_stream_uncork(output); - array_foreach(&ctx->errors, strings) { - i_error("%s", *strings); + array_foreach_elem(&ctx->errors, str) { + i_error("%s", str); ret = -1; } return ret; @@ -615,7 +615,7 @@ config_dump_one(const struct config_filter *filter, bool hide_key, bool hide_passwords) { static struct config_dump_human_context *ctx; - const char *const *str; + const char *str; size_t len; bool dump_section = FALSE; @@ -625,20 +625,20 @@ config_dump_one(const struct config_filter *filter, bool hide_key, return -1; len = strlen(setting_name_filter); - array_foreach(&ctx->strings, str) { - if (strncmp(*str, setting_name_filter, len) != 0) + array_foreach_elem(&ctx->strings, str) { + if (strncmp(str, setting_name_filter, len) != 0) continue; - if ((*str)[len] == '=') { + if (str[len] == '=') { if (hide_key) - printf("%s\n", *str + len+1); + printf("%s\n", str + len+1); else { printf("%s = %s\n", setting_name_filter, - *str + len+1); + str + len+1); } dump_section = FALSE; break; - } else if ((*str)[len] == '/') { + } else if (str[len] == '/') { dump_section = TRUE; } }