From 8062d04cd4515f0491ac4d309a30c8b0da90eb68 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 8 Jan 2024 12:28:02 +0100 Subject: [PATCH] libnm: don't set .direct_string_allow_empty for _nm_setting_property_define_direct_mac_address() Most properties don't accept empty strings and reject them during verify(). All _nm_setting_property_define_direct_mac_address() call nm_utils_hwaddr_valid() on the string, which rejects empty strings. Clear the .direct_string_allow_empty flag for those. The usage of the flag is misleading. --- src/libnm-core-impl/nm-setting-private.h | 1 - src/libnm-core-impl/tests/test-setting.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index cf4054db68..9fe49de48b 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -1048,7 +1048,6 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p &nm_sett_info_propert_type_direct_mac_address, \ .direct_offset = \ NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \ - .direct_string_allow_empty = TRUE, \ __VA_ARGS__); \ } \ G_STMT_END diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index ee552cc1ea..e4f3ab9fc1 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -4743,12 +4743,6 @@ test_setting_metadata(void) if (sip->direct_string_allow_empty) { g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); } - if (!sip->direct_string_allow_empty - && sip->property_type->direct_type == NM_VALUE_TYPE_STRING) { - g_error("currently all properties must have this set: FAIL: %s.%s", - nm_setting_get_name(setting), - sip->name); - } if (sip->direct_set_string_mac_address_len != 0) { g_assert(NM_IN_SET(sip->property_type,