diff options
author | Noel Power <noel.power@suse.com> | 2019-05-02 19:47:29 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-05-16 17:55:17 +0000 |
commit | cbdd3d0c26c9cefd968a2adaf9892c5c858bf597 (patch) | |
tree | ce2f3c7d6a024b80f2c5981707371123c6d12c81 | |
parent | a7d75a1c57befee4a178b7061ea218e353a72195 (diff) | |
download | samba-cbdd3d0c26c9cefd968a2adaf9892c5c858bf597.tar.gz |
squash 'cast between incompatible function types' warning
To avoid warning above produced by using
-Wcast-function-type we;
+ ensure PyCFunctions of type METH_NOARGS defined dummy arg
+ ensure PyCFunctions of type METH_KEYWORDS use PY_DISCARD_FUNC_SIG
macro
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r-- | auth/credentials/pycredentials.c | 4 | ||||
-rw-r--r-- | libcli/nbt/pynbt.c | 16 | ||||
-rw-r--r-- | libcli/security/pysecurity.c | 5 | ||||
-rw-r--r-- | libgpo/pygpo.c | 13 | ||||
-rw-r--r-- | python/pyglue.c | 12 |
5 files changed, 35 insertions, 15 deletions
diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index 1b86e001557..966c625a10e 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -19,6 +19,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include "pycredentials.h" #include "param/param.h" #include "lib/cmdline/credentials.h" @@ -760,7 +761,8 @@ static PyMethodDef py_creds_methods[] = { }, { .ml_name = "get_ntlm_response", - .ml_meth = (PyCFunction)py_creds_get_ntlm_response, + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_creds_get_ntlm_response), .ml_flags = METH_VARARGS | METH_KEYWORDS, .ml_doc = "S.get_ntlm_response" "(flags, challenge[, target_info]) -> " diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c index ccd7a039248..2ae3ecfe8a7 100644 --- a/libcli/nbt/pynbt.c +++ b/libcli/nbt/pynbt.c @@ -389,17 +389,23 @@ static PyObject *py_nbt_name_release(PyObject *self, PyObject *args, PyObject *k } static PyMethodDef py_nbt_methods[] = { - { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS, + { "query_name", PY_DISCARD_FUNC_SIG(PyCFunction, py_nbt_name_query), + METH_VARARGS|METH_KEYWORDS, "S.query_name(name, dest, broadcast=True, wins=False, timeout=0, retries=3) -> (reply_from, name, reply_addr)\n" "Query for a NetBIOS name" }, - { "register_name", (PyCFunction)py_nbt_name_register, METH_VARARGS|METH_KEYWORDS, + { "register_name", PY_DISCARD_FUNC_SIG(PyCFunction, + py_nbt_name_register), + METH_VARARGS|METH_KEYWORDS, "S.register_name(name, address, dest, register_demand=True, broadcast=True, multi_homed=True, ttl=0, timeout=0, retries=0) -> (reply_from, name, reply_addr, rcode)\n" "Register a new name" }, - { "release_name", (PyCFunction)py_nbt_name_release, METH_VARARGS|METH_KEYWORDS, "S.release_name(name, address, dest, nb_flags=0, broadcast=true, timeout=0, retries=3) -> (reply_from, name, reply_addr, rcode)\n" + { "release_name", PY_DISCARD_FUNC_SIG(PyCFunction, py_nbt_name_release), + METH_VARARGS|METH_KEYWORDS, "S.release_name(name, address, dest, nb_flags=0, broadcast=true, timeout=0, retries=3) -> (reply_from, name, reply_addr, rcode)\n" "release a previously registered name" }, - { "refresh_name", (PyCFunction)py_nbt_name_refresh, METH_VARARGS|METH_KEYWORDS, "S.refresh_name(name, address, dest, nb_flags=0, broadcast=True, ttl=0, timeout=0, retries=0) -> (reply_from, name, reply_addr, rcode)\n" + { "refresh_name", PY_DISCARD_FUNC_SIG(PyCFunction, py_nbt_name_refresh), + METH_VARARGS|METH_KEYWORDS, "S.refresh_name(name, address, dest, nb_flags=0, broadcast=True, ttl=0, timeout=0, retries=0) -> (reply_from, name, reply_addr, rcode)\n" "release a previously registered name" }, - { "name_status", (PyCFunction)py_nbt_name_status, METH_VARARGS|METH_KEYWORDS, + { "name_status", PY_DISCARD_FUNC_SIG(PyCFunction, py_nbt_name_status), + METH_VARARGS|METH_KEYWORDS, "S.name_status(name, dest, timeout=0, retries=0) -> (reply_from, name, status)\n" "Find the status of a name" }, diff --git a/libcli/security/pysecurity.c b/libcli/security/pysecurity.c index 72058424d99..86b2cc893aa 100644 --- a/libcli/security/pysecurity.c +++ b/libcli/security/pysecurity.c @@ -20,6 +20,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include "libcli/util/pyerrors.h" #include "libcli/security/security.h" #include "pytalloc.h" @@ -68,7 +69,9 @@ static PyObject *py_se_access_check(PyObject *module, PyObject *args, PyObject * } static PyMethodDef py_security_methods[] = { - { "access_check", (PyCFunction)py_se_access_check, METH_VARARGS|METH_KEYWORDS, + { "access_check", PY_DISCARD_FUNC_SIG(PyCFunction, + py_se_access_check), + METH_VARARGS|METH_KEYWORDS, "access_check(security_descriptor, token, access_desired) -> access_granted. Raises NT_STATUS on error, including on access check failure, returns access granted bitmask"}, { NULL }, }; diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index e82cc5c984f..35d35d69cbe 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -28,6 +28,7 @@ #include "auth/credentials/pycredentials.h" #include "libcli/util/pyerrors.h" #include "python/py3compat.h" +#include "python/modules.h" /* A Python C API module to use LIBGPO */ @@ -115,7 +116,9 @@ out: } static PyMethodDef GPO_methods[] = { - {"get_unix_path", (PyCFunction)py_gpo_get_unix_path, METH_KEYWORDS, + {"get_unix_path", PY_DISCARD_FUNC_SIG(PyCFunction, + py_gpo_get_unix_path), + METH_KEYWORDS, NULL }, {NULL} }; @@ -143,7 +146,7 @@ static void py_ads_dealloc(ADS* self) Py_TYPE(self)->tp_free((PyObject*)self); } -static PyObject* py_ads_connect(ADS *self); +static PyObject* py_ads_connect(ADS *self, PyObject *Py_UNUSED(ignored)); static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds) { const char *realm = NULL; @@ -213,7 +216,8 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds) } /* connect. Failure to connect results in an Exception */ -static PyObject* py_ads_connect(ADS *self) +static PyObject* py_ads_connect(ADS *self, + PyObject *Py_UNUSED(ignored)) { ADS_STATUS status; TALLOC_CTX *frame = talloc_stackframe(); @@ -485,7 +489,8 @@ static PyMethodDef ADS_methods[] = { { "connect", (PyCFunction)py_ads_connect, METH_NOARGS, "Connect to the LDAP server" }, #ifdef HAVE_ADS - { "get_gpo_list", (PyCFunction)py_ads_get_gpo_list, METH_VARARGS | METH_KEYWORDS, + { "get_gpo_list", PY_DISCARD_FUNC_SIG(PyCFunction, py_ads_get_gpo_list), + METH_VARARGS | METH_KEYWORDS, NULL }, #endif { NULL } diff --git a/python/pyglue.c b/python/pyglue.c index 70e211606ff..b998aff223e 100644 --- a/python/pyglue.c +++ b/python/pyglue.c @@ -166,12 +166,14 @@ static PyObject *py_set_debug_level(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *py_get_debug_level(PyObject *self) +static PyObject *py_get_debug_level(PyObject *self, + PyObject *Py_UNUSED(ignored)) { return PyInt_FromLong(debuglevel_get()); } -static PyObject *py_fault_setup(PyObject *self) +static PyObject *py_fault_setup(PyObject *self, + PyObject *Py_UNUSED(ignored)) { static bool done; if (!done) { @@ -181,7 +183,8 @@ static PyObject *py_fault_setup(PyObject *self) Py_RETURN_NONE; } -static PyObject *py_is_ntvfs_fileserver_built(PyObject *self) +static PyObject *py_is_ntvfs_fileserver_built(PyObject *self, + PyObject *Py_UNUSED(ignored)) { #ifdef WITH_NTVFS_FILESERVER Py_RETURN_TRUE; @@ -190,7 +193,8 @@ static PyObject *py_is_ntvfs_fileserver_built(PyObject *self) #endif } -static PyObject *py_is_heimdal_built(PyObject *self) +static PyObject *py_is_heimdal_built(PyObject *self, + PyObject *Py_UNUSED(ignored)) { #ifdef SAMBA4_USES_HEIMDAL Py_RETURN_TRUE; |