[Pkg-telepathy-commits] [libnice] 22/265: Add missing ‘default’ cases to switches

Simon McVittie smcv at debian.org
Wed May 14 12:04:48 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 71fa5bb8716ea311fc3a1d9cc845a123eb8cd4cc
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Tue Dec 17 09:24:03 2013 +0000

    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.
---
 agent/address.c    | 13 +++++++------
 agent/agent.c      |  5 ++---
 agent/candidate.c  | 12 +++++-------
 agent/conncheck.c  |  9 +++++++++
 agent/discovery.c  |  3 +++
 socket/turn.c      |  6 ++++++
 stun/stunmessage.c |  9 +++++++--
 stun/tools/stund.c |  8 ++++++++
 stun/usages/bind.c |  9 +++++++++
 stun/usages/ice.c  |  1 +
 stun/usages/turn.c |  8 ++++++++
 stun/utils.c       |  4 +++-
 12 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/agent/address.c b/agent/address.c
index b441a54..e37744d 100644
--- a/agent/address.c
+++ b/agent/address.c
@@ -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);
 }
 
 
diff --git a/agent/agent.c b/agent/agent.c
index e09855b..6d1bc2b 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -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)
diff --git a/agent/candidate.c b/agent/candidate.c
index b7636a8..7d66560 100644
--- a/agent/candidate.c
+++ b/agent/candidate.c
@@ -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); */
diff --git a/agent/conncheck.c b/agent/conncheck.c
index a862a1e..91d2392 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -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;
   }
 
 
diff --git a/agent/discovery.c b/agent/discovery.c
index 56995c6..bffc286 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -987,6 +987,9 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
               ++not_done; /* note: retry later */
               break;
             }
+          default:
+            /* Nothing to do. */
+            break;
 	}
 
       } else {
diff --git a/socket/turn.c b/socket/turn.c
index 41de521..f73bb22 100644
--- a/socket/turn.c
+++ b/socket/turn.c
@@ -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;
     }
   }
 
diff --git a/stun/stunmessage.c b/stun/stunmessage.c
index 32e05da..0479fa9 100644
--- a/stun/stunmessage.c
+++ b/stun/stunmessage.c
@@ -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
diff --git a/stun/tools/stund.c b/stun/tools/stund.c
index d340d19..7338fcf 100644
--- a/stun/tools/stund.c
+++ b/stun/tools/stund.c
@@ -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;
diff --git a/stun/usages/bind.c b/stun/usages/bind.c
index 01f0fec..1750a2b 100644
--- a/stun/usages/bind.c
+++ b/stun/usages/bind.c
@@ -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;
         }
       }
diff --git a/stun/usages/ice.c b/stun/usages/ice.c
index 909bbaa..08210d3 100644
--- a/stun/usages/ice.c
+++ b/stun/usages/ice.c
@@ -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;
diff --git a/stun/usages/turn.c b/stun/usages/turn.c
index 5bcf89b..cf819d5 100644
--- a/stun/usages/turn.c
+++ b/stun/usages/turn.c
@@ -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);
diff --git a/stun/utils.c b/stun/utils.c
index d3fb391..26d7520 100644
--- a/stun/utils.c
+++ b/stun/utils.c
@@ -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;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list