From 63c4827af23cf741d47d2e393bb491cfec12c6c5 Mon Sep 17 00:00:00 2001 From: Jan Vaclav Date: Mon, 8 Jan 2024 12:45:56 +0100 Subject: [PATCH] libnm-core: add direct_strv_not_null property This property indicates that a non-null strv array is expected, and an empty strv array should be returned instead of NULL if it hadn't been created yet. --- src/libnm-core-impl/nm-setting.c | 2 +- src/libnm-core-intern/nm-core-internal.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index fc3f42f8bc..f3dc6442a3 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -859,7 +859,7 @@ _nm_setting_property_get_property_direct(GObject *object, value, nm_strvarray_get_strv_full_dup(p_val->arr, NULL, - FALSE, + property_info->direct_strv_not_null, property_info->direct_strv_preserve_empty)); return; } diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index f64cdd873c..b9af77572f 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -868,6 +868,10 @@ struct _NMSettInfoProperty { * an empty array. */ bool direct_strv_preserve_empty : 1; + /* This flag indicates that an empty strv array should be returned + * instead of NULL if it hadn't been created yet. */ + bool direct_strv_not_null : 1; + /* Usually, properties that are set to the default value for the GParamSpec * are not serialized to GVariant (and NULL is returned by to_dbus_data(). * Set this flag to force always converting the property even if the value