From d5eb873eec1615159a0dc0ecd6662a64f5cb5bd1 Mon Sep 17 00:00:00 2001 From: luokai <454728735@qq.com> Date: Mon, 21 Feb 2022 13:36:52 +0800 Subject: [PATCH] platform: use switch statement in _linktype_get_type() for better readability https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1110 --- src/libnm-platform/nm-linux-platform.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index f87182936a..e3cc7a4dbc 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -1114,20 +1114,22 @@ _linktype_get_type(NMPlatform *platform, return link_type; } - if (arptype == ARPHRD_LOOPBACK) + switch (arptype) { + case ARPHRD_LOOPBACK: return NM_LINK_TYPE_LOOPBACK; - else if (arptype == ARPHRD_INFINIBAND) + case ARPHRD_INFINIBAND: return NM_LINK_TYPE_INFINIBAND; - else if (arptype == ARPHRD_SIT) + case ARPHRD_SIT: return NM_LINK_TYPE_SIT; - else if (arptype == ARPHRD_TUNNEL6) + case ARPHRD_TUNNEL6: return NM_LINK_TYPE_IP6TNL; - else if (arptype == ARPHRD_PPP) + case ARPHRD_PPP: return NM_LINK_TYPE_PPP; - else if (arptype == ARPHRD_IEEE802154) + case ARPHRD_IEEE802154: return NM_LINK_TYPE_WPAN; - else if (arptype == ARPHRD_6LOWPAN) + case ARPHRD_6LOWPAN: return NM_LINK_TYPE_6LOWPAN; + } { NMPUtilsEthtoolDriverInfo driver_info;