From 858fb211ad11bd9a7e89f63fe62d4fa7f8cee7b1 Mon Sep 17 00:00:00 2001 From: Antonio Cardace Date: Thu, 7 May 2020 17:09:49 +0200 Subject: [PATCH] keyfile: add support for uint32 variant types when using gendata https://bugzilla.redhat.com/show_bug.cgi?id=1614700 --- shared/nm-keyfile/nm-keyfile.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/shared/nm-keyfile/nm-keyfile.c b/shared/nm-keyfile/nm-keyfile.c index 0caef893e0..372ae202e3 100644 --- a/shared/nm-keyfile/nm-keyfile.c +++ b/shared/nm-keyfile/nm-keyfile.c @@ -3243,6 +3243,22 @@ _read_setting (KeyfileReaderInfo *info) continue; } variant = g_variant_new_boolean (v); + } else if (g_variant_type_equal (variant_type, G_VARIANT_TYPE_UINT32)) { + guint64 v; + + v = g_key_file_get_uint64 (info->keyfile, + info->group, + key, + &local); + + if (local) { + if (!handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN, + _("key '%s.%s' is not a uint32"), + info->group, key)) + break; + continue; + } + variant = g_variant_new_uint32 ((guint32) v); } else { nm_assert_not_reached (); continue; @@ -3851,6 +3867,11 @@ nm_keyfile_write (NMConnection *connection, setting_name, key, g_variant_get_boolean (v)); + } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) { + g_key_file_set_uint64 (info.keyfile, + setting_name, + key, + (guint64) g_variant_get_uint32 (v)); } else { /* BUG: The variant type is not implemented. Since the connection * verifies, this can only mean we either wrongly didn't reject