]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/librpc: squash 'cast between incompatible function types' warning
authorNoel Power <noel.power@suse.com>
Thu, 2 May 2019 18:35:56 +0000 (19:35 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 16 May 2019 17:55:17 +0000 (17:55 +0000)
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>
source4/librpc/ndr/py_security.c
source4/librpc/rpc/pyrpc.c
source4/librpc/rpc/pyrpc_util.c

index f6aabc740ce94a73ef9607617fcb34c0d41aecdb..ecac43bb258e6c79b13cb2b237e86c5975a819da 100644 (file)
@@ -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;
index 0713920e3a536a5ce62b75e4e682dcb1c082af9f..09f3e32074bb71ded79089dcf6076ebbbc5775e9 100644 (file)
@@ -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 },
 };
 
index 8015e7099648843e45db60bcf4950fa5f3c18bda..29e501cdfefc06d7570e4639f226c97f0e4a8a4e 100644 (file)
@@ -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]));