diff options
author | Noel Power <noel.power@suse.com> | 2019-05-02 19:45:14 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-05-16 17:55:17 +0000 |
commit | a7d75a1c57befee4a178b7061ea218e353a72195 (patch) | |
tree | 45d349384f33d4ec8c624fd3d40daf4535d4a03f | |
parent | cea41645fb463b026bb7161b524ba732ba0d14e3 (diff) | |
download | samba-a7d75a1c57befee4a178b7061ea218e353a72195.tar.gz |
s4: 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
+ ensure PyCFunctions of type METH_KEYWORDS really actually use the
problematic kargs param, if not remove it
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r-- | source4/auth/gensec/pygensec.c | 18 | ||||
-rw-r--r-- | source4/auth/pyauth.c | 8 | ||||
-rw-r--r-- | source4/dns_server/pydns.c | 3 | ||||
-rw-r--r-- | source4/lib/messaging/pymessaging.c | 23 | ||||
-rw-r--r-- | source4/lib/registry/pyregistry.c | 13 | ||||
-rw-r--r-- | source4/libnet/py_net.c | 82 | ||||
-rw-r--r-- | source4/libnet/py_net_dckeytab.c | 5 | ||||
-rw-r--r-- | source4/param/pyparam.c | 12 |
8 files changed, 125 insertions, 39 deletions
diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index 72981a22263..c62d2be081e 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -19,6 +19,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include "param/pyparam.h" #include "auth/gensec/gensec.h" #include "auth/gensec/gensec_internal.h" /* TODO: remove this */ @@ -295,7 +296,8 @@ static PyObject *py_gensec_set_credentials(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *py_gensec_session_info(PyObject *self) +static PyObject *py_gensec_session_info(PyObject *self, + PyObject *Py_UNUSED(ignored)) { TALLOC_CTX *mem_ctx; NTSTATUS status; @@ -320,7 +322,8 @@ static PyObject *py_gensec_session_info(PyObject *self) return py_session_info; } -static PyObject *py_gensec_session_key(PyObject *self) +static PyObject *py_gensec_session_key(PyObject *self, + PyObject *Py_UNUSED(ignored)) { TALLOC_CTX *mem_ctx; NTSTATUS status; @@ -440,7 +443,8 @@ static PyObject *py_gensec_set_max_update_size(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *py_gensec_max_update_size(PyObject *self) +static PyObject *py_gensec_max_update_size(PyObject *self, + PyObject *Py_UNUSED(ignored)) { struct gensec_security *security = pytalloc_get_type(self, struct gensec_security); unsigned int max_update_size = gensec_max_update_size(security); @@ -640,9 +644,13 @@ static PyObject *py_gensec_check_packet(PyObject *self, PyObject *args) } static PyMethodDef py_gensec_security_methods[] = { - { "start_client", (PyCFunction)py_gensec_start_client, METH_VARARGS|METH_KEYWORDS|METH_CLASS, + { "start_client", PY_DISCARD_FUNC_SIG(PyCFunction, + py_gensec_start_client), + METH_VARARGS|METH_KEYWORDS|METH_CLASS, "S.start_client(settings) -> gensec" }, - { "start_server", (PyCFunction)py_gensec_start_server, METH_VARARGS|METH_KEYWORDS|METH_CLASS, + { "start_server", PY_DISCARD_FUNC_SIG(PyCFunction, + py_gensec_start_server), + METH_VARARGS|METH_KEYWORDS|METH_CLASS, "S.start_server(auth_ctx, settings) -> gensec" }, { "set_credentials", (PyCFunction)py_gensec_set_credentials, METH_VARARGS, "S.start_client(credentials)" }, diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c index 861b6983c9c..acda96612af 100644 --- a/source4/auth/pyauth.c +++ b/source4/auth/pyauth.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 "param/param.h" #include "pyauth.h" @@ -423,13 +424,14 @@ static PyTypeObject PyAuthContext = { static PyMethodDef py_auth_methods[] = { { "system_session", (PyCFunction)py_system_session, METH_VARARGS, NULL }, { "admin_session", (PyCFunction)py_admin_session, METH_VARARGS, NULL }, - { "user_session", (PyCFunction)py_user_session, METH_VARARGS|METH_KEYWORDS, NULL }, + { "user_session", PY_DISCARD_FUNC_SIG(PyCFunction,py_user_session), + METH_VARARGS|METH_KEYWORDS, NULL }, { "session_info_fill_unix", - (PyCFunction)py_session_info_fill_unix, + PY_DISCARD_FUNC_SIG(PyCFunction,py_session_info_fill_unix), METH_VARARGS|METH_KEYWORDS, NULL }, { "copy_session_info", - (PyCFunction)py_copy_session_info, + PY_DISCARD_FUNC_SIG(PyCFunction,py_copy_session_info), METH_VARARGS|METH_KEYWORDS, NULL }, { NULL }, diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c index 16d22dfe4b8..8139ce413e6 100644 --- a/source4/dns_server/pydns.c +++ b/source4/dns_server/pydns.c @@ -22,6 +22,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include <pyldb.h> #include <pytalloc.h> #include "dns_server/dnsserver_common.h" @@ -326,7 +327,7 @@ static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args) static PyMethodDef py_dsdb_dns_methods[] = { - { "lookup", (PyCFunction)py_dsdb_dns_lookup, + { "lookup", PY_DISCARD_FUNC_SIG(PyCFunction, py_dsdb_dns_lookup), METH_VARARGS|METH_KEYWORDS, "Get the DNS database entries for a DNS name"}, { "replace", (PyCFunction)py_dsdb_dns_replace, diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 0681b349220..39c09a82403 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -310,7 +310,7 @@ static PyObject *py_imessaging_loop_once(PyObject *self, PyObject *args, PyObjec Py_RETURN_NONE; } -static PyObject *py_irpc_add_name(PyObject *self, PyObject *args, PyObject *kwargs) +static PyObject *py_irpc_add_name(PyObject *self, PyObject *args) { imessaging_Object *iface = (imessaging_Object *)self; char *server_name; @@ -329,7 +329,7 @@ static PyObject *py_irpc_add_name(PyObject *self, PyObject *args, PyObject *kwar Py_RETURN_NONE; } -static PyObject *py_irpc_remove_name(PyObject *self, PyObject *args, PyObject *kwargs) +static PyObject *py_irpc_remove_name(PyObject *self, PyObject *args) { imessaging_Object *iface = (imessaging_Object *)self; char *server_name; @@ -343,7 +343,7 @@ static PyObject *py_irpc_remove_name(PyObject *self, PyObject *args, PyObject *k Py_RETURN_NONE; } -static PyObject *py_irpc_servers_byname(PyObject *self, PyObject *args, PyObject *kwargs) +static PyObject *py_irpc_servers_byname(PyObject *self, PyObject *args) { imessaging_Object *iface = (imessaging_Object *)self; char *server_name; @@ -397,7 +397,8 @@ static PyObject *py_irpc_servers_byname(PyObject *self, PyObject *args, PyObject return pylist; } -static PyObject *py_irpc_all_servers(PyObject *self, PyObject *args, PyObject *kwargs) +static PyObject *py_irpc_all_servers(PyObject *self, + PyObject *Py_UNUSED(ignored)) { imessaging_Object *iface = (imessaging_Object *)self; PyObject *pylist; @@ -437,16 +438,22 @@ static PyObject *py_irpc_all_servers(PyObject *self, PyObject *args, PyObject *k } static PyMethodDef py_imessaging_methods[] = { - { "send", (PyCFunction)py_imessaging_send, METH_VARARGS|METH_KEYWORDS, + { "send", PY_DISCARD_FUNC_SIG(PyCFunction, py_imessaging_send), + METH_VARARGS|METH_KEYWORDS, "S.send(target, msg_type, data) -> None\nSend a message" }, - { "register", (PyCFunction)py_imessaging_register, METH_VARARGS|METH_KEYWORDS, + { "register", PY_DISCARD_FUNC_SIG(PyCFunction, py_imessaging_register), + METH_VARARGS|METH_KEYWORDS, "S.register((callback, context), msg_type=None) -> msg_type\nRegister a message handler. " "The callback and context must be supplied as a two-element tuple." }, - { "deregister", (PyCFunction)py_imessaging_deregister, METH_VARARGS|METH_KEYWORDS, + { "deregister", PY_DISCARD_FUNC_SIG(PyCFunction, + py_imessaging_deregister), + METH_VARARGS|METH_KEYWORDS, "S.deregister((callback, context), msg_type) -> None\nDeregister a message handler " "The callback and context must be supplied as the exact same two-element tuple " "as was used as registration time." }, - { "loop_once", (PyCFunction)py_imessaging_loop_once, METH_VARARGS|METH_KEYWORDS, + { "loop_once", PY_DISCARD_FUNC_SIG(PyCFunction, + py_imessaging_loop_once), + METH_VARARGS|METH_KEYWORDS, "S.loop_once(timeout) -> None\n" "Loop on the internal event context until we get an event " "(which might be a message calling the callback), " diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index 78b47b8286d..5da804fb048 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -21,6 +21,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include "libcli/util/pyerrors.h" #include "lib/registry/registry.h" #include <pytalloc.h> @@ -178,7 +179,8 @@ static PyObject *py_hive_key_del(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *py_hive_key_flush(PyObject *self) +static PyObject *py_hive_key_flush(PyObject *self, + PyObject *Py_UNUSED(ignored)) { WERROR result; struct hive_key *key = PyHiveKey_AsHiveKey(self); @@ -433,9 +435,12 @@ static PyObject *py_get_predef_name(PyObject *self, PyObject *args) } static PyMethodDef py_registry_methods[] = { - { "open_samba", (PyCFunction)py_open_samba, METH_VARARGS|METH_KEYWORDS, "open_samba() -> reg" }, - { "open_ldb", (PyCFunction)py_open_ldb_file, METH_VARARGS|METH_KEYWORDS, "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, - { "open_hive", (PyCFunction)py_open_hive, METH_VARARGS|METH_KEYWORDS, "open_hive(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, + { "open_samba", PY_DISCARD_FUNC_SIG(PyCFunction, py_open_samba), + METH_VARARGS|METH_KEYWORDS, "open_samba() -> reg" }, + { "open_ldb", PY_DISCARD_FUNC_SIG(PyCFunction, py_open_ldb_file), + METH_VARARGS|METH_KEYWORDS, "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, + { "open_hive", PY_DISCARD_FUNC_SIG(PyCFunction, py_open_hive), + METH_VARARGS|METH_KEYWORDS, "open_hive(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, { "str_regtype", py_str_regtype, METH_VARARGS, "str_regtype(int) -> str" }, { "get_predef_name", py_get_predef_name, METH_VARARGS, "get_predef_name(hkey) -> str" }, { NULL } diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index cacd695e50d..5beeeab1fa8 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -22,6 +22,7 @@ #include <Python.h> #include "python/py3compat.h" #include "includes.h" +#include "python/modules.h" #include <pyldb.h> #include <pytalloc.h> #include "libnet.h" @@ -768,17 +769,76 @@ static const char py_net_finddc_doc[] = "finddc(flags=server_type, domain=None, "Find a DC with the specified 'server_type' bits. The 'domain' and/or 'address' have to be used as additional search criteria. Returns the whole netlogon struct"; static PyMethodDef net_obj_methods[] = { - {"join_member", (PyCFunction)py_net_join_member, METH_VARARGS|METH_KEYWORDS, py_net_join_member_doc}, - {"change_password", (PyCFunction)py_net_change_password, METH_VARARGS|METH_KEYWORDS, py_net_change_password_doc}, - {"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc}, - {"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc}, - {"create_user", (PyCFunction)py_net_user_create, METH_VARARGS|METH_KEYWORDS, py_net_create_user_doc}, - {"delete_user", (PyCFunction)py_net_user_delete, METH_VARARGS|METH_KEYWORDS, py_net_delete_user_doc}, - {"replicate_init", (PyCFunction)py_net_replicate_init, METH_VARARGS|METH_KEYWORDS, py_net_replicate_init_doc}, - {"replicate_chunk", (PyCFunction)py_net_replicate_chunk, METH_VARARGS|METH_KEYWORDS, py_net_replicate_chunk_doc}, - {"replicate_decrypt", (PyCFunction)py_net_replicate_decrypt, METH_VARARGS|METH_KEYWORDS, py_net_replicate_decrypt_doc}, - {"finddc", (PyCFunction)py_net_finddc, METH_VARARGS|METH_KEYWORDS, py_net_finddc_doc}, - { NULL } + { + .ml_name = "join_member", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_join_member), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_join_member_doc + }, + { + .ml_name = "change_password", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_change_password), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_change_password_doc + }, + { + .ml_name = "set_password", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_set_password), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_set_password_doc + }, + { + .ml_name = "time", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, py_net_time), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_time_doc + }, + { + .ml_name = "create_user", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_user_create), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_create_user_doc + }, + { + .ml_name = "delete_user", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_user_delete), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_delete_user_doc + }, + { + .ml_name = "replicate_init", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_replicate_init), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_replicate_init_doc + }, + { + .ml_name = "replicate_chunk", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_replicate_chunk), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_replicate_chunk_doc + }, + { + .ml_name = "replicate_decrypt", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_replicate_decrypt), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_replicate_decrypt_doc + }, + { + .ml_name = "finddc", + .ml_meth = PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_finddc), + .ml_flags = METH_VARARGS|METH_KEYWORDS, + .ml_doc = py_net_finddc_doc + }, + { .ml_name = NULL } }; static void py_net_dealloc(py_net_Object *self) diff --git a/source4/libnet/py_net_dckeytab.c b/source4/libnet/py_net_dckeytab.c index cf43da71c60..ad65c7d46a6 100644 --- a/source4/libnet/py_net_dckeytab.c +++ b/source4/libnet/py_net_dckeytab.c @@ -23,6 +23,7 @@ #include <Python.h> #include "includes.h" #include "python/py3compat.h" +#include "python/modules.h" #include "py_net.h" #include "libnet_export_keytab.h" @@ -65,7 +66,9 @@ static const char py_net_export_keytab_doc[] = "export_keytab(keytab, name)\n\n" "Export the DC keytab to a keytab file."; static PyMethodDef export_keytab_method_table[] = { - {"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc}, + {"export_keytab", PY_DISCARD_FUNC_SIG(PyCFunction, + py_net_export_keytab), + METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc}, { NULL, NULL, 0, NULL } }; diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 9801b0cb01a..200162ea29e 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -614,33 +614,33 @@ PyTypeObject PyLoadparmService = { .tp_flags = Py_TPFLAGS_DEFAULT, }; -static PyObject *py_default_path(PyObject *self) +static PyObject *py_default_path(PyObject *self, PyObject *Py_UNUSED(ignored)) { return PyStr_FromString(lp_default_path()); } -static PyObject *py_setup_dir(PyObject *self) +static PyObject *py_setup_dir(PyObject *self, PyObject *Py_UNUSED(ignored)) { return PyStr_FromString(dyn_SETUPDIR); } -static PyObject *py_modules_dir(PyObject *self) +static PyObject *py_modules_dir(PyObject *self, PyObject *Py_UNUSED(ignored)) { return PyStr_FromString(dyn_MODULESDIR); } -static PyObject *py_bin_dir(PyObject *self) +static PyObject *py_bin_dir(PyObject *self, PyObject *Py_UNUSED(ignored)) { return PyStr_FromString(dyn_BINDIR); } -static PyObject *py_sbin_dir(PyObject *self) +static PyObject *py_sbin_dir(PyObject *self, PyObject *Py_UNUSED(ignored)) { return PyStr_FromString(dyn_SBINDIR); } static PyMethodDef pyparam_methods[] = { - { "default_path", (PyCFunction)py_default_path, METH_NOARGS, + { "default_path", (PyCFunction)py_default_path, METH_NOARGS, "Returns the default smb.conf path." }, { "setup_dir", (PyCFunction)py_setup_dir, METH_NOARGS, "Returns the compiled in location of provision tempates." }, |