From: Justin Dossey Date: Mon, 22 Sep 2025 15:35:16 +0000 (-0700) Subject: Use clang-format-18 to address indentation mismatches X-Git-Tag: 3.13.1~11^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ac9925bc3d3489c6635e272f655cf20b96bcb06;p=thirdparty%2Frspamd.git Use clang-format-18 to address indentation mismatches --- diff --git a/src/libserver/redis_pool.cxx b/src/libserver/redis_pool.cxx index f8aa8c31e0..cdb301b82b 100644 --- a/src/libserver/redis_pool.cxx +++ b/src/libserver/redis_pool.cxx @@ -123,8 +123,8 @@ public: const char *_sni = nullptr) : pool(_pool), ip(_ip), port(_port), key(redis_pool_elt::make_key(_db, _username, _password, _ip, _port, - _use_tls, _no_ssl_verify, - _ca_file, _ca_dir, _cert_file, _key_file, _sni)) + _use_tls, _no_ssl_verify, + _ca_file, _ca_dir, _cert_file, _key_file, _sni)) { is_unix = ip[0] == '.' || ip[0] == '/'; @@ -278,7 +278,7 @@ private: class redis_pool final { static constexpr const double default_timeout = 10.0; -static constexpr const unsigned default_max_conns = 100; + static constexpr const unsigned default_max_conns = 100; /* We want to have references integrity */ ankerl::unordered_dense::map redisAsyncContext *; auto new_connection_ext(const char *db, const char *username, - const char *password, const char *ip, int port, - bool use_tls, bool no_ssl_verify, - const char *ca_file, const char *ca_dir, - const char *cert_file, const char *key_file, - const char *sni) -> redisAsyncContext *; + const char *password, const char *ip, int port, + bool use_tls, bool no_ssl_verify, + const char *ca_file, const char *ca_dir, + const char *cert_file, const char *key_file, + const char *sni) -> redisAsyncContext *; auto release_connection(redisAsyncContext *ctx, enum rspamd_redis_pool_release_type how) -> void; @@ -565,17 +565,17 @@ auto redis_pool_elt::new_connection() -> redisAsyncContext * conn->ctx->errstr, ip.c_str(), port, nctx); if (nctx) { - /* If TLS is configured for this element, initiate it now */ - if (use_tls && !is_unix) { - if (!initiate_tls(nctx)) { - redisAsyncFree(nctx); - nctx = nullptr; - } + /* If TLS is configured for this element, initiate it now */ + if (use_tls && !is_unix) { + if (!initiate_tls(nctx)) { + redisAsyncFree(nctx); + nctx = nullptr; } + } if (nctx) { active.emplace_front(std::make_unique(pool, this, - db.c_str(), username.c_str(), password.c_str(), nctx)); + db.c_str(), username.c_str(), password.c_str(), nctx)); active.front()->elt_pos = active.begin(); } } @@ -587,17 +587,17 @@ auto redis_pool_elt::new_connection() -> redisAsyncContext * auto *nctx = redis_async_new(); if (nctx) { - /* If TLS is configured for this element, initiate it now */ - if (use_tls && !is_unix) { - if (!initiate_tls(nctx)) { - redisAsyncFree(nctx); - nctx = nullptr; - } + /* If TLS is configured for this element, initiate it now */ + if (use_tls && !is_unix) { + if (!initiate_tls(nctx)) { + redisAsyncFree(nctx); + nctx = nullptr; } + } if (nctx) { active.emplace_front(std::make_unique(pool, this, - db.c_str(), username.c_str(), password.c_str(), nctx)); + db.c_str(), username.c_str(), password.c_str(), nctx)); active.front()->elt_pos = active.begin(); auto conn = active.front().get(); msg_debug_rpool("no inactive connections; opened new connection to %s:%d: %p", @@ -637,17 +637,17 @@ auto redis_pool::new_connection(const char *db, const char *username, } auto redis_pool::new_connection_ext(const char *db, const char *username, - const char *password, const char *ip, int port, - bool use_tls, bool no_ssl_verify, - const char *ca_file, const char *ca_dir, - const char *cert_file, const char *key_file, - const char *sni) -> redisAsyncContext * + const char *password, const char *ip, int port, + bool use_tls, bool no_ssl_verify, + const char *ca_file, const char *ca_dir, + const char *cert_file, const char *key_file, + const char *sni) -> redisAsyncContext * { if (!wanna_die) { auto key = redis_pool_elt::make_key(db, username, password, ip, port, - use_tls, no_ssl_verify, ca_file, ca_dir, - cert_file, key_file, sni); + use_tls, no_ssl_verify, ca_file, ca_dir, + cert_file, key_file, sni); auto found_elt = elts_by_key.find(key); if (found_elt != elts_by_key.end()) { @@ -742,8 +742,8 @@ void rspamd_redis_pool_config(void *p, struct redisAsyncContext * rspamd_redis_pool_connect(void *p, - const char *db, const char *username, - const char *password, const char *ip, int port) + const char *db, const char *username, + const char *password, const char *ip, int port) { g_assert(p != NULL); auto *pool = reinterpret_cast(p); @@ -761,12 +761,12 @@ rspamd_redis_pool_connect_ext(void *p, g_assert(p != NULL); auto *pool = reinterpret_cast(p); - if (tls && tls->use_tls) { - return pool->new_connection_ext(db, username, password, ip, port, - true, tls->no_ssl_verify, - tls->ca_file, tls->ca_dir, - tls->cert_file, tls->key_file, - tls->sni); + if (tls && tls->use_tls) { + return pool->new_connection_ext(db, username, password, ip, port, + true, tls->no_ssl_verify, + tls->ca_file, tls->ca_dir, + tls->cert_file, tls->key_file, + tls->sni); } else { return pool->new_connection(db, username, password, ip, port); diff --git a/src/libserver/redis_pool.h b/src/libserver/redis_pool.h index ed648abece..50f54911bf 100644 --- a/src/libserver/redis_pool.h +++ b/src/libserver/redis_pool.h @@ -25,13 +25,13 @@ struct rspamd_config; struct redisAsyncContext; struct ev_loop; struct rspamd_redis_tls_opts { - bool use_tls; /* enable TLS */ - bool no_ssl_verify; /* disable peer verify */ - const char *ca_file; /* optional */ - const char *ca_dir; /* optional */ - const char *cert_file; /* optional */ - const char *key_file; /* optional */ - const char *sni; /* optional */ + bool use_tls; /* enable TLS */ + bool no_ssl_verify; /* disable peer verify */ + const char *ca_file; /* optional */ + const char *ca_dir; /* optional */ + const char *cert_file; /* optional */ + const char *key_file; /* optional */ + const char *sni; /* optional */ }; /** @@ -61,18 +61,18 @@ void rspamd_redis_pool_config(void *pool, * @return */ struct redisAsyncContext *rspamd_redis_pool_connect( - void *pool, - const char *db, const char *username, const char *password, - const char *ip, int port); + void *pool, + const char *db, const char *username, const char *password, + const char *ip, int port); /** * Create or reuse a specific redis connection with optional TLS */ struct redisAsyncContext *rspamd_redis_pool_connect_ext( - void *pool, - const char *db, const char *username, const char *password, - const char *ip, int port, - const struct rspamd_redis_tls_opts *tls); + void *pool, + const char *db, const char *username, const char *password, + const char *ip, int port, + const struct rspamd_redis_tls_opts *tls); enum rspamd_redis_pool_release_type { RSPAMD_REDIS_RELEASE_DEFAULT = 0, diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index fbe65bacee..d1eb471da8 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -888,10 +888,10 @@ rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async struct rspamd_task *task = NULL; const char *host = NULL; const char *username = NULL, *password = NULL, *dbname = NULL, *log_tag = NULL; - struct rspamd_redis_tls_opts tls_opts; - /* Duplicated TLS strings to ensure lifetime beyond Lua stack */ - char *dup_ca_file = NULL, *dup_ca_dir = NULL, *dup_cert_file = NULL, - *dup_key_file = NULL, *dup_sni = NULL; + struct rspamd_redis_tls_opts tls_opts; + /* Duplicated TLS strings to ensure lifetime beyond Lua stack */ + char *dup_ca_file = NULL, *dup_ca_dir = NULL, *dup_cert_file = NULL, + *dup_key_file = NULL, *dup_sni = NULL; int cbref = -1; struct rspamd_config *cfg = NULL; struct rspamd_async_session *session = NULL; @@ -899,7 +899,7 @@ rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async gboolean ret = FALSE; unsigned int flags = 0; - memset(&tls_opts, 0, sizeof(tls_opts)); + memset(&tls_opts, 0, sizeof(tls_opts)); if (lua_istable(L, 1)) { /* Table version */ @@ -1016,61 +1016,61 @@ rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async } lua_pop(L, 1); - /* TLS options (optional) */ - lua_pushstring(L, "ssl"); - lua_gettable(L, -2); - if (!!lua_toboolean(L, -1)) { - tls_opts.use_tls = true; - } - lua_pop(L, 1); - - lua_pushstring(L, "no_ssl_verify"); - lua_gettable(L, -2); - if (!!lua_toboolean(L, -1)) { - tls_opts.no_ssl_verify = true; - } - lua_pop(L, 1); - - /* Duplicate string options to avoid ephemeral Lua string pointers */ - lua_pushstring(L, "ssl_ca"); - lua_gettable(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - dup_ca_file = g_strdup(lua_tostring(L, -1)); - tls_opts.ca_file = dup_ca_file; - } - lua_pop(L, 1); - - lua_pushstring(L, "ssl_ca_dir"); - lua_gettable(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - dup_ca_dir = g_strdup(lua_tostring(L, -1)); - tls_opts.ca_dir = dup_ca_dir; - } - lua_pop(L, 1); - - lua_pushstring(L, "ssl_cert"); - lua_gettable(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - dup_cert_file = g_strdup(lua_tostring(L, -1)); - tls_opts.cert_file = dup_cert_file; - } - lua_pop(L, 1); - - lua_pushstring(L, "ssl_key"); - lua_gettable(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - dup_key_file = g_strdup(lua_tostring(L, -1)); - tls_opts.key_file = dup_key_file; - } - lua_pop(L, 1); - - lua_pushstring(L, "sni"); - lua_gettable(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - dup_sni = g_strdup(lua_tostring(L, -1)); - tls_opts.sni = dup_sni; - } - lua_pop(L, 1); + /* TLS options (optional) */ + lua_pushstring(L, "ssl"); + lua_gettable(L, -2); + if (!!lua_toboolean(L, -1)) { + tls_opts.use_tls = true; + } + lua_pop(L, 1); + + lua_pushstring(L, "no_ssl_verify"); + lua_gettable(L, -2); + if (!!lua_toboolean(L, -1)) { + tls_opts.no_ssl_verify = true; + } + lua_pop(L, 1); + + /* Duplicate string options to avoid ephemeral Lua string pointers */ + lua_pushstring(L, "ssl_ca"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dup_ca_file = g_strdup(lua_tostring(L, -1)); + tls_opts.ca_file = dup_ca_file; + } + lua_pop(L, 1); + + lua_pushstring(L, "ssl_ca_dir"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dup_ca_dir = g_strdup(lua_tostring(L, -1)); + tls_opts.ca_dir = dup_ca_dir; + } + lua_pop(L, 1); + + lua_pushstring(L, "ssl_cert"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dup_cert_file = g_strdup(lua_tostring(L, -1)); + tls_opts.cert_file = dup_cert_file; + } + lua_pop(L, 1); + + lua_pushstring(L, "ssl_key"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dup_key_file = g_strdup(lua_tostring(L, -1)); + tls_opts.key_file = dup_key_file; + } + lua_pop(L, 1); + + lua_pushstring(L, "sni"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dup_sni = g_strdup(lua_tostring(L, -1)); + tls_opts.sni = dup_sni; + } + lua_pop(L, 1); lua_pushstring(L, "no_pool"); lua_gettable(L, -2); @@ -1133,22 +1133,22 @@ rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async if (ret) { ud->terminated = 0; - ud->ctx = rspamd_redis_pool_connect_ext(ud->pool, - dbname, username, password, - rspamd_inet_address_to_string(addr->addr), - rspamd_inet_address_get_port(addr->addr), - &tls_opts); - - /* Free temporary TLS strings after they have been consumed */ - g_free(dup_ca_file); - g_free(dup_ca_dir); - g_free(dup_cert_file); - g_free(dup_key_file); - g_free(dup_sni); - - if (ip) { - rspamd_inet_address_free(ip); - } + ud->ctx = rspamd_redis_pool_connect_ext(ud->pool, + dbname, username, password, + rspamd_inet_address_to_string(addr->addr), + rspamd_inet_address_get_port(addr->addr), + &tls_opts); + + /* Free temporary TLS strings after they have been consumed */ + g_free(dup_ca_file); + g_free(dup_ca_dir); + g_free(dup_cert_file); + g_free(dup_key_file); + g_free(dup_sni); + + if (ip) { + rspamd_inet_address_free(ip); + } if (ud->ctx == NULL || ud->ctx->err) { if (ud->ctx) { @@ -1171,21 +1171,21 @@ rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async msg_debug_lua_redis("opened redis connection host=%s; lua_ctx=%p; redis_ctx=%p; ud=%p", host, ctx, ud->ctx, ud); - return ctx; - } + return ctx; + } - if (ip) { - rspamd_inet_address_free(ip); - } + if (ip) { + rspamd_inet_address_free(ip); + } - /* Free any duplicated TLS strings on error path */ - g_free(dup_ca_file); - g_free(dup_ca_dir); - g_free(dup_cert_file); - g_free(dup_key_file); - g_free(dup_sni); + /* Free any duplicated TLS strings on error path */ + g_free(dup_ca_file); + g_free(dup_ca_dir); + g_free(dup_cert_file); + g_free(dup_key_file); + g_free(dup_sni); - return NULL; + return NULL; } /*** @@ -1690,9 +1690,9 @@ lua_redis_exec(lua_State *L) int replies_pending = g_queue_get_length(ctx->replies); msg_debug_lua_redis("execute pending commands for %p; commands pending = %d; replies pending = %d", - ctx, - ctx->cmds_pending, - replies_pending); + ctx, + ctx->cmds_pending, + replies_pending); if (ctx->cmds_pending == 0 && replies_pending == 0) { lua_pushstring(L, "No pending commands to execute");