summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-01-27 14:13:09 +0100
committerThomas Haller <thaller@redhat.com>2017-02-10 14:40:23 +0100
commit8ac14b5400a2017a8383c5352973b14666023ae6 (patch)
treed04363603acbfcb3d707c15ed5d7bb21c86e1b2e
parente234673a4aab53675374e35eedf02ff9949157f4 (diff)
downloadNetworkManager-8ac14b5400a2017a8383c5352973b14666023ae6.tar.gz
device: implement queued_state_to_string() via NM_UTILS_LOOKUP_STR_DEFINE_STATIC()
-rw-r--r--src/devices/nm-device.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 84c08bf91b..34fc54e071 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -500,29 +500,22 @@ static void _cancel_activation (NMDevice *self);
/*****************************************************************************/
-static const char *state_table[] = {
- [NM_DEVICE_STATE_UNKNOWN] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unknown",
- [NM_DEVICE_STATE_UNMANAGED] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unmanaged",
- [NM_DEVICE_STATE_UNAVAILABLE] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unavailable",
- [NM_DEVICE_STATE_DISCONNECTED] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "disconnected",
- [NM_DEVICE_STATE_PREPARE] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "prepare",
- [NM_DEVICE_STATE_CONFIG] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "config",
- [NM_DEVICE_STATE_NEED_AUTH] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "need-auth",
- [NM_DEVICE_STATE_IP_CONFIG] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "ip-config",
- [NM_DEVICE_STATE_IP_CHECK] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "ip-check",
- [NM_DEVICE_STATE_SECONDARIES] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "secondaries",
- [NM_DEVICE_STATE_ACTIVATED] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "activated",
- [NM_DEVICE_STATE_DEACTIVATING] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "deactivating",
- [NM_DEVICE_STATE_FAILED] = NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "failed",
-};
-
-static const char *
-queued_state_to_string (NMDeviceState state)
-{
- if ((gsize) state < G_N_ELEMENTS (state_table))
- return state_table[state];
- return state_table[NM_DEVICE_STATE_UNKNOWN];
-}
+NM_UTILS_LOOKUP_STR_DEFINE_STATIC (queued_state_to_string, NMDeviceState,
+ NM_UTILS_LOOKUP_DEFAULT ( NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "???"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_UNKNOWN, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unknown"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_UNMANAGED, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unmanaged"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_UNAVAILABLE, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "unavailable"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_DISCONNECTED, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "disconnected"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_PREPARE, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "prepare"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_CONFIG, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "config"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_NEED_AUTH, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "need-auth"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_IP_CONFIG, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "ip-config"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_IP_CHECK, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "ip-check"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_SECONDARIES, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "secondaries"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_ACTIVATED, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "activated"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_DEACTIVATING, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "deactivating"),
+ NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_FAILED, NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "failed"),
+);
static const char *
state_to_string (NMDeviceState state)