core/utils: assert that completion results in a valid connection

Completion of a connection must always result in a valid connection and
the call to normalize() is always expected to succeed here.

Croak if it doesn't because the rest basically relies on the connection
being normalized. If it's not valid, and can't be normalized, it's a bug.
This commit is contained in:
Lubomir Rintel 2024-12-13 08:22:40 +01:00
parent 6e52a8ab9e
commit a93dbf95bd

View file

@ -267,6 +267,7 @@ _nm_utils_complete_generic_with_params(NMPlatform *platform,
va_list ap;
const char *p_val;
const char *p_key;
gboolean valid;
g_assert(fallback_id_prefix);
g_return_if_fail(ifname_prefix == NULL || ifname == NULL);
@ -315,7 +316,8 @@ _nm_utils_complete_generic_with_params(NMPlatform *platform,
g_hash_table_insert(parameters, (char *) p_key, (char *) p_val);
}
va_end(ap);
nm_connection_normalize(connection, parameters, NULL, NULL);
valid = nm_connection_normalize(connection, parameters, NULL, NULL);
nm_assert(valid);
}
/*****************************************************************************/