diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-13 03:13:40 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-13 03:13:40 (GMT) |
commit | 1df9fdd4d5ba2c1a0c4731dada51780e5b5968a7 (patch) | |
tree | 900d1010f58468a6ec7ebad37a8d8bbc89e7b06d /Modules/socketmodule.c | |
parent | 12d31e2e9d507d3999b3240c99862244efb1eb47 (diff) | |
download | cpython-1df9fdd4d5ba2c1a0c4731dada51780e5b5968a7.zip cpython-1df9fdd4d5ba2c1a0c4731dada51780e5b5968a7.tar.gz cpython-1df9fdd4d5ba2c1a0c4731dada51780e5b5968a7.tar.bz2 |
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.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index f7bbeae..1b3321f 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2710,16 +2710,19 @@ socket_inet_aton(PyObject *self, PyObject *args) #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; +#else + /* Have to use inet_addr() instead */ + unsigned long packed_addr; +#endif + char *ip_addr; - if (!PyArg_ParseTuple(args, "s:inet_aton", &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 @@ socket_inet_aton(PyObject *self, PyObject *args) "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 @@ socket_inet_aton(PyObject *self, PyObject *args) "illegal IP address string passed to inet_aton"); return NULL; } - return PyString_FromStringAndSize((char *) &packed_addr, sizeof(packed_addr)); #endif |