From 4aa7e09d1fca28c31589ab7e9dd1c94bd7b63dcd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 23 Mar 2016 16:18:25 +0100 Subject: [PATCH] libnm: be more accepting for invalid connections from NetworkManager Relax our error checking which will allow us to try harder to make the best out of whatever NetworkManager sends us. Also, drop the g_warning(). First, now we really don't expect this function to fail. And even in that case, raising a g_warning() from the library is not very friendly to the user of libnm. --- libnm/nm-remote-connection.c | 11 +++++------ libnm/tests/test-nm-client.c | 4 ---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index c4a0b6aeb..eb2874a04 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -26,6 +26,7 @@ #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-setting-connection.h" +#include "nm-core-internal.h" #include "nm-remote-connection.h" #include "nm-remote-connection-private.h" @@ -563,13 +564,11 @@ replace_settings (NMRemoteConnection *self, GVariant *new_settings) { GError *error = NULL; - if (!nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) { - g_warning ("%s: error updating connection %s settings: %s", - __func__, - nm_connection_get_path (NM_CONNECTION (self)), - error->message); + if (!_nm_connection_replace_settings ((NMConnection *) self, + new_settings, + NM_SETTING_PARSE_FLAGS_BEST_EFFORT, + &error)) g_clear_error (&error); - } } static void diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index c6a4a05ca..3a7c4d5dd 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -1309,9 +1309,7 @@ test_connection_invalid (void) FALSE, &path2); - g_test_expect_message ("libnm", G_LOG_LEVEL_WARNING, "*replace_settings: error updating connection /org/freedesktop/NetworkManager/Settings/Connection/3 settings: *"); client = nm_client_new (NULL, &error); - g_test_assert_expected_messages (); g_assert_no_error (error); connections = nm_client_get_connections (client); @@ -1385,9 +1383,7 @@ test_connection_invalid (void) variant, FALSE); - g_test_expect_message ("libnm", G_LOG_LEVEL_WARNING, "*replace_settings: error updating connection /org/freedesktop/NetworkManager/Settings/Connection/3 settings: *"); nmtst_main_loop_run (loop, 100); - g_test_assert_expected_messages (); connections = nm_client_get_connections (client); g_assert (connections); -- 2.17.1