1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

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>
This commit is contained in:
Noel Power 2019-05-02 19:35:56 +01:00 committed by Andreas Schneider
parent 0830485d1c
commit cc60866990
3 changed files with 18 additions and 7 deletions

View 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;

View 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 },
};

View 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]));