ip-tunnel: tigthen up checks for valid IP tunnel modes

The compiler warns us when we don't specify all enum values
in a switch(), provided that default: is missing.

Make use of that to get a warning when we add a new tunnel mode.
This commit is contained in:
Thomas Haller 2016-11-08 09:42:31 +01:00 committed by Beniamino Galvani
parent cd73f281cc
commit a6416cbd13
2 changed files with 10 additions and 4 deletions

View file

@ -291,7 +291,7 @@ static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE (setting);
int family;
int family = AF_UNSPEC;
switch (priv->mode) {
case NM_IP_TUNNEL_MODE_IPIP:
@ -307,8 +307,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
case NM_IP_TUNNEL_MODE_VTI6:
family = AF_INET6;
break;
default:
family = AF_UNSPEC;
case NM_IP_TUNNEL_MODE_UNKNOWN:
break;
}
if (family == AF_UNSPEC) {

View file

@ -585,9 +585,15 @@ tunnel_mode_to_link_type (NMIPTunnelMode tunnel_mode)
return NM_LINK_TYPE_IPIP;
case NM_IP_TUNNEL_MODE_SIT:
return NM_LINK_TYPE_SIT;
default:
case NM_IP_TUNNEL_MODE_VTI:
case NM_IP_TUNNEL_MODE_IP6GRE:
case NM_IP_TUNNEL_MODE_VTI6:
case NM_IP_TUNNEL_MODE_ISATAP:
return NM_LINK_TYPE_UNKNOWN;
case NM_IP_TUNNEL_MODE_UNKNOWN:
break;
}
g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN);
}
/*****************************************************************************/