Commit 71fa5bb8 authored by Philip Withnall's avatar Philip Withnall Committed by Olivier Crête

Add missing ‘default’ cases to switches

This shuts GCC’s -Wswitch-default warning, and makes the code flow a
little more explicit.

This introduces no functional changes.
parent bb276388
......@@ -180,9 +180,9 @@ nice_address_get_port (const NiceAddress *addr)
return ntohs (addr->s.ip4.sin_port);
case AF_INET6:
return ntohs (addr->s.ip6.sin6_port);
default:
g_return_val_if_reached (0);
}
g_return_val_if_reached (0);
}
......@@ -278,9 +278,10 @@ nice_address_equal (const NiceAddress *a, const NiceAddress *b)
return IN6_ARE_ADDR_EQUAL (&a->s.ip6.sin6_addr, &b->s.ip6.sin6_addr)
&& (a->s.ip6.sin6_port == b->s.ip6.sin6_port)
&& (a->s.ip6.sin6_scope_id == b->s.ip6.sin6_scope_id);
}
g_return_val_if_reached (FALSE);
default:
g_return_val_if_reached (FALSE);
}
}
......@@ -345,9 +346,9 @@ nice_address_is_private (const NiceAddress *a)
return ipv4_address_is_private (a->s.ip4.sin_addr.s_addr);
case AF_INET6:
return ipv6_address_is_private (a->s.ip6.sin6_addr.s6_addr);
default:
g_return_val_if_reached (FALSE);
}
g_return_val_if_reached (FALSE);
}
......
......@@ -1318,10 +1318,9 @@ component_state_to_string (NiceComponentState state)
case NICE_COMPONENT_STATE_FAILED:
return "failed";
case NICE_COMPONENT_STATE_LAST:
break;
default:
return "invalid";
}
return "invalid";
}
void agent_signal_component_state_change (NiceAgent *agent, guint stream_id, guint component_id, NiceComponentState state)
......
......@@ -93,10 +93,8 @@ nice_candidate_jingle_priority (NiceCandidate *candidate)
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 900;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 900;
case NICE_CANDIDATE_TYPE_RELAYED: return 500;
default: return 0;
}
/* appease GCC */
return 0;
}
guint32
......@@ -108,10 +106,8 @@ nice_candidate_msn_priority (NiceCandidate *candidate)
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 550;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 550;
case NICE_CANDIDATE_TYPE_RELAYED: return 450;
default: return 0;
}
/* appease GCC */
return 0;
}
......@@ -138,7 +134,7 @@ nice_candidate_ice_priority_full (
guint32
nice_candidate_ice_priority (const NiceCandidate *candidate)
{
guint8 type_preference = 0;
guint8 type_preference;
switch (candidate->type)
{
......@@ -150,6 +146,8 @@ nice_candidate_ice_priority (const NiceCandidate *candidate)
type_preference = NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE; break;
case NICE_CANDIDATE_TYPE_RELAYED:
type_preference = NICE_CANDIDATE_TYPE_PREF_RELAYED; break;
default:
type_preference = 0; break;
}
/* return _candidate_ice_priority (type_preference, 1, candidate->component_id); */
......
......@@ -313,6 +313,9 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
keep_timer_going = TRUE;
break;
}
default:
/* Nothing to do. */
break;
}
}
}
......@@ -530,6 +533,9 @@ static gboolean priv_conn_keepalive_retransmissions_tick (gpointer pointer)
stun_timer_remainder (&pair->keepalive.timer),
priv_conn_keepalive_retransmissions_tick, pair);
break;
default:
/* Nothing to do. */
break;
}
......@@ -768,6 +774,9 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe
stun_timer_remainder (&cand->timer),
priv_turn_allocate_refresh_retransmissions_tick, cand);
break;
default:
/* Nothing to do. */
break;
}
......
......@@ -987,6 +987,9 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
++not_done; /* note: retry later */
break;
}
default:
/* Nothing to do. */
break;
}
} else {
......
......@@ -1188,6 +1188,9 @@ priv_retransmissions_tick_unlocked (TurnPriv *priv)
case STUN_USAGE_TIMER_RETURN_SUCCESS:
ret = TRUE;
break;
default:
/* Nothing to do. */
break;
}
}
......@@ -1248,6 +1251,9 @@ priv_retransmissions_create_permission_tick_unlocked (TurnPriv *priv, GList *lis
case STUN_USAGE_TIMER_RETURN_SUCCESS:
ret = TRUE;
break;
default:
/* Nothing to do. */
break;
}
}
......
......@@ -124,6 +124,10 @@ stun_message_find (const StunMessage *msg, StunAttribute type,
case STUN_ATTRIBUTE_FINGERPRINT:
/* Nothing may come after FPR */
return NULL;
default:
/* Nothing misordered. */
break;
}
if (!(msg->agent &&
......@@ -272,9 +276,10 @@ stun_message_find_addr (const StunMessage *msg, StunAttribute type,
memcpy (&ip6->sin6_addr, ptr + 4, 16);
return STUN_MESSAGE_RETURN_SUCCESS;
}
}
return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
default:
return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
}
}
StunMessageReturn
......
......@@ -46,6 +46,7 @@
#ifndef _WIN32
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
......@@ -125,6 +126,9 @@ int listen_socket (int fam, int type, int proto, unsigned int port)
#endif
addr.in6.sin6_port = htons (port);
break;
default:
assert (0); /* should never be reached */
}
if (bind (fd, (struct sockaddr *)&addr, sizeof (struct sockaddr)))
......@@ -148,6 +152,9 @@ int listen_socket (int fam, int type, int proto, unsigned int port)
setsockopt (fd, SOL_IPV6, IPV6_RECVERR, &yes, sizeof (yes));
#endif
break;
default:
assert (0); /* should never be reached */
}
}
else
......@@ -275,6 +282,7 @@ int main (int argc, char *argv[])
switch (c)
{
default:
case '4':
family = AF_INET;
break;
......
......@@ -143,6 +143,10 @@ StunUsageBindReturn stun_usage_bind_process (StunMessage *msg,
}
return STUN_USAGE_BIND_RETURN_ERROR;
default:
/* Fall through. */
break;
}
stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg));
......@@ -257,6 +261,9 @@ static int stun_socket (int family, int type, int proto)
case AF_INET6:
setsockopt (fd, SOL_IPV6, IPV6_RECVERR, &yes, sizeof (yes));
break;
default:
/* Nothing to do. */
break;
}
}
#endif
......@@ -500,6 +507,8 @@ StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv,
}
continue;
case STUN_USAGE_TIMER_RETURN_SUCCESS:
default:
/* Fall through. */
break;
}
}
......
......@@ -149,6 +149,7 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
break;
case STUN_ERROR:
default:
if (stun_message_find_error (msg, &code) != STUN_MESSAGE_RETURN_SUCCESS) {
/* missing ERROR-CODE: ignore message */
return STUN_USAGE_ICE_RETURN_INVALID;
......
......@@ -315,6 +315,10 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
}
return STUN_USAGE_TURN_RETURN_ERROR;
default:
/* Fall through. */
break;
}
stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg));
......@@ -396,6 +400,10 @@ StunUsageTurnReturn stun_usage_turn_refresh_process (StunMessage *msg,
}
return STUN_USAGE_TURN_RETURN_ERROR;
default:
/* Fall through. */
break;
}
stun_message_find32 (msg, STUN_ATTRIBUTE_LIFETIME, lifetime);
......
......@@ -117,6 +117,8 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
ip6->sin6_addr.s6_addr[i] ^= msg->buffer[4 + i];
return STUN_MESSAGE_RETURN_SUCCESS;
}
default:
return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
}
return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment