diff options
author | Thomas Haller <thaller@redhat.com> | 2015-03-03 11:06:59 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-03-03 11:07:01 +0100 |
commit | 5599a82d0dc7b69497cb29f67bb0fb8cd618d32c (patch) | |
tree | f670738830f7577bcfe84037e8679e6d5b08326a | |
parent | e93309e81dce04a56d5c7015efd1c2730104202f (diff) | |
download | NetworkManager-5599a82d0dc7b69497cb29f67bb0fb8cd618d32c.tar.gz |
wwan: refactor nm_modem_ip_type_to_string() and fix return type
The statement
g_return_val_if_reached (NM_MODEM_IP_TYPE_UNKNOWN);
was wrong, because the return type is 'const char *'.
But just refactor nm_modem_ip_type_to_string() to get rid of
the static table and make it a switch statement.
Fixes: 85d9132464b76b75c0145376458c35f16472dc32
-rw-r--r-- | src/devices/wwan/nm-modem.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 9f7f60951a..bbb229d930 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -222,29 +222,19 @@ nm_modem_get_supported_ip_types (NMModem *self) return NM_MODEM_GET_PRIVATE (self)->ip_types; } -typedef struct { - NMModemIPType ip_type; - const gchar *name; -} IpTypeTable; - -static const IpTypeTable ip_types[] = { - { NM_MODEM_IP_TYPE_IPV4, "ipv4" }, - { NM_MODEM_IP_TYPE_IPV6, "ipv6" }, - { NM_MODEM_IP_TYPE_IPV4V6, "ipv4v6" }, - { NM_MODEM_IP_TYPE_UNKNOWN, "unknown" }, -}; - const gchar * nm_modem_ip_type_to_string (NMModemIPType ip_type) { - guint i; - - for (i = 0; i < G_N_ELEMENTS (ip_types); i++) { - if (ip_type == ip_types[i].ip_type) - return ip_types[i].name; + switch (ip_type) { + case NM_MODEM_IP_TYPE_IPV4: + return "ipv4"; + case NM_MODEM_IP_TYPE_IPV6: + return "ipv6"; + case NM_MODEM_IP_TYPE_IPV4V6: + return "ipv4v6"; + default: + g_return_val_if_reached ("unknown"); } - - g_return_val_if_reached (NM_MODEM_IP_TYPE_UNKNOWN); } static GArray * |