From 7394f6d1671e30d1953b200f8e60ec88fc39d130 Mon Sep 17 00:00:00 2001
From: Ralph Castain <rhc@open-mpi.org>
Date: Mon, 25 Oct 2010 13:56:23 +0000
Subject: [PATCH] Silence warnings about IPV6 sa_family not known when ipv6
 support is not enabled in configure

This commit was SVN r23928.
---
 opal/util/net.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/opal/util/net.c b/opal/util/net.c
index 64de72bb13..0f181dc567 100644
--- a/opal/util/net.c
+++ b/opal/util/net.c
@@ -213,17 +213,17 @@ opal_net_islocalhost(const struct sockaddr *addr)
             return false;
         }
         break;
-#if OPAL_WANT_IPV6
     case AF_INET6:
+#if OPAL_WANT_IPV6
         {
             const struct sockaddr_in6 *inaddr = (struct sockaddr_in6*) addr;
             if (IN6_IS_ADDR_LOOPBACK (&inaddr->sin6_addr)) {
                return true; /* Bug, FIXME: check for 127.0.0.1/8 */
             }
-            return false;
         }
-        break;
 #endif
+        return false;
+        break;
 
     default:
         opal_output(0, "unhandled sa_family %d passed to opal_net_islocalhost",
@@ -257,8 +257,8 @@ opal_net_samenetwork(const struct sockaddr *addr1,
             return false;
         }
         break;
-#if OPAL_WANT_IPV6
     case AF_INET6:
+#if OPAL_WANT_IPV6
         {
             const struct sockaddr_in6 *inaddr1 = (struct sockaddr_in6*) addr1;
             const struct sockaddr_in6 *inaddr2 = (struct sockaddr_in6*) addr2;
@@ -278,10 +278,10 @@ opal_net_samenetwork(const struct sockaddr *addr1,
                     return true;
                 }
             }
-            return false;
         }
-        break;
 #endif
+        return false;
+        break;
     default:
         opal_output(0, "unhandled sa_family %d passed to opal_samenetwork",
                     addr1->sa_family);
@@ -298,10 +298,9 @@ bool
 opal_net_addr_isipv4public(const struct sockaddr *addr)
 {
     switch (addr->sa_family) {
-#if OPAL_WANT_IPV6
         case AF_INET6:
             return false;
-#endif
+
         case AF_INET:
             {
                 const struct sockaddr_in *inaddr = (struct sockaddr_in*) addr;
@@ -348,6 +347,7 @@ opal_net_get_hostname(const struct sockaddr *addr)
         addrlen = sizeof (struct sockaddr_in);
         break;
     case AF_INET6:
+#if OPAL_WANT_IPV6
 #if defined( __NetBSD__)         
         /* hotfix for netbsd: on my netbsd machine, getnameinfo
            returns an unkown error code. */
@@ -360,7 +360,11 @@ opal_net_get_hostname(const struct sockaddr *addr)
         return name;
 #else
         addrlen = sizeof (struct sockaddr_in6);
-#endif
+#endif  /* NetBSD */
+#else  /* OPAL_WANT_IPV6 */
+        free(name);
+        return NULL;
+#endif /* OPAL_WANT_IPV6 */
         break;
     default:
         free(name);
@@ -392,11 +396,13 @@ opal_net_get_port(const struct sockaddr *addr)
     case AF_INET:
         return ntohs(((struct sockaddr_in*) addr)->sin_port);
         break;
-#if OPAL_WANT_IPV6
     case AF_INET6:
+#if OPAL_WANT_IPV6
         return ntohs(((struct sockaddr_in6*) addr)->sin6_port);
-        break;
+#else
+        return -1;
 #endif
+        break;
     }
 
     return -1;