mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 23:50:16 +01:00
ifcfg-rh: make out_unhandled argument non-optional
Depending on the connection we are about to read,
we would assert that the user provided a @out_unhandled
argument.
That means, the user must always provide a valid @out_unhandled
pointer, because he cannot know beforehand how the reading
of the ifcfg file goes.
(cherry picked from commit 50d7ac4af3)
This commit is contained in:
parent
1d909f4229
commit
6de181247f
3 changed files with 11 additions and 12 deletions
|
|
@ -395,7 +395,9 @@ commit_changes (NMSettingsConnection *connection,
|
|||
*/
|
||||
filename = nm_settings_connection_get_filename (connection);
|
||||
if (filename) {
|
||||
reread = connection_from_file (filename, NULL, NULL, NULL);
|
||||
gs_free char *unhandled = NULL;
|
||||
|
||||
reread = connection_from_file (filename, &unhandled, NULL, NULL);
|
||||
if (reread) {
|
||||
same = nm_connection_compare (NM_CONNECTION (connection),
|
||||
reread,
|
||||
|
|
|
|||
|
|
@ -4848,7 +4848,7 @@ create_unhandled_connection (const char *filename, shvarFile *ifcfg,
|
|||
NMSetting *s_con;
|
||||
char *value;
|
||||
|
||||
g_assert (out_spec != NULL);
|
||||
nm_assert (out_spec && !*out_spec);
|
||||
|
||||
connection = nm_simple_connection_new ();
|
||||
|
||||
|
|
@ -4963,8 +4963,7 @@ connection_from_file_full (const char *filename,
|
|||
const char *ifcfg_name = NULL;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
if (out_unhandled)
|
||||
g_return_val_if_fail (*out_unhandled == NULL, NULL);
|
||||
g_return_val_if_fail (out_unhandled && !*out_unhandled, NULL);
|
||||
|
||||
/* Non-NULL only for unit tests; normally use /etc/sysconfig/network */
|
||||
if (!network_file)
|
||||
|
|
@ -4982,8 +4981,6 @@ connection_from_file_full (const char *filename,
|
|||
return NULL;
|
||||
|
||||
if (!svGetValueBoolean (parsed, "NM_CONTROLLED", TRUE)) {
|
||||
g_assert (out_unhandled != NULL);
|
||||
|
||||
connection = create_unhandled_connection (filename, parsed, "unmanaged", out_unhandled);
|
||||
if (!connection)
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
|
||||
|
|
@ -5136,8 +5133,6 @@ connection_from_file_full (const char *filename,
|
|||
else if (!strcasecmp (type, TYPE_BRIDGE))
|
||||
connection = bridge_connection_from_ifcfg (filename, parsed, error);
|
||||
else {
|
||||
g_assert (out_unhandled != NULL);
|
||||
|
||||
connection = create_unhandled_connection (filename, parsed, "unrecognized", out_unhandled);
|
||||
if (!connection)
|
||||
PARSE_WARNING ("connection type was unrecognized but device was not uniquely identified; device may be managed");
|
||||
|
|
|
|||
|
|
@ -67,11 +67,14 @@ _connection_from_file (const char *filename,
|
|||
{
|
||||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
char *unhandled_fallback = NULL;
|
||||
|
||||
g_assert (!out_unhandled || !*out_unhandled);
|
||||
|
||||
connection = connection_from_file_test (filename, network_file, test_type, out_unhandled, &error);
|
||||
connection = connection_from_file_test (filename, network_file, test_type,
|
||||
out_unhandled ?: &unhandled_fallback, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (!unhandled_fallback);
|
||||
|
||||
if (out_unhandled && *out_unhandled)
|
||||
nmtst_assert_connection_verifies (connection);
|
||||
|
|
@ -89,13 +92,12 @@ _connection_from_file_fail (const char *filename,
|
|||
NMConnection *connection;
|
||||
GError *local = NULL;
|
||||
char *unhandled = NULL;
|
||||
char **p_unhandled = (nmtst_get_rand_int () % 2) ? &unhandled : NULL;
|
||||
|
||||
connection = connection_from_file_test (filename, network_file, test_type, p_unhandled, &local);
|
||||
connection = connection_from_file_test (filename, network_file, test_type, &unhandled, &local);
|
||||
|
||||
g_assert (!connection);
|
||||
g_assert (local);
|
||||
g_assert (!p_unhandled || !*p_unhandled);
|
||||
g_assert (!unhandled);
|
||||
g_propagate_error (error, local);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue