summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-03-03 11:06:59 +0100
committerThomas Haller <thaller@redhat.com>2015-03-05 12:55:04 +0100
commitae500e4ee0428fee09ef3d6d21fe0e8d4acfadde (patch)
tree128a76cfd6ea0afba8dea8c06c38a57372f6fe1a
parenta7323ab2cc5c827ad26876c97484c4556c8995a2 (diff)
downloadNetworkManager-ae500e4ee0428fee09ef3d6d21fe0e8d4acfadde.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: 02beeeeb1233c9b6cfd1193fd2c56b5566ca8612 (cherry picked from commit 5599a82d0dc7b69497cb29f67bb0fb8cd618d32c)
-rw-r--r--src/devices/wwan/nm-modem.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index 3729c6202a..69eaddf3c0 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -221,29 +221,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 *