From: Timo Sirainen Date: Thu, 16 Jan 2025 11:11:40 +0000 (+0200) Subject: global: Remove/fix dead code X-Git-Tag: 2.4.1~313 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5abc9b48eb0517781041fe78a38269ff8712e0f;p=thirdparty%2Fdovecot%2Fcore.git global: Remove/fix dead code Found by scan-build --- diff --git a/src/auth/passdb-ldap.c b/src/auth/passdb-ldap.c index b2a21d8571..a71da10455 100644 --- a/src/auth/passdb-ldap.c +++ b/src/auth/passdb-ldap.c @@ -437,7 +437,6 @@ static int passdb_ldap_preinit(pool_t pool, struct event *event, const struct auth_passdb_post_settings *auth_post = NULL; const struct ldap_pre_settings *ldap_pre = NULL; struct ldap_passdb_module *module; - struct ldap_connection *conn; int ret = -1; if (settings_get(event, &auth_passdb_post_setting_parser_info, @@ -448,7 +447,7 @@ static int passdb_ldap_preinit(pool_t pool, struct event *event, goto failed; module = p_new(pool, struct ldap_passdb_module, 1); - module->conn = conn = db_ldap_init(event); + module->conn = db_ldap_init(event); db_ldap_get_attribute_names(pool, &auth_post->fields, &module->attributes, diff --git a/src/auth/userdb-ldap.c b/src/auth/userdb-ldap.c index 8f49eb691e..6afa4ab510 100644 --- a/src/auth/userdb-ldap.c +++ b/src/auth/userdb-ldap.c @@ -320,7 +320,6 @@ static int userdb_ldap_preinit(pool_t pool, struct event *event, const struct ldap_post_settings *ldap_post = NULL; const struct ldap_pre_settings *ldap_pre = NULL; struct ldap_userdb_module *module; - struct ldap_connection *conn; int ret = -1; if (settings_get(event, &auth_userdb_post_setting_parser_info, @@ -334,7 +333,7 @@ static int userdb_ldap_preinit(pool_t pool, struct event *event, goto failed; module = p_new(pool, struct ldap_userdb_module, 1); - module->conn = conn = db_ldap_init(event); + module->conn = db_ldap_init(event); db_ldap_get_attribute_names(pool, &auth_post->fields, &module->attributes, diff --git a/src/lib-lua/dlua-dovecot-http.c b/src/lib-lua/dlua-dovecot-http.c index 20bfaca991..3b7b01bf9e 100644 --- a/src/lib-lua/dlua-dovecot-http.c +++ b/src/lib-lua/dlua-dovecot-http.c @@ -435,7 +435,7 @@ static int parse_client_settings(lua_State *L, struct settings_instance *instanc while (*error_r == NULL && lua_next(L, -2) != 0) { const char *key = lua_tostring(L, -2); const char *value = lua_tostring(L, -1); - const char *real_key = key; + const char *real_key; unsigned int idx ATTR_UNUSED; /* ignore event_parent */ if (strcmp(key, "event_parent") == 0) { diff --git a/src/lib-lua/test-lua-http-client.c b/src/lib-lua/test-lua-http-client.c index 9ff3ea99b5..37cf91bc1d 100644 --- a/src/lib-lua/test-lua-http-client.c +++ b/src/lib-lua/test-lua-http-client.c @@ -417,9 +417,9 @@ static void test_bad_settings(void) /* This needs a bit more roundabout way to check this as SSL settings are lazily evaluated. */ - ret = dlua_pcall(script->L, "test_invalid_set_value_3", 0, 0, &error); + test_assert(dlua_pcall(script->L, "test_invalid_set_value_3", 0, 0, &error) == 0); lua_pushstring(script->L, "https://localhost"); - ret = dlua_pcall(script->L, "http_request_post", 1, 2, &error); + test_assert(dlua_pcall(script->L, "http_request_post", 1, 2, &error) == 2); error = lua_tostring(script->L, 2); test_assert_strcmp(error, "Couldn't initialize SSL client context: Can't set minimum protocol to 'cow' (ssl_min_protocol setting): Unknown value"); diff --git a/src/lib-settings/settings.c b/src/lib-settings/settings.c index 646beb67d7..681823b5a2 100644 --- a/src/lib-settings/settings.c +++ b/src/lib-settings/settings.c @@ -2422,7 +2422,7 @@ settings_get_full(struct event *event, return 1; } - const struct setting_define *def = info->defines; + const struct setting_define *def; /* Sort filter arrays when order is defined */ for (def = info->defines; def->key != NULL; def++) { diff --git a/src/lib-sql/driver-sqlpool.c b/src/lib-sql/driver-sqlpool.c index a2bf86900c..3027b1532c 100644 --- a/src/lib-sql/driver-sqlpool.c +++ b/src/lib-sql/driver-sqlpool.c @@ -479,7 +479,7 @@ driver_sqlpool_init_common(const struct sql_db *driver, if (array_count(hostnames) == 0) { /* no hosts specified. create a default one. */ - host = array_append_space(&db->hosts); + array_append_zero(&db->hosts); } else { array_foreach_elem(hostnames, hostname) { host = array_append_space(&db->hosts); diff --git a/src/lib-var-expand/expansion-program.c b/src/lib-var-expand/expansion-program.c index 0b761e541a..5f64b5bda6 100644 --- a/src/lib-var-expand/expansion-program.c +++ b/src/lib-var-expand/expansion-program.c @@ -228,7 +228,6 @@ static void var_expand_program_export_one(const struct var_expand_program *progr str_append(dest, stmt->function); str_append_c(dest, '\1'); const struct var_expand_parameter *param = stmt->params; - param = stmt->params; while (param != NULL) { if (param->key != NULL) str_append(dest, param->key);