From 6ae1f0e4591d54f00d49e21d06d031662a607cd6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Jun 2020 11:55:09 +0200 Subject: [PATCH] libnm: return NULL for boxed strv properties of NMSettingMatch The API does not allow to distinguish between an unset (NULL) or empty strv array. For example, nm_setting_match_get_paths() never returns %NULL, but returns an empty strv array. On the other hand, the GObject properties of type G_TYPE_STRV have a default value of %NULL. That means, also the getter should map both unset and empty to %NULL. Note that this is a change in behavior w.r.t. 1.24.0 API, where match.interface-name property would return an empty strv array. Regrading the other API, this is no change because it is new API and we will fix it before 1.26.0 release. (cherry picked from commit 62263e706fb7e3ac9ab628af60e4f52faf67a2ea) --- libnm-core/nm-setting-match.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libnm-core/nm-setting-match.c b/libnm-core/nm-setting-match.c index 6071c88290..599fcf9916 100644 --- a/libnm-core/nm-setting-match.c +++ b/libnm-core/nm-setting-match.c @@ -659,16 +659,16 @@ get_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_INTERFACE_NAME: - g_value_set_boxed (value, nm_strvarray_get_strv (&self->interface_name, NULL)); + g_value_set_boxed (value, nm_strvarray_get_strv_non_empty (self->interface_name, NULL)); break; case PROP_KERNEL_COMMAND_LINE: - g_value_set_boxed (value, nm_strvarray_get_strv (&self->kernel_command_line, NULL)); + g_value_set_boxed (value, nm_strvarray_get_strv_non_empty (self->kernel_command_line, NULL)); break; case PROP_DRIVER: - g_value_set_boxed (value, nm_strvarray_get_strv (&self->driver, NULL)); + g_value_set_boxed (value, nm_strvarray_get_strv_non_empty (self->driver, NULL)); break; case PROP_PATH: - g_value_set_boxed (value, nm_strvarray_get_strv (&self->path, NULL)); + g_value_set_boxed (value, nm_strvarray_get_strv_non_empty (self->path, NULL)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);