[kaffe] CVS kaffe (dalibor): Fixed compiler warning on hpux

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Sun Jan 25 13:16:02 2004


PatchSet 4372 
Date: 2004/01/25 21:13:10
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Fixed compiler warning on hpux

2004-01-25  Dalibor Topic <robilad@kaffe.org>

        * libraries/clib/net/PlainDatagramSocketImpl.c,
        libraries/clib/net/PlainSocketImpl.c:
        Added comments.
        (ip62str): Only define if HAVE_STRUCT_SOCKADDR_IN6
        is defined, since it's only used in that case.

        Reported by: Riccardo Mottola <zuse@libero.it>

Members: 
	ChangeLog:1.1957->1.1958 
	libraries/clib/net/PlainDatagramSocketImpl.c:1.39->1.40 
	libraries/clib/net/PlainSocketImpl.c:1.38->1.39 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1957 kaffe/ChangeLog:1.1958
--- kaffe/ChangeLog:1.1957	Sun Jan 25 19:57:25 2004
+++ kaffe/ChangeLog	Sun Jan 25 21:13:10 2004
@@ -1,5 +1,15 @@
 2004-01-25  Dalibor Topic <robilad@kaffe.org>
 
+	* libraries/clib/net/PlainDatagramSocketImpl.c,
+	libraries/clib/net/PlainSocketImpl.c:
+	Added comments.
+	(ip62str): Only define if HAVE_STRUCT_SOCKADDR_IN6
+	is defined, since it's only used in that case.
+
+        Reported by: Riccardo Mottola <zuse@libero.it>
+
+2004-01-25  Dalibor Topic <robilad@kaffe.org>
+
 	* kaffe/kaffevm/external.c:
 	Include <stdarg.h> if it exists. Include <stdio.h> to fix
 	compiler warnings on HP-UX about missing vsnprintf prototype.
Index: kaffe/libraries/clib/net/PlainDatagramSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.39 kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.40
--- kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.39	Mon Jan 19 12:24:27 2004
+++ kaffe/libraries/clib/net/PlainDatagramSocketImpl.c	Sun Jan 25 21:13:11 2004
@@ -71,6 +71,7 @@
 	return addrbuf;
 }
 
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
 /* Generate a string for an inet6 addr (in host form). */
 static char *
 ip62str(struct in6_addr *addr) 
@@ -93,7 +94,9 @@
 	}
 	return addrbuf;
 }
-#endif /* KAFFE_VMDEBUG */
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
+#endif /* defined(KAFFE_VMDEBUG) && !defined(NDEBUG) */
+
 /*
  * Create a datagram socket.
  */
@@ -144,9 +147,11 @@
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(laddr)->addr) == 4) {
 		alen = sizeof(addr.addr4);
+
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
-#endif
+#endif /* defined(BSD44) */
+
 		addr.addr4.sin_family = AF_INET;
 		addr.addr4.sin_port = htons(port);
 		memcpy(&addr.addr4.sin_addr, unhand_byte_array(unhand(laddr)->addr),
@@ -156,12 +161,15 @@
 	dprintf("datagram_bind4(%p, %s, %d)\n", 
 		this, ip2str(addr.addr4.sin_addr.s_addr), port);
 )
+
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(laddr)->addr) == 16) {
 		alen = sizeof(addr.addr6);
+
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
-#endif
+#endif /* defined(BSD44) */
+
 		addr.addr6.sin6_family = AF_INET6;
 		addr.addr6.sin6_port = htons(port);
 		memcpy(&addr.addr6.sin6_addr, unhand_byte_array(unhand(laddr)->addr),
@@ -171,7 +179,8 @@
 	dprintf("datagram_bind6(%p, %s, %d)\n", 
 		this, ip62str(&addr.addr6.sin6_addr), port);
 )		
-#endif
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
+
 	} else {
 		SignalError("java.net.SocketException", "Unsupported address family");
 	}
@@ -223,9 +232,11 @@
         memset(&addr, 0, sizeof(addr));
         if (obj_length(unhand(unhand(pkt)->address)->addr) == 4) {
 	    alen = sizeof(addr.addr4);
+
 #if defined(BSD44)
 	    addr.addr4.sin_len = sizeof(addr.addr4);
-#endif
+#endif /* defined(BSD44) */
+
 	    addr.addr4.sin_family = AF_INET;
 	    addr.addr4.sin_port = htons(unhand(pkt)->port);
 	    memcpy(&addr.addr4.sin_addr.s_addr, unhand_byte_array(unhand(unhand(pkt)->address)->addr),
@@ -239,9 +250,11 @@
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(unhand(pkt)->address)->addr) == 16) {
 	    alen = sizeof(addr.addr6);
+
 #if defined(BSD44)
 	    addr.addr6.sin6_len = sizeof(addr.addr6);
-#endif
+#endif /* defined(BSD44) */
+
 	    addr.addr6.sin6_family = AF_INET6;
 	    addr.addr6.sin6_port = htons(unhand(pkt)->port);
 	    memcpy(&addr.addr6.sin6_addr, unhand_byte_array(unhand(unhand(pkt)->address)->addr),
@@ -252,7 +265,7 @@
 		ip62str(&addr.addr6.sin6_addr),
 		unhand(pkt)->port);
 )
-#endif
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
 
         } else {
 	    SignalError("java.net.SocketException", "Unsupported packet internet address");
@@ -288,10 +301,12 @@
 
 	if (saddr.addr4.sin_family == AF_INET) {
 	    memcpy(unhand_byte_array(unhand(addr)->addr), &saddr.addr4.sin_addr, sizeof(saddr.addr4.sin_addr));
+
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (saddr.addr6.sin6_family == AF_INET6) {
 	    memcpy(unhand_byte_array(unhand(addr)->addr), &saddr.addr6.sin6_addr, sizeof(saddr.addr6.sin6_addr));
-#endif
+#endif /*  defined(HAVE_STRUCT_SOCKADDR_IN6) */
+
 	} else {
 	    SignalError("java.net.SocketException", "Unsupported address family");
 	}
@@ -366,6 +381,7 @@
 		unhand(pkt)->address = (struct Hjava_net_InetAddress*)
 			execute_java_constructor("java/net/InetAddress", 0, 0, "([B)V",
 						 array_address);
+
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (addr.addr6.sin6_family == AF_INET6) {
 		array_address = (HArrayOfByte*)AllocArray(sizeof(addr.addr6.sin6_addr), TYPE_Byte);
@@ -374,7 +390,7 @@
 		unhand(pkt)->address = (struct Hjava_net_InetAddress*)
 			execute_java_constructor("java/net/Inet6Address", 0, 0, "([BLjava/lang/String;)V",
 						 array_address);
-#endif
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
 		
 	} else {
 		SignalError("java.net.SocketException", "Unsupported address family");
@@ -437,6 +453,7 @@
 
 	switch(opt) {
 	case java_net_SocketOptions_IP_MULTICAST_IF:
+
 #if defined(IP_MULTICAST_IF)
 		addrp = (struct Hjava_net_InetAddress*)arg;
 		{
@@ -455,10 +472,11 @@
 					    SYS_ERROR(r));
 			}
 		}
-#else
+#else /* !defined(IP_MULTICAST_IF) */
 			SignalError("java.net.SocketException",
 				    "IP_MULTICAST_IF is not supported");
-#endif
+#endif /* defined(IP_MULTICAST_IF) */
+
 		break;
 
 	case java_net_SocketOptions_SO_BINDADDR:
@@ -505,6 +523,7 @@
 		}
 		r = htonl(addr.sin_addr.s_addr);
 		break;
+
 #if defined(IP_MULTICAST_IF)
 	case java_net_SocketOptions_IP_MULTICAST_IF:
 		r = KGETSOCKOPT(unhand(unhand(this)->fd)->nativeFd,
@@ -515,7 +534,8 @@
 		}
 		r = ntohl(ia.s_addr);
 		break;
-#endif
+#endif /* defined(IP_MULTICAST_IF) */
+
 	case java_net_SocketOptions_SO_TIMEOUT: /* JAVA takes care */
 	default:
 		SignalError("java.net.SocketException",
@@ -530,6 +550,7 @@
 void
 gnu_java_net_PlainDatagramSocketImpl_join(struct Hgnu_java_net_PlainDatagramSocketImpl* this, struct Hjava_net_InetAddress* laddr)
 {
+
 #if defined(IP_ADD_MEMBERSHIP)
 	int r;
 	struct ip_mreq ipm;
@@ -554,10 +575,11 @@
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
-#else
+#else /* !defined(IP_ADD_MEMBERSHIP) */
 	SignalError("java.net.SocketException",
 		"IP_ADD_MEMBERSHIP not supported");
-#endif
+#endif /* defined(IP_ADD_MEMBERSHIP) */
+
 }
 
 /*
@@ -566,6 +588,7 @@
 void
 gnu_java_net_PlainDatagramSocketImpl_leave(struct Hgnu_java_net_PlainDatagramSocketImpl* this, struct Hjava_net_InetAddress* laddr)
 {
+
 #if defined(IP_DROP_MEMBERSHIP)
 	int r;
 	struct ip_mreq ipm;
@@ -590,10 +613,11 @@
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
-#else
+#else /* !defined(IP_DROP_MEMBERSHIP) */
 	SignalError("java.net.SocketException",
 		"IP_DROP_MEMBERSHIP not supported");
-#endif
+#endif /* defined(IP_DROP_MEMBERSHIP) */
+
 }
 
 /*
@@ -602,6 +626,7 @@
 void
 gnu_java_net_PlainDatagramSocketImpl_joinGroup(struct Hgnu_java_net_PlainDatagramSocketImpl* this, struct Hjava_net_SocketAddress *jsa, struct Hjava_net_NetworkInterface *jni)
 {
+
 #if defined(IP_ADD_MEMBERSHIP)
 	struct Hjava_net_InetSocketAddress *jisa;
 	struct ip_mreq ipm;
@@ -642,10 +667,11 @@
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
-#else
+#else /* !defined(IP_ADD_MEMBERSHIP) */
 	SignalError("java.net.SocketException",
 		"IP_ADD_MEMBERSHIP not supported");
-#endif
+#endif /* defined(IP_ADD_MEMBERSHIP) */
+
 }
 
 /*
@@ -654,6 +680,7 @@
 void
 gnu_java_net_PlainDatagramSocketImpl_leaveGroup(struct Hgnu_java_net_PlainDatagramSocketImpl* this, struct Hjava_net_SocketAddress *jsa, struct Hjava_net_NetworkInterface *jni)
 {
+
 #if defined(IP_ADD_MEMBERSHIP)
 	struct Hjava_net_InetSocketAddress *jisa;
 	struct ip_mreq ipm;
@@ -689,10 +716,11 @@
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
-#else
+#else /* !defined(IP_ADD_MEMBERSHIP) */
 	SignalError("java.net.SocketException",
 		"IP_ADD_MEMBERSHIP not supported");
-#endif
+#endif /* defined(IP_ADD_MEMBERSHIP) */
+
 }
 
 /*
@@ -701,6 +729,7 @@
 void
 gnu_java_net_PlainDatagramSocketImpl_setTTL(struct Hgnu_java_net_PlainDatagramSocketImpl* this, jbool ttl)
 {
+
 #if defined(IP_MULTICAST_TTL)
 	int r;
 	unsigned char v = (unsigned char)ttl;
@@ -710,10 +739,11 @@
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
-#else
+#else /* !defined(IP_MULTICAST_TTL) */
 	SignalError("java.net.SocketException",
 		"IP_MULTICAST_TTL not supported");
-#endif
+#endif /* defined(IP_MULTICAST_TTL) */
+
 }
 
 /*
@@ -722,6 +752,7 @@
 jbyte
 gnu_java_net_PlainDatagramSocketImpl_getTTL(struct Hgnu_java_net_PlainDatagramSocketImpl* this)
 {
+
 #if defined(IP_MULTICAST_TTL)
 	unsigned char v;
 	int s;
@@ -733,8 +764,9 @@
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
 	return (jbyte)v;
-#else
+#else /* !defined(IP_MULTICAST_TTL) */
 	SignalError("java.net.SocketException",
 		"IP_MULTICAST_TTL not supported");
-#endif
+#endif /* defined(IP_MULTICAST_TTL) */
+
 }
Index: kaffe/libraries/clib/net/PlainSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainSocketImpl.c:1.38 kaffe/libraries/clib/net/PlainSocketImpl.c:1.39
--- kaffe/libraries/clib/net/PlainSocketImpl.c:1.38	Wed Jan  7 16:11:39 2004
+++ kaffe/libraries/clib/net/PlainSocketImpl.c	Sun Jan 25 21:13:11 2004
@@ -33,7 +33,7 @@
 
 #if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
 #include "getaddrinfo.h"
-#endif
+#endif /* !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) */
 
 /*
  * Supported socket options
@@ -43,21 +43,26 @@
 	  int level;
 	  int copt;
   } socketOptions[] = {
-#ifdef SO_SNDBUF
+
+#if defined(SO_SNDBUF)
     { java_net_SocketOptions_SO_SNDBUF,		SOL_SOCKET,	SO_SNDBUF },
-#endif
-#ifdef SO_RCVBUF
+#endif /* defined(SO_SNDBUF) */
+
+#if defined(SO_RCVBUF)
     { java_net_SocketOptions_SO_RCVBUF,		SOL_SOCKET,	SO_RCVBUF },
-#endif
-#ifdef SO_LINGER
+#endif /* defined(SO_RCVBUF) */
+
+#if defined(SO_LINGER)
     { java_net_SocketOptions_SO_LINGER,		SOL_SOCKET,	SO_LINGER },
-#endif
-#ifdef SO_REUSEADDR
+#endif /* defined(SO_LINGER) */
+
+#if defined(SO_REUSEADDR)
     { java_net_SocketOptions_SO_REUSEADDR,	SOL_SOCKET,	SO_REUSEADDR },
-#endif
-#ifdef TCP_NODELAY
+#endif /* defined(SO_REUSEADDR) */
+
+#if defined(TCP_NODELAY)
     { java_net_SocketOptions_TCP_NODELAY,	IPPROTO_TCP,	TCP_NODELAY },
-#endif
+#endif /* defined(TCP_NODELAY) */
   };
 
 #if defined(KAFFE_VMDEBUG) && !defined(NDEBUG)
@@ -68,21 +73,27 @@
 	  int opt;
 	  char *name;
   } optionNames[] = {
-#ifdef SO_SNDBUF
+
+#if defined(SO_SNDBUF)
     { java_net_SocketOptions_SO_SNDBUF, "SO_SNDBUF" },
-#endif
-#ifdef SO_RCVBUF
+#endif /* defined(SO_SNDBUF) */
+
+#if defined(SO_RCVBUF)
     { java_net_SocketOptions_SO_RCVBUF, "SO_RCVBUF" },
-#endif
-#ifdef SO_LINGER
+#endif /* defined(SO_RCVBUF) */
+
+#if defined(SO_LINGER)
     { java_net_SocketOptions_SO_LINGER, "SO_LINGER" },
-#endif
-#ifdef SO_REUSEADDR
+#endif /* defined(SO_LINGER) */
+
+#if defined(SO_REUSEADDR)
     { java_net_SocketOptions_SO_REUSEADDR, "SO_REUSEADDR" },
-#endif
-#ifdef TCP_NODELAY
+#endif /* defined(SO_REUSEADDR) */
+
+#if defined(TCP_NODELAY)
     { java_net_SocketOptions_TCP_NODELAY, "TCP_NODELAY" },
-#endif
+#endif /* defined(TCP_NODELAY) */
+
     { java_net_SocketOptions_SO_BINDADDR, "SO_BINDADDR" },
     { java_net_SocketOptions_SO_TIMEOUT, "SO_TIMEOUT" },
     { java_net_SocketOptions_IP_MULTICAST_IF, "IP_MULTICAST_IF" }
@@ -102,6 +113,7 @@
 	return addrbuf;
 }
 
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
 /* Generate a string for an inet6 addr (in host form). */
 static char *
 ip62str(struct in6_addr *addr) 
@@ -124,6 +136,7 @@
 	}
 	return addrbuf;
 }
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
 #endif /* defined(KAFFE_VMDEBUG) && !defined(NDEBUG) */
 
 /*
@@ -178,24 +191,30 @@
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(daddr)->addr) == 4) {
 	        alen = sizeof(addr.addr4); 
+
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
-#endif
+#endif /* defined(BSD44) */
+
 		addr.addr4.sin_family = AF_INET;
 		addr.addr4.sin_port = htons(dport);
 		memcpy(&addr.addr4.sin_addr, 
 		       unhand_byte_array(unhand(daddr)->addr), sizeof(addr.addr4.sin_addr));
+
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(daddr)->addr) == 16) {
 	        alen = sizeof(addr.addr6);
+
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
-#endif
+#endif /*  defined(BSD44) */
+
 		addr.addr6.sin6_family = AF_INET6;
 		addr.addr6.sin6_port = htons(dport);
 		memcpy(&addr.addr6.sin6_addr, 
 		       unhand_byte_array(unhand(daddr)->addr), sizeof(addr.addr6.sin6_addr));
-#endif
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
+
 	} else {
 		SignalError("java.net.SocketException", "Unsupported address family");
 	}
@@ -264,9 +283,11 @@
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(laddr)->addr) == 4) {
 	        alen = sizeof(addr.addr4);
+
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
-#endif
+#endif /*  defined(BSD44) */
+
 		addr.addr4.sin_family = AF_INET;
 		addr.addr4.sin_port = htons(lport);
 		memcpy(&addr.addr4.sin_addr, 
@@ -276,12 +297,15 @@
 		    dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
 			    ip2str(addr.addr4.sin_addr.s_addr), lport);
 		    );
+
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(laddr)->addr) == 16) {
 	        alen = sizeof(addr.addr6);
+
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
-#endif
+#endif /* defined(BSD44) */
+
 		addr.addr6.sin6_family = AF_INET6;
 		addr.addr6.sin6_port = htons(lport);
 		memcpy(&addr.addr6.sin6_addr, 
@@ -291,7 +315,8 @@
 		    dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
 			    ip62str(&addr.addr6.sin6_addr), lport);
 		    );
-#endif
+#endif /* defined(HAVE_STRUCT_SOCKADDR_IN6) */
+
 	} else {
 		SignalError("java.net.SocketException", "Unsupported address family");
 	}
@@ -359,9 +384,11 @@
 	
 	remote_addr = NULL;
 	memset(&addr, 0, sizeof(addr));
+
 #if defined(BSD44)
 	addr.sin_len = sizeof(addr);
-#endif
+#endif /* defined(BSD44) */
+
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons(unhand(sock)->localport);
 	/* I guess the next line is too much as unhand(sock)->address is not supposed
@@ -415,7 +442,8 @@
 			       &in6->sin6_addr,
 			       sizeof(in6->sin6_addr));
 			break;
-#endif
+#endif /* defined(AF_INET6) */
+
 		default:
 			/* Ignore */
 			break;
@@ -444,10 +472,11 @@
 	int r;
 	jint len;
 	int fd;
+
 #if (!(defined(HAVE_IOCTL) && defined(FIONREAD)) && !defined(__WIN32__))
 	static struct timeval tm = { 0, 0 };
 	fd_set rd;
-#endif
+#endif /* (!(defined(HAVE_IOCTL) && defined(FIONREAD)) && !defined(__WIN32__)) */
 
 	DBG(NATIVENET,
 	    dprintf("socketAvailable(%p)\n", this);
@@ -460,10 +489,10 @@
 	if (r < 0) {
 		SignalError("java.io.IOException", SYS_ERROR(errno));
 	}
-#else
+#else /* !(defined(HAVE_IOCTL) && defined(FIONREAD)) */
 #if defined(__WIN32__) /* Windows hack - XXX */
 	len = 0;
-#else
+#else /* !defined(__WIN32__) */
 	/* This uses KSELECT() to work out if we can read - but what
 	 * happens at the end of file?
 	 */