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 62263e706f)
This commit is contained in:
Thomas Haller 2020-06-22 11:55:09 +02:00
parent 092ab227d5
commit 6ae1f0e459
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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);