diff options
author | Thomas Haller <thaller@redhat.com> | 2018-05-16 08:43:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-05-16 08:45:42 +0200 |
commit | 009b7d61ad5679e405483973d843660d3d7a19d6 (patch) | |
tree | 3e1e92e08d8a934aae1e54ea2490521636d0649e | |
parent | c905ee94f09e76db917a684a2fb44d83886475f5 (diff) |
core: minor cleanup using helpers NM_IN_STRSET() and nm_utils_strdict_get_keys()
-rw-r--r-- | src/dhcp/nm-dhcp-client.c | 17 | ||||
-rw-r--r-- | src/nm-core-utils.c | 7 |
2 files changed, 7 insertions, 17 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index f407da89a..7d42a786e 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -736,14 +736,6 @@ maybe_add_option (NMDhcpClient *self, GVariant *value) { char *str_value = NULL; - const char **p; - static const char *ignored_keys[] = { - "interface", - "pid", - "reason", - "dhcp_message_type", - NULL - }; g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING)); @@ -751,10 +743,11 @@ maybe_add_option (NMDhcpClient *self, return; /* Filter out stuff that's not actually new DHCP options */ - for (p = ignored_keys; *p; p++) { - if (!strcmp (*p, key)) - return; - } + if (NM_IN_STRSET (key, "interface", + "pid", + "reason", + "dhcp_message_type")) + return; if (g_str_has_prefix (key, NEW_TAG)) key += NM_STRLEN (NEW_TAG); diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 0e3f5cc91..4b266ed56 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -4178,12 +4178,9 @@ nm_utils_strdict_to_variant (GHashTable *options) GVariantBuilder builder; gs_free const char **keys = NULL; guint i; - guint nkeys = 0; + guint nkeys; - if (options) { - keys = (const char **) g_hash_table_get_keys_as_array (options, &nkeys); - nm_utils_strv_sort (keys, nkeys); - } + keys = nm_utils_strdict_get_keys (options, TRUE, &nkeys); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); for (i = 0; i < nkeys; i++) { |