Turn a switch() with no default case into an explicit if+assert.
authorEmil Mikulic <emikulic@gmail.com>
Thu, 1 Mar 2012 09:20:06 +0000 (20:20 +1100)
committerEmil Mikulic <emikulic@gmail.com>
Thu, 1 Mar 2012 09:20:06 +0000 (20:20 +1100)
dns.c

diff --git a/dns.c b/dns.c
index f8d7296..e8bdbb4 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -191,16 +191,15 @@ dns_get_result(struct addr *ipaddr, char **name)
       /* Identify common special cases.  */
       const char *type = "none";
 
-      switch (reply.addr.family) {
-      case IPv6:
+      if (reply.addr.family == IPv6) {
          if (IN6_IS_ADDR_LINKLOCAL(&reply.addr.ip.v6))
             type = "link-local";
          else if (IN6_IS_ADDR_SITELOCAL(&reply.addr.ip.v6))
             type = "site-local";
          else if (IN6_IS_ADDR_MULTICAST(&reply.addr.ip.v6))
             type = "multicast";
-         break;
-      case IPv4:
+      } else {
+         assert(reply.addr.family == IPv4);
          if (IN_MULTICAST(htonl(reply.addr.ip.v4)))
             type = "multicast";
       }