diff Modules/socketmodule.c @ 27861:f8440bb8ede5 legacy-trunk

socket_inet_aton(): ip_addr was left undefined before use in the !HAVE_INET_ATON case. Repaired that, and tried to repair what looked like out-of-date comments.
author Tim Peters <tim.peters@gmail.com>
date Thu, 13 Feb 2003 03:13:40 +0000
parents 9453d8cdd01e
children eb2a984d3747
line wrap: on
line diff
--- a/Modules/socketmodule.c	Thu Feb 13 03:12:48 2003 +0000
+++ b/Modules/socketmodule.c	Thu Feb 13 03:13:40 2003 +0000
@@ -2710,16 +2710,19 @@
 #ifndef INADDR_NONE
 #define INADDR_NONE (-1)
 #endif
-
-	/* Have to use inet_addr() instead */
-	char *ip_addr;
 #ifdef HAVE_INET_ATON
 	struct in_addr buf;
-
-	if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) {
+#else
+	/* Have to use inet_addr() instead */
+	unsigned long packed_addr;
+#endif
+	char *ip_addr;
+
+	if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr))
 		return NULL;
-	}
-
+
+
+#ifdef HAVE_INET_ATON
 	if (inet_aton(ip_addr, &buf))
 		return PyString_FromStringAndSize((char *)(&buf),
 						  sizeof(buf));
@@ -2728,11 +2731,9 @@
 			"illegal IP address string passed to inet_aton");
 	return NULL;
 
-#else /* In case you don't have inet_aton() */
+#else /* ! HAVE_INET_ATON */
 	/* XXX Problem here: inet_aton('255.255.255.255') raises
 	   an exception while it should be a valid address. */
-	unsigned long packed_addr;
-
 	packed_addr = inet_addr(ip_addr);
 
 	if (packed_addr == INADDR_NONE) {	/* invalid address */
@@ -2740,7 +2741,6 @@
 			"illegal IP address string passed to inet_aton");
 		return NULL;
 	}
-
 	return PyString_FromStringAndSize((char *) &packed_addr,
 					  sizeof(packed_addr));
 #endif