diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-30 10:48:45 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-11-06 17:30:25 +0100 |
commit | e2dac63de6a6ce784f1308608b695bd91a1d91ab (patch) | |
tree | 31418ffaada4aa7fdc3ca72a9376f3badd29fd0d | |
parent | ea8546b622729b940e51b38620af36c3b2261802 (diff) | |
download | NetworkManager-e2dac63de6a6ce784f1308608b695bd91a1d91ab.tar.gz |
libnm: fix handling "q" (uint16) property types in libnm
NMDeviceVxlan has some "q" type properties. They were not handled:
$ G_MESSAGES_DEBUG=all PAGER= LIBNM_GLIB_DEBUG=properties-changed nmcli 2>&1 | grep "couldn't be set from D-Bus type"
libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:dst-port (type guint) couldn't be set from D-Bus type q.
libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:src-port-max (type guint) couldn't be set from D-Bus type q.
libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:src-port-min (type guint) couldn't be set from D-Bus type q.
libnm-Message: 10:44:04.539: demarshal_generic: NMDeviceWireGuard:listen-port (type guint) couldn't be set from D-Bus type q.
-rw-r--r-- | libnm/nm-object.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libnm/nm-object.c b/libnm/nm-object.c index e77372446f..a49a905859 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -947,14 +947,24 @@ properties_changed (GDBusProxy *proxy, } } -#define HANDLE_TYPE(vtype, ctype, getter) \ - G_STMT_START { \ +#define HANDLE_TYPE_CHECK(vtype, ctype, getter) \ + ({ \ + gboolean _success = FALSE; \ + \ if (g_variant_is_of_type (value, vtype)) { \ ctype *param = (ctype *) field; \ ctype newval = getter (value); \ different = *param != newval; \ *param = newval; \ - } else { \ + _success = TRUE; \ + } \ + \ + _success; \ + }) + +#define HANDLE_TYPE(vtype, ctype, getter) \ + G_STMT_START { \ + if (!HANDLE_TYPE_CHECK (vtype, ctype, getter)) {\ success = FALSE; \ goto done; \ } \ @@ -1066,9 +1076,11 @@ demarshal_generic (NMObject *object, NM_PRAGMA_WARNING_REENABLE } else if (pspec->value_type == G_TYPE_INT) HANDLE_TYPE (G_VARIANT_TYPE_INT32, int, g_variant_get_int32); - else if (pspec->value_type == G_TYPE_UINT) - HANDLE_TYPE (G_VARIANT_TYPE_UINT32, guint, g_variant_get_uint32); - else if (pspec->value_type == G_TYPE_INT64) + else if (pspec->value_type == G_TYPE_UINT) { + if ( !HANDLE_TYPE_CHECK (G_VARIANT_TYPE_UINT32, guint, g_variant_get_uint32) + && !HANDLE_TYPE_CHECK (G_VARIANT_TYPE_UINT16, guint, g_variant_get_uint16)) + success = FALSE; + } else if (pspec->value_type == G_TYPE_INT64) HANDLE_TYPE (G_VARIANT_TYPE_INT64, gint64, g_variant_get_int64); else if (pspec->value_type == G_TYPE_UINT64) HANDLE_TYPE (G_VARIANT_TYPE_UINT64, guint64, g_variant_get_uint64); |