mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 12:20:09 +01:00
libnm: simplify assertions in _property_infos_sort_cmp_setting_connection()
What we sort is very static, the names of properties in NMSettingConnection. We know that the list contains no two identical names. There were already assertions for that, just rework them a bit to make the code clearer.
This commit is contained in:
parent
eb3b2d9ef6
commit
11ee08e78a
1 changed files with 6 additions and 9 deletions
|
|
@ -250,10 +250,8 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a,
|
|||
{
|
||||
const NMSettInfoProperty *a = *((const NMSettInfoProperty *const *) p_a);
|
||||
const NMSettInfoProperty *b = *((const NMSettInfoProperty *const *) p_b);
|
||||
int c_name;
|
||||
|
||||
c_name = strcmp(a->name, b->name);
|
||||
nm_assert(c_name != 0);
|
||||
nm_assert(a->name && b->name && !nm_streq(a->name, b->name));
|
||||
|
||||
#define CMP_AND_RETURN(n_a, n_b, name) \
|
||||
G_STMT_START \
|
||||
|
|
@ -266,15 +264,14 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a,
|
|||
G_STMT_END
|
||||
|
||||
/* for [connection], report first id, uuid, type in that order. */
|
||||
if (c_name != 0) {
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_ID);
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_UUID);
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_TYPE);
|
||||
}
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_ID);
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_UUID);
|
||||
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_TYPE);
|
||||
|
||||
#undef CMP_AND_RETURN
|
||||
|
||||
return c_name;
|
||||
NM_CMP_FIELD_STR(a, b, name);
|
||||
return nm_assert_unreachable_val(0);
|
||||
}
|
||||
|
||||
static const NMSettInfoProperty *const *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue