Remove unused HAVE_SOCKADDR_SA_LEN ifdef'd code

dnsmasq is only built for Android on Linux.  Clean up a bit so we
can more easily read the code.

Also: a few whitespace fixes and assertion of HAVE_IPV6 code paths.

Test: as follows
    - built, flashed, booted
    - USB tethering works as expected
Bug: 38364896
Change-Id: I636ba74b83594f13a7a2e9836e8829e113ca88a0
diff --git a/src/config.h b/src/config.h
index 5a88c1d..1491f14 100644
--- a/src/config.h
+++ b/src/config.h
@@ -4,12 +4,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; version 2 dated June, 1991, or
    (at your option) version 3 dated 29 June, 2007.
- 
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-     
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
diff --git a/src/dhcp.c b/src/dhcp.c
index fa204a5..82075fd 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -69,9 +69,6 @@
   saddr.sin_family = AF_INET;
   saddr.sin_port = htons(daemon->dhcp_server_port);
   saddr.sin_addr.s_addr = INADDR_ANY;
-#ifdef HAVE_SOCKADDR_SA_LEN
-  saddr.sin_len = sizeof(struct sockaddr_in);
-#endif
 
   if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
     die(_("failed to bind DHCP server socket: %s"), NULL, EC_BADNET);
@@ -231,11 +228,7 @@
   
   /* packet buffer may have moved */
   mess = (struct dhcp_packet *)daemon->dhcp_packet.iov_base;
-  
-#ifdef HAVE_SOCKADDR_SA_LEN
-  dest.sin_len = sizeof(struct sockaddr_in);
-#endif
-     
+
   if (mess->giaddr.s_addr)
     {
       /* Send to BOOTP relay  */
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index cc3a6a4..947b481 100644
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -22,6 +22,10 @@
 #error Should not HAVE_BSD_NETWORK
 #endif
 
+#if defined(HAVE_SOCKADDR_SA_LEN)
+#error Should not HAVE_SOCKADDR_SA_LEN
+#endif
+
 #if defined(HAVE_SOLARIS_NETWORK)
 #error Should not HAVE_SOLARIS_NETWORK
 #endif
@@ -1149,10 +1153,7 @@
   saddr.sin_family = AF_INET;
   saddr.sin_port = 0;
   saddr.sin_addr = addr;
-#ifdef HAVE_SOCKADDR_SA_LEN
-  saddr.sin_len = sizeof(struct sockaddr_in);
-#endif
-  
+
   memset(&packet.icmp, 0, sizeof(packet.icmp));
   packet.icmp.icmp_type = ICMP_ECHO;
   packet.icmp.icmp_id = id;
diff --git a/src/log.c b/src/log.c
index 55bc9c8..5399251 100644
--- a/src/log.c
+++ b/src/log.c
@@ -208,10 +208,7 @@
 		 (ECONNRESET, EDESTADDRREQ are *BSD equivalents) */
 	      
 	      struct sockaddr_un logaddr;
-	      
-#ifdef HAVE_SOCKADDR_SA_LEN
-	      logaddr.sun_len = sizeof(logaddr) - sizeof(logaddr.sun_path) + strlen(_PATH_LOG) + 1; 
-#endif
+
 	      logaddr.sun_family = AF_UNIX;
 	      strncpy(logaddr.sun_path, _PATH_LOG, sizeof(logaddr.sun_path));
 	      
diff --git a/src/network.c b/src/network.c
index ea96793..40f0226 100644
--- a/src/network.c
+++ b/src/network.c
@@ -214,13 +214,10 @@
 {
   union mysockaddr addr;
   struct in_addr netmask; /* dummy */
-  
+
   netmask.s_addr = 0;
-  
+
   memset(&addr, 0, sizeof(addr));
-#ifdef HAVE_SOCKADDR_SA_LEN
-  addr.in6.sin6_len = sizeof(addr.in6);
-#endif
   addr.in6.sin6_family = AF_INET6;
   addr.in6.sin6_addr = *local;
   addr.in6.sin6_port = htons(daemon->port);
@@ -244,9 +241,6 @@
   union mysockaddr addr;
 
   memset(&addr, 0, sizeof(addr));
-#ifdef HAVE_SOCKADDR_SA_LEN
-  addr.in.sin_len = sizeof(addr.in);
-#endif
   addr.in.sin_family = AF_INET;
   addr.in.sin_addr = broadcast; /* warning */
   addr.in.sin_addr = local;
@@ -288,19 +282,16 @@
   addr.in6.sin6_family = AF_INET6;
   addr.in6.sin6_addr = in6addr_any;
   addr.in6.sin6_port = htons(port);
-#ifdef HAVE_SOCKADDR_SA_LEN
-  addr.in6.sin6_len = sizeof(addr.in6);
-#endif
 
   /* No error of the kernel doesn't support IPv6 */
   if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
     return (errno == EPROTONOSUPPORT ||
 	    errno == EAFNOSUPPORT ||
 	    errno == EINVAL);
-  
+
   if ((tcpfd = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
     return 0;
-      
+
   if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
       setsockopt(tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
       setsockopt(fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
@@ -340,9 +331,6 @@
   addr.in.sin_family = AF_INET;
   addr.in.sin_addr.s_addr = INADDR_ANY;
   addr.in.sin_port = htons(daemon->port);
-#ifdef HAVE_SOCKADDR_SA_LEN
-  addr.in.sin_len = sizeof(struct sockaddr_in);
-#endif
 
   if (daemon->port != 0)
     {
@@ -675,26 +663,15 @@
 	    
 	    if (daemon->min_port != 0)
 	      port = htons(daemon->min_port + (port % ((unsigned short)ports_avail)));
-	    
-	    if (family == AF_INET) 
-	      {
+
+	    if (family == AF_INET) {
 		addr.in.sin_addr.s_addr = INADDR_ANY;
 		addr.in.sin_port = port;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		addr.in.sin_len = sizeof(struct sockaddr_in);
-#endif
-	      }
-#ifdef HAVE_IPV6
-	    else
-	      {
-		addr.in6.sin6_addr = in6addr_any; 
+	    } else {
+		addr.in6.sin6_addr = in6addr_any;
 		addr.in6.sin6_port = port;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		addr.in6.sin6_len = sizeof(struct sockaddr_in6);
-#endif
-	      }
-#endif
-	    
+	    }
+
 	    if (bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == 0)
 	      return fd;
 	    
@@ -803,7 +780,7 @@
 void pre_allocate_sfds(void)
 {
   struct server *srv;
-  
+
   if (daemon->query_port != 0)
     {
       union  mysockaddr addr;
@@ -811,22 +788,16 @@
       addr.in.sin_family = AF_INET;
       addr.in.sin_addr.s_addr = INADDR_ANY;
       addr.in.sin_port = htons(daemon->query_port);
-#ifdef HAVE_SOCKADDR_SA_LEN
-      addr.in.sin_len = sizeof(struct sockaddr_in);
-#endif
       allocate_sfd(&addr, "", 0);
 #ifdef HAVE_IPV6
       memset(&addr, 0, sizeof(addr));
       addr.in6.sin6_family = AF_INET6;
       addr.in6.sin6_addr = in6addr_any;
       addr.in6.sin6_port = htons(daemon->query_port);
-#ifdef HAVE_SOCKADDR_SA_LEN
-      addr.in6.sin6_len = sizeof(struct sockaddr_in6);
-#endif
       allocate_sfd(&addr, "", 0);
 #endif
     }
-  
+
   for (srv = daemon->servers; srv; srv = srv->next)
     if (!(srv->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)) &&
 	!allocate_sfd(&srv->source_addr, srv->interface, srv->mark) &&
diff --git a/src/option.c b/src/option.c
index 627754f..09814d9 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1408,10 +1408,7 @@
 	    
 	    if (parse_addr(AF_INET, arg, &newlist->addr) == 0)
 	      {
-		newlist->addr.in.sin_port = htons(serv_port);	
-#ifdef HAVE_SOCKADDR_SA_LEN
-		newlist->source_addr.in.sin_len = newlist->addr.in.sin_len = sizeof(struct sockaddr_in);
-#endif
+		newlist->addr.in.sin_port = htons(serv_port);
 		if (source)
 		  {
 		    newlist->flags |= SERV_HAS_SOURCE;
diff --git a/src/util.c b/src/util.c
index e44b8fa..9d7a055 100644
--- a/src/util.c
+++ b/src/util.c
@@ -271,18 +271,11 @@
   return 0;
 }
 
-int sa_len(union mysockaddr *addr)
-{
-#ifdef HAVE_SOCKADDR_SA_LEN
-  return addr->sa.sa_len;
-#else
-#ifdef HAVE_IPV6
-  if (addr->sa.sa_family == AF_INET6)
-    return sizeof(addr->in6);
-  else
-#endif
-    return sizeof(addr->in); 
-#endif
+int sa_len(union mysockaddr *addr) {
+    if (addr->sa.sa_family == AF_INET6)
+        return sizeof(addr->in6);
+    else
+        return sizeof(addr->in);
 }
 
 /* don't use strcasecmp and friends here - they may be messed up by LOCALE */