libnm/tests: fix dead code in WireGuard roundtrip test

The inner condition at line 4086 duplicated the outer check for
NM_CONNECTION_SERIALIZE_ALL, making the else-if branch for
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET unreachable. This meant
the non-secret serialization path was never actually tested.

Restructure to make both branches reachable.

Found by Coverity (CID: DEADCODE).

Fixes: 395a78618b ('libnm/tests: add tests for creating wireguard connection profiles')

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit ca326bd636)
This commit is contained in:
Jan Vaclav 2026-04-07 13:17:30 +02:00
parent 530a8934f5
commit e42c1f6171

View file

@ -4082,13 +4082,12 @@ test_roundtrip_conversion(gconstpointer test_data)
if (flag == NM_CONNECTION_SERIALIZE_ALL) {
s_wg2 = NM_SETTING_WIREGUARD(
nm_connection_get_setting(con2, NM_TYPE_SETTING_WIREGUARD));
if (flag == NM_CONNECTION_SERIALIZE_ALL)
_rndt_wg_peers_assert_equal(s_wg2, wg_peers, TRUE, TRUE, FALSE);
else if (flag == NM_CONNECTION_SERIALIZE_WITH_NON_SECRET)
_rndt_wg_peers_assert_equal(s_wg2, wg_peers, FALSE, FALSE, TRUE);
else
g_assert_not_reached();
_rndt_wg_peers_assert_equal(s_wg2, wg_peers, TRUE, TRUE, FALSE);
} else if (flag == NM_CONNECTION_SERIALIZE_WITH_NON_SECRET) {
con2 = _connection_new_from_dbus_strict(con_var, FALSE);
s_wg2 = NM_SETTING_WIREGUARD(
nm_connection_get_setting(con2, NM_TYPE_SETTING_WIREGUARD));
_rndt_wg_peers_assert_equal(s_wg2, wg_peers, FALSE, FALSE, TRUE);
}
break;
}