diff options
author | Thomas Haller <thaller@redhat.com> | 2022-11-08 18:45:43 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-11-10 09:36:53 +0100 |
commit | a0370e0efa8434d71f67bbc3ca3eb9a8c7e0e246 (patch) | |
tree | 3b8141ee86a917fc79a279102ed4d7e141b0b2ed | |
parent | 7f22835328ef364bfc1e0cc95205b47d12d48b5d (diff) |
ethtool: add and use nm_ethtool_id_get_variant_type() helper
-rw-r--r-- | src/libnm-base/nm-ethtool-base.c | 12 | ||||
-rw-r--r-- | src/libnm-base/nm-ethtool-base.h | 2 | ||||
-rw-r--r-- | src/libnm-core-impl/nm-setting-ethtool.c | 18 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/libnm-base/nm-ethtool-base.c b/src/libnm-base/nm-ethtool-base.c index db77651ac5..8e7d448c28 100644 --- a/src/libnm-base/nm-ethtool-base.c +++ b/src/libnm-base/nm-ethtool-base.c @@ -294,3 +294,15 @@ nm_ethtool_id_to_type(NMEthtoolID id) return NM_ETHTOOL_TYPE_UNKNOWN; } + +const GVariantType * +nm_ethtool_id_get_variant_type(NMEthtoolID ethtool_id) +{ + if (nm_ethtool_id_is_feature(ethtool_id) || nm_ethtool_id_is_pause(ethtool_id)) + return G_VARIANT_TYPE_BOOLEAN; + + if (nm_ethtool_id_is_coalesce(ethtool_id) || nm_ethtool_id_is_ring(ethtool_id)) + return G_VARIANT_TYPE_UINT32; + + return NULL; +} diff --git a/src/libnm-base/nm-ethtool-base.h b/src/libnm-base/nm-ethtool-base.h index abedcafe40..22bb88fbed 100644 --- a/src/libnm-base/nm-ethtool-base.h +++ b/src/libnm-base/nm-ethtool-base.h @@ -21,6 +21,8 @@ const NMEthtoolData *nm_ethtool_data_get_by_optname(const char *optname); NMEthtoolType nm_ethtool_id_to_type(NMEthtoolID id); +const GVariantType *nm_ethtool_id_get_variant_type(NMEthtoolID ethtool_id); + /****************************************************************************/ static inline NMEthtoolID diff --git a/src/libnm-core-impl/nm-setting-ethtool.c b/src/libnm-core-impl/nm-setting-ethtool.c index 71179efd39..1db6c3355f 100644 --- a/src/libnm-core-impl/nm-setting-ethtool.c +++ b/src/libnm-core-impl/nm-setting-ethtool.c @@ -23,20 +23,6 @@ /*****************************************************************************/ -static const GVariantType * -get_variant_type_from_ethtool_id(NMEthtoolID ethtool_id) -{ - if (nm_ethtool_id_is_feature(ethtool_id) || nm_ethtool_id_is_pause(ethtool_id)) - return G_VARIANT_TYPE_BOOLEAN; - - if (nm_ethtool_id_is_coalesce(ethtool_id) || nm_ethtool_id_is_ring(ethtool_id)) - return G_VARIANT_TYPE_UINT32; - - return NULL; -} - -/*****************************************************************************/ - /** * nm_ethtool_optname_is_feature: * @optname: (allow-none): the option name to check @@ -302,7 +288,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) NMEthtoolID ethtool_id; ethtool_id = nm_ethtool_id_get_by_name(optname); - variant_type = get_variant_type_from_ethtool_id(ethtool_id); + variant_type = nm_ethtool_id_get_variant_type(ethtool_id); if (!variant_type) { g_set_error_literal(error, @@ -365,7 +351,7 @@ get_variant_type(const NMSettInfoSetting *sett_info, const char *name, GError ** { const GVariantType *variant_type; - variant_type = get_variant_type_from_ethtool_id(nm_ethtool_id_get_by_name(name)); + variant_type = nm_ethtool_id_get_variant_type(nm_ethtool_id_get_by_name(name)); if (!variant_type) { g_set_error(error, |