From 7f6b5faf77626ec1de9e48d86a6fc24f6f10591f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 17:52:30 +0100 Subject: [PATCH 1/4] Correct return LDAPerror_TypeError() LDAPerror_TypeError() returns (PyObject *)NULL. Some functions don't return a PyObject* so technically it's wrong to return (PyObject *)NULL. Return NULL instead. Signed-off-by: Christian Heimes --- Modules/LDAPObject.c | 9 ++++++--- Modules/ldapcontrol.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/LDAPObject.c b/Modules/LDAPObject.c index 4800724..cff9337 100644 --- a/Modules/LDAPObject.c +++ b/Modules/LDAPObject.c @@ -112,7 +112,8 @@ Tuple_to_LDAPMod( PyObject* tup, int no_op ) Py_ssize_t i, len, nstrs; if (!PyTuple_Check(tup)) { - return LDAPerror_TypeError("expected a tuple", tup); + LDAPerror_TypeError("expected a tuple", tup); + return NULL; } if (no_op) { @@ -209,13 +210,15 @@ List_to_LDAPMods( PyObject *list, int no_op ) { PyObject *item; if (!PySequence_Check(list)) { - return LDAPerror_TypeError("expected list of tuples", list); + LDAPerror_TypeError("expected list of tuples", list); + return NULL; } len = PySequence_Length(list); if (len < 0) { - return LDAPerror_TypeError("expected list of tuples", list); + LDAPerror_TypeError("expected list of tuples", list); + return NULL; } lms = PyMem_NEW(LDAPMod *, len + 1); diff --git a/Modules/ldapcontrol.c b/Modules/ldapcontrol.c index 3f5b2c4..b76d33c 100644 --- a/Modules/ldapcontrol.c +++ b/Modules/ldapcontrol.c @@ -71,7 +71,8 @@ Tuple_to_LDAPControl( PyObject* tup ) Py_ssize_t len; if (!PyTuple_Check(tup)) { - return LDAPerror_TypeError("expected a tuple", tup); + LDAPerror_TypeError("expected a tuple", tup); + return NULL; } if (!PyArg_ParseTuple( tup, "sbO", &oid, &iscritical, &bytes )) From 67c69e72a347c69f599f504b18e47248109bca4f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 17:56:10 +0100 Subject: [PATCH 2/4] Fix implicit declaration of error functions ldapcontrol.c was missing include of constants.h that defines LDAPerr() and LDAPerror(). Signed-off-by: Christian Heimes --- Modules/ldapcontrol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/ldapcontrol.c b/Modules/ldapcontrol.c index b76d33c..7d8fbe3 100644 --- a/Modules/ldapcontrol.c +++ b/Modules/ldapcontrol.c @@ -4,6 +4,7 @@ #include "LDAPObject.h" #include "ldapcontrol.h" #include "berval.h" +#include "constants.h" #include "lber.h" From bdbe614a12fed05166b05d055b0e8d49d42c37b8 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 17:57:02 +0100 Subject: [PATCH 3/4] Travis: Turn compiler warnings into fatal errors Signed-off-by: Christian Heimes --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 581013c..5dda5e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,14 @@ matrix: - python: 3.6 env: TOXENV=doc +env: + global: + # -Wno-int-in-bool-context: don't complain about PyMem_MALLOC() + # -Werror: turn all warnings into fatal errors + - CFLAGS="-Wno-int-in-bool-context -Werror" + # pass CFLAGS and WITH_GCOV to tox tasks + - TOX_TESTENV_PASSENV="CFLAGS WITH_GCOV" + install: - pip install "pip>=7.1.0" - pip install tox-travis tox codecov coverage From 5b2d2f9de64c28cb7b73ca95f45648405bc5a97b Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 18:22:03 +0100 Subject: [PATCH 4/4] Make init_ldap_module definition a strict prototype Signed-off-by: Christian Heimes --- Modules/ldapmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ldapmodule.c b/Modules/ldapmodule.c index bd54313..4c2c4ec 100644 --- a/Modules/ldapmodule.c +++ b/Modules/ldapmodule.c @@ -37,7 +37,7 @@ static PyMethodDef methods[] = { /* Common initialization code */ -PyObject* init_ldap_module() +PyObject* init_ldap_module(void) { PyObject *m, *d;