From: Timo Sirainen Date: Thu, 15 May 2025 10:40:13 +0000 (+0300) Subject: global: Fix warnings about uninitialized variables when compiling with -flto X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2651ac792d2983753fa1fa2f7284fcd8e7a2c60d;p=thirdparty%2Fdovecot%2Fcore.git global: Fix warnings about uninitialized variables when compiling with -flto These were only false positives, except for the unit test ones, which don't really matter. --- diff --git a/src/anvil/test-connect-limit.c b/src/anvil/test-connect-limit.c index 52035e69f7..6bbd58809b 100644 --- a/src/anvil/test-connect-limit.c +++ b/src/anvil/test-connect-limit.c @@ -314,7 +314,7 @@ static void test_sessions_compare(struct connect_limit *limit, test_assert(!session->found); session->found = TRUE; - pid_t pid; + pid_t pid = -1; test_assert(str_to_pid(args[0], &pid) == 0); test_assert(pid == session->pid); test_assert_strcmp(args[1], session->key.username); diff --git a/src/lib-dict/dict-txn-lua.c b/src/lib-dict/dict-txn-lua.c index 54bb390b99..990e4c5259 100644 --- a/src/lib-dict/dict-txn-lua.c +++ b/src/lib-dict/dict-txn-lua.c @@ -250,7 +250,7 @@ int lua_dict_transaction_begin(lua_State *L) static int lua_dict_set_timestamp(lua_State *L) { struct lua_dict_txn *txn; - lua_Number tv_sec, tv_nsec; + lua_Number tv_sec = 0, tv_nsec = 0; DLUA_REQUIRE_ARGS(L, 2); diff --git a/src/lib-lua/test-lua.c b/src/lib-lua/test-lua.c index 676ca8d121..af350dc5b9 100644 --- a/src/lib-lua/test-lua.c +++ b/src/lib-lua/test-lua.c @@ -33,14 +33,12 @@ static void check_table_get_##name##_ok(struct dlua_script *script, \ /* check string key */ \ ret = dlua_table_get_##name##_by_str(script->L, idx, \ str_key, &value); \ - test_assert(ret == 1); \ - test_assert(value == expected_value); \ + test_assert(ret == 1 && value == expected_value); \ \ /* check int key */ \ ret = dlua_table_get_##name##_by_int(script->L, idx, \ int_key, &value); \ - test_assert(ret == 1); \ - test_assert(value == expected_value); \ + test_assert(ret == 1 && value == expected_value); \ } \ static void check_table_get_##name##_err(struct dlua_script *script, \ int idx, int expected_ret, \ @@ -75,7 +73,7 @@ static void check_table_get_string_ok(struct dlua_script *script, const char *str_key, lua_Integer int_key) { - const char *value; + const char *value = NULL; int ret; /* check string key */ diff --git a/src/lib-settings/settings.c b/src/lib-settings/settings.c index 622ae746c5..e3ecfbaa7c 100644 --- a/src/lib-settings/settings.c +++ b/src/lib-settings/settings.c @@ -802,7 +802,7 @@ static int settings_var_expand(struct settings_apply_ctx *ctx, unsigned int key_idx, const char **value, const char **error_r) { - struct settings_file file; + struct settings_file file = { NULL, NULL }; const char *orig_value = *value; bool changed; bool want_expand = FALSE; diff --git a/src/lib/test-strnum.c b/src/lib/test-strnum.c index fff0606152..3df2bff752 100644 --- a/src/lib/test-strnum.c +++ b/src/lib/test-strnum.c @@ -107,7 +107,7 @@ static void test_str_to_uintmax_hex(void) test_begin("str_to_uintmax_hex in range"); while (i < sizeof(uintmax_t)*CHAR_BIT) { - uintmax_t value_back; + uintmax_t value_back = UINTMAX_MAX; const char *endp; value = (value << 1) + 1;