mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 21:00:16 +01:00
all: merge branch 'th/coverity-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/883
(cherry picked from commit c47ad0f754)
This commit is contained in:
commit
f353cb95e5
4 changed files with 48 additions and 38 deletions
|
|
@ -4503,42 +4503,44 @@ test_setting_connection_secondaries_verify(void)
|
|||
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_SECONDARIES, arr->pdata, NULL);
|
||||
|
||||
#define _assert_secondaries(s_con, expected) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
NMSettingConnection *const _s_con = (s_con); \
|
||||
const char *const * _expected = (expected); \
|
||||
GArray * _secondaries; \
|
||||
const guint _expected_len = NM_PTRARRAY_LEN(_expected); \
|
||||
gs_strfreev char ** _sec_strv = NULL; \
|
||||
guint _i; \
|
||||
\
|
||||
g_assert(_expected); \
|
||||
\
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
_secondaries = _nm_setting_connection_get_secondaries(_s_con); \
|
||||
g_assert_cmpint(_expected_len, ==, nm_g_array_len(_secondaries)); \
|
||||
g_assert((_expected_len == 0) == (!_secondaries)); \
|
||||
g_assert(nm_utils_strv_equal(_expected, nm_strvarray_get_strv(&_secondaries, NULL))); \
|
||||
} \
|
||||
\
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
g_object_get(_s_con, NM_SETTING_CONNECTION_SECONDARIES, &_sec_strv, NULL); \
|
||||
g_assert_cmpint(_expected_len, ==, NM_PTRARRAY_LEN(_sec_strv)); \
|
||||
g_assert((_expected_len == 0) == (!_sec_strv)); \
|
||||
g_assert(nm_utils_strv_equal(_expected, _sec_strv ?: NM_STRV_EMPTY())); \
|
||||
} \
|
||||
\
|
||||
g_assert_cmpint(nm_setting_connection_get_num_secondaries(_s_con), ==, _expected_len); \
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
for (_i = 0; _i < _expected_len; _i++) { \
|
||||
g_assert_cmpstr(nm_setting_connection_get_secondary(_s_con, _i), \
|
||||
==, \
|
||||
_expected[_i]); \
|
||||
} \
|
||||
g_assert_null(nm_setting_connection_get_secondary(_s_con, _expected_len)); \
|
||||
} \
|
||||
} \
|
||||
#define _assert_secondaries(s_con, expected) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
NMSettingConnection *const _s_con = (s_con); \
|
||||
const char *const * _expected = (expected); \
|
||||
GArray * _secondaries; \
|
||||
const guint _expected_len = NM_PTRARRAY_LEN(_expected); \
|
||||
gs_strfreev char ** _sec_strv = NULL; \
|
||||
guint _i; \
|
||||
\
|
||||
g_assert(_expected); \
|
||||
\
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
_secondaries = _nm_setting_connection_get_secondaries(_s_con); \
|
||||
g_assert_cmpint(_expected_len, ==, nm_g_array_len(_secondaries)); \
|
||||
g_assert((_expected_len == 0) == (!_secondaries)); \
|
||||
g_assert(nm_utils_strv_equal(_expected, \
|
||||
_secondaries ? nm_strvarray_get_strv(&_secondaries, NULL) \
|
||||
: NM_PTRARRAY_EMPTY(const char *))); \
|
||||
} \
|
||||
\
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
g_object_get(_s_con, NM_SETTING_CONNECTION_SECONDARIES, &_sec_strv, NULL); \
|
||||
g_assert_cmpint(_expected_len, ==, NM_PTRARRAY_LEN(_sec_strv)); \
|
||||
g_assert((_expected_len == 0) == (!_sec_strv)); \
|
||||
g_assert(nm_utils_strv_equal(_expected, _sec_strv ?: NM_STRV_EMPTY())); \
|
||||
} \
|
||||
\
|
||||
g_assert_cmpint(nm_setting_connection_get_num_secondaries(_s_con), ==, _expected_len); \
|
||||
if (nmtst_get_rand_bool()) { \
|
||||
for (_i = 0; _i < _expected_len; _i++) { \
|
||||
g_assert_cmpstr(nm_setting_connection_get_secondary(_s_con, _i), \
|
||||
==, \
|
||||
_expected[_i]); \
|
||||
} \
|
||||
g_assert_null(nm_setting_connection_get_secondary(_s_con, _expected_len)); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
_assert_secondaries(s_con, (const char *const *) arr->pdata);
|
||||
|
|
|
|||
|
|
@ -1326,8 +1326,8 @@ test_nm_g_source_sentinel(void)
|
|||
|
||||
if (nmtst_get_rand_bool()) {
|
||||
s2 = nm_g_source_sentinel_get(0);
|
||||
g_assert_cmpint(g_atomic_int_get(&s2->ref_count), >=, 1);
|
||||
g_assert(s2 == s1);
|
||||
g_assert_cmpint(g_atomic_int_get(&s1->ref_count), >=, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1893,7 +1893,9 @@ nmp_utils_sysctl_open_netdir(int ifindex, const char *ifname_guess, char *out_if
|
|||
* end of the @try_count. */
|
||||
if (nm_streq(ifname, ifname_buf_last_try))
|
||||
return -1;
|
||||
strcpy(ifname_buf_last_try, ifname);
|
||||
|
||||
if (g_strlcpy(ifname_buf_last_try, ifname, IFNAMSIZ) >= IFNAMSIZ)
|
||||
nm_assert_not_reached();
|
||||
|
||||
fd_dir = open(sysdir, O_DIRECTORY | O_CLOEXEC);
|
||||
if (fd_dir < 0)
|
||||
|
|
|
|||
|
|
@ -3284,7 +3284,13 @@ do_connection_down(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons
|
|||
g_clear_error(&error);
|
||||
|
||||
if (info) {
|
||||
/* coverity thinks that info might be freed already while we still iterate
|
||||
* the loop. But it cannot, because connection_cb_info_finish() only does some
|
||||
* kind of ref-counting that ensures info stays alive long enough. */
|
||||
|
||||
/* coverity[pass_freed_arg] */
|
||||
g_signal_handlers_disconnect_by_func(active, down_active_connection_state_cb, info);
|
||||
|
||||
connection_cb_info_finish(info, active);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue