summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2019-05-02 19:35:56 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-05-16 17:55:17 +0000
commitcc60866990212236c4184dc1dc8ce3194a7e1869 (patch)
tree27bf2f3cb61f6c40e9d309100513bdf08ca8d22a
parent0830485d1cddd8567e420e80b60edcf80d26ab24 (diff)
downloadsamba-cc60866990212236c4184dc1dc8ce3194a7e1869.tar.gz
s4/librpc: squash 'cast between incompatible function types' warning
Where possible make PyCFunction definition signature match. Sometimes this is not possible (e.g. when the c-function is associated with a python method definition with 'METH_VARARGS|METH_KEYWORDS' in this case we use the PY_DISCARD_FUNC_SIG macro. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source4/librpc/ndr/py_security.c15
-rw-r--r--source4/librpc/rpc/pyrpc.c6
-rw-r--r--source4/librpc/rpc/pyrpc_util.c4
3 files changed, 18 insertions, 7 deletions
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index f6aabc740ce..ecac43bb258 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -343,28 +343,32 @@ static PyObject *py_token_has_sid(PyObject *self, PyObject *args)
return PyBool_FromLong(security_token_has_sid(token, sid));
}
-static PyObject *py_token_is_anonymous(PyObject *self)
+static PyObject *py_token_is_anonymous(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_is_anonymous(token));
}
-static PyObject *py_token_is_system(PyObject *self)
+static PyObject *py_token_is_system(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_is_system(token));
}
-static PyObject *py_token_has_builtin_administrators(PyObject *self)
+static PyObject *py_token_has_builtin_administrators(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_has_builtin_administrators(token));
}
-static PyObject *py_token_has_nt_authenticated_users(PyObject *self)
+static PyObject *py_token_has_nt_authenticated_users(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct security_token *token = pytalloc_get_ptr(self);
@@ -447,7 +451,8 @@ static PyObject *py_privilege_id(PyObject *self, PyObject *args)
return PyInt_FromLong(sec_privilege_id(name));
}
-static PyObject *py_random_sid(PyObject *self)
+static PyObject *py_random_sid(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct dom_sid *sid;
PyObject *ret;
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
index 0713920e3a5..09f3e32074b 100644
--- a/source4/librpc/rpc/pyrpc.c
+++ b/source4/librpc/rpc/pyrpc.c
@@ -20,6 +20,7 @@
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
+#include "python/modules.h"
#include <structmember.h>
#include "librpc/rpc/pyrpc.h"
#include "lib/events/events.h"
@@ -293,7 +294,10 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar
}
static PyMethodDef dcerpc_interface_methods[] = {
- { "request", (PyCFunction)py_iface_request, METH_VARARGS|METH_KEYWORDS, "S.request(opnum, data, object=None) -> data\nMake a raw request" },
+ { "request", PY_DISCARD_FUNC_SIG(PyCFunction, py_iface_request),
+ METH_VARARGS|METH_KEYWORDS,
+ "S.request(opnum, data, object=None) -> data\n"
+ "Make a raw request" },
{ NULL, NULL, 0, NULL },
};
diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c
index 8015e709964..29e501cdfef 100644
--- a/source4/librpc/rpc/pyrpc_util.c
+++ b/source4/librpc/rpc/pyrpc_util.c
@@ -23,6 +23,7 @@
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
+#include "python/modules.h"
#include "librpc/rpc/pyrpc_util.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/pyrpc.h"
@@ -324,7 +325,8 @@ bool PyInterface_AddNdrRpcMethods(PyTypeObject *ifacetype, const struct PyNdrRpc
}
wb->name = discard_const_p(char, mds[i].name);
wb->flags = PyWrapperFlag_KEYWORDS;
- wb->wrapper = (wrapperfunc)py_dcerpc_call_wrapper;
+ wb->wrapper = PY_DISCARD_FUNC_SIG(wrapperfunc,
+ py_dcerpc_call_wrapper);
wb->doc = discard_const_p(char, mds[i].doc);
ret = PyDescr_NewWrapper(ifacetype, wb, discard_const_p(void, &mds[i]));