From e42c1f6171a56c372860481c4f9d5feb86529480 Mon Sep 17 00:00:00 2001 From: Jan Vaclav Date: Tue, 7 Apr 2026 13:17:30 +0200 Subject: [PATCH] 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: 395a78618b6d ('libnm/tests: add tests for creating wireguard connection profiles') Co-Authored-By: Claude Opus 4.6 (cherry picked from commit ca326bd636e642ef0c4916b8a0abaaacf13cd175) --- src/libnm-core-impl/tests/test-setting.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index f3070c1730..5f2a2ae3ec 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -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; }