pysocketwrapper: fix behaviour to be consistent with 'socket.getsockopt'
authorJelmer Vernooij <jelmer@samba.org>
Sun, 5 Feb 2012 15:42:41 +0000 (16:42 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 7 Feb 2012 00:11:07 +0000 (01:11 +0100)
socklen_t is unsigned

lib/socket_wrapper/py_socket_wrapper.c

index 5c8af03124a0aed3c28e22a51e98fec4354d8f27..f5742d3dd1011aedc29667f7b40b5b75ad7cbd8f 100644 (file)
@@ -374,7 +374,7 @@ static PyObject *py_socket_getsockopt(pytalloc_Object *self, PyObject *args)
 {
        int level, optname;
        int *sock;
-       socklen_t optlen = -1, newlen;
+       socklen_t optlen = 0, newlen;
        int optval;
        bool is_integer = false;
        char *buffer;
@@ -385,7 +385,7 @@ static PyObject *py_socket_getsockopt(pytalloc_Object *self, PyObject *args)
                return NULL;
        }
 
-       if (optlen < 0) {
+       if (optlen == 0) {
                optlen = sizeof(int);
                is_integer = true;
        }