summaryrefslogtreecommitdiff
path: root/libnm/nm-device-generic.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-12 19:50:32 +0200
committerThomas Haller <thaller@redhat.com>2016-10-24 10:14:02 +0200
commit95ab69b761293993c27d64137b9c5163d4773de0 (patch)
treee0f9f1c06c212d66d534bcfd47b53863557f94c9 /libnm/nm-device-generic.c
parent21d7aa92044b458028e1968cd09ec015edf977ec (diff)
downloadNetworkManager-95ab69b761293993c27d64137b9c5163d4773de0.tar.gz
libnm: coerce empty strings to NULL for D-Bus properties
On D-Bus level, string (s) or object paths (o) cannot be NULL. Thus, whenver server exposes such an object, it gets automatically coerced to "" or "/", respectively. On client side, libnm should coerce certain properties back, for which "" is just not a sensible value. For example, an empty NM_DEVICE_ETHERNET_HW_ADDRESS should be instead exposed as NULL. Technically, this is an API change. However, all users were well advised to expect both NULL and "" as possible return values and handle them accordingly.
Diffstat (limited to 'libnm/nm-device-generic.c')
-rw-r--r--libnm/nm-device-generic.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c
index 9dd1c945ec..6bc1336219 100644
--- a/libnm/nm-device-generic.c
+++ b/libnm/nm-device-generic.c
@@ -59,7 +59,7 @@ nm_device_generic_get_hw_address (NMDeviceGeneric *device)
{
g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL);
- return NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address;
+ return nm_str_not_empty (NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address);
}
/*****************************************************************************/
@@ -69,7 +69,7 @@ get_type_description (NMDevice *device)
{
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device);
- return priv->type_description;
+ return nm_str_not_empty (priv->type_description);
}
static const char *
@@ -150,14 +150,15 @@ get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
+ NMDeviceGeneric *self = NM_DEVICE_GENERIC (object);
+ NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self);
switch (prop_id) {
case PROP_HW_ADDRESS:
g_value_set_string (value, priv->hw_address);
break;
case PROP_TYPE_DESCRIPTION:
- g_value_set_string (value, priv->type_description);
+ g_value_set_string (value, get_type_description ((NMDevice *) self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);