summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-11-16 10:44:21 +0100
committerThomas Haller <thaller@redhat.com>2020-11-17 22:19:29 +0100
commitd0ec5011638e09f4d5c593b87f18d22789bf764e (patch)
tree20f24f14d7e275f94906a5d32f70a3e4d3cb67d5 /clients
parent9ebeeb6bf2389ecc79164cf010f3d169506f7ab8 (diff)
downloadNetworkManager-d0ec5011638e09f4d5c593b87f18d22789bf764e.tar.gz
cli: assert that valid_parts are set for base types
Diffstat (limited to 'clients')
-rw-r--r--clients/common/nm-meta-setting-desc.c20
-rw-r--r--clients/common/tests/test-clients-common.c8
2 files changed, 25 insertions, 3 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index aa6fa0dbf0..c18035de83 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -2564,8 +2564,12 @@ static const char *const *_complete_fcn_connection_type(ARGS_COMPLETE_FCN)
GType gtype = setting_info->general->get_setting_gtype();
const char * v;
- if (_nm_setting_type_get_base_type_priority(gtype) == NM_SETTING_PRIORITY_INVALID)
+ if (_nm_setting_type_get_base_type_priority(gtype) == NM_SETTING_PRIORITY_INVALID) {
+ nm_assert(!setting_info->valid_parts);
continue;
+ }
+
+ nm_assert(setting_info->valid_parts);
v = setting_info->alias;
if (v) {
@@ -8150,7 +8154,12 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
),
),
- SETTING_INFO (OVS_DPDK),
+ SETTING_INFO (OVS_DPDK,
+ .valid_parts = NM_META_SETTING_VALID_PARTS (
+ NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
+ NM_META_SETTING_VALID_PART_ITEM (OVS_DPDK, TRUE),
+ ),
+ ),
SETTING_INFO_EMPTY (OVS_EXTERNAL_IDS),
SETTING_INFO (OVS_INTERFACE,
.valid_parts = NM_META_SETTING_VALID_PARTS (
@@ -8164,7 +8173,12 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
NM_META_SETTING_VALID_PART_ITEM (ETHTOOL, FALSE),
),
),
- SETTING_INFO (OVS_PATCH),
+ SETTING_INFO (OVS_PATCH,
+ .valid_parts = NM_META_SETTING_VALID_PARTS (
+ NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
+ NM_META_SETTING_VALID_PART_ITEM (OVS_PATCH, TRUE),
+ ),
+ ),
SETTING_INFO (OVS_PORT,
.valid_parts = NM_META_SETTING_VALID_PARTS (
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
diff --git a/clients/common/tests/test-clients-common.c b/clients/common/tests/test-clients-common.c
index 8a59d4e288..d4c53d24c3 100644
--- a/clients/common/tests/test-clients-common.c
+++ b/clients/common/tests/test-clients-common.c
@@ -53,6 +53,9 @@ test_client_meta_check(void)
for (m = 0; m < _NM_META_SETTING_TYPE_NUM; m++) {
const NMMetaSettingInfoEditor *info = &nm_meta_setting_infos_editor[m];
+ GType gtype;
+ NMSettingPriority base_priority;
+ gboolean is_base_type;
g_assert(info);
g_assert(info->meta_type == &nm_meta_type_setting_info_editor);
@@ -97,6 +100,11 @@ test_client_meta_check(void)
} else
g_assert(!info->properties);
+ gtype = info->general->get_setting_gtype();
+ base_priority = _nm_setting_type_get_base_type_priority(gtype);
+ is_base_type = (base_priority != NM_SETTING_PRIORITY_INVALID);
+ g_assert((!!info->valid_parts) == is_base_type);
+
if (info->valid_parts) {
gsize i, l;
gs_unref_hashtable GHashTable *dup = g_hash_table_new(nm_direct_hash, NULL);