Patch: FYI: Zero out SockAddr in bind()

Mohan Embar gnustuff@thisiscool.com
Mon Jul 24 00:38:00 GMT 2006


Hi All,

Based on this preapproval:

http://gcc.gnu.org/ml/java/2006-07/msg00072.html

I checked the following patch in. It passed
a "make check" in libjava with no differences
on i686-pc-linux-gnu.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

2006-07-21  Mohan Embar  <gnustuff@thisiscool.com>

	* gnu/java/net/natPlainSocketImplPosix.cc (bind): Clear
	SockAddr before using - needed for OS X/PPC.

Index: gnu/java/net/natPlainSocketImplPosix.cc
===================================================================
--- gnu/java/net/natPlainSocketImplPosix.cc	(revision 115645)
+++ gnu/java/net/natPlainSocketImplPosix.cc	(working copy)
@@ -89,6 +89,11 @@
   int len = haddress->length;
   int i = 1;
 
+  // The following is needed for OS X/PPC, otherwise bind() fails with an
+  // error. I found the issue and following fix on some mailing list, but
+  // no explanation was given as to why this solved the problem.
+  memset (&u, 0, sizeof (u));
+
   if (len == 4)
     {
       u.address.sin_family = AF_INET;






More information about the Java-patches mailing list