]> granicus.if.org Git - libevent/commitdiff
Improve readability of evutil_unparse_protoname()
authorJardel Weyrich <jweyrich@users.sourceforge.net>
Mon, 28 Dec 2009 21:03:47 +0000 (16:03 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 28 Dec 2009 21:03:47 +0000 (16:03 -0500)
evutil.c

index 2e58a310f8e86c865c298b157fda6b549911eed6..800e40b2db0c1d3aea0a11a64bf5ce7750757819 100644 (file)
--- a/evutil.c
+++ b/evutil.c
@@ -535,24 +535,27 @@ evutil_parse_servname(const char *servname, const char *protocol,
 static const char *
 evutil_unparse_protoname(int proto)
 {
-       if (proto == 0)
+       switch (proto) {
+       case 0:
                return NULL;
-       else if (proto == IPPROTO_TCP)
+       case IPPROTO_TCP:
                return "tcp";
-       else if (proto == IPPROTO_UDP)
+       case IPPROTO_UDP:
                return "udp";
 #ifdef IPPROTO_SCTP
-       else if (proto == IPPROTO_SCTP)
+       case IPPROTO_SCTP:
                return "sctp";
 #endif
+       default:
 #ifdef _EVENT_HAVE_GETPROTOBYNUMBER
-       {
-               struct protoent *ent = getprotobynumber(proto);
-               if (ent)
-                       return ent->p_name;
-       }
+               {
+                       struct protoent *ent = getprotobynumber(proto);
+                       if (ent)
+                               return ent->p_name;
+               }
 #endif
-       return NULL;
+               return NULL;
+       }
 }
 
 static void