]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4: squash 'cast between incompatible function types' warning
authorNoel Power <noel.power@suse.com>
Thu, 2 May 2019 18:45:14 +0000 (19:45 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 16 May 2019 17:55:17 +0000 (17:55 +0000)
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>
source4/auth/gensec/pygensec.c
source4/auth/pyauth.c
source4/dns_server/pydns.c
source4/lib/messaging/pymessaging.c
source4/lib/registry/pyregistry.c
source4/libnet/py_net.c
source4/libnet/py_net_dckeytab.c
source4/param/pyparam.c

index 72981a22263e0f31f4a3f7336f9cb6bd919ffd35..c62d2be081ef8daf223b13934474623c401e9565 100644 (file)
@@ -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)" },
index 861b6983c9c1ebf22c9e12cb8172768fcb9b8efa..acda96612af5e97dcf4aea099c122cbe12347cd0 100644 (file)
@@ -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 },
index 16d22dfe4b8df2176dc40e382a438659adfc1337..8139ce413e6d149fb8fda8f13fde1786d59ed240 100644 (file)
@@ -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,
index 0681b34922096f32c12d9acb425b06deea502614..39c09a8240324c5f4c73b08d1f340ed325df6416 100644 (file)
@@ -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), "
index 78b47b8286d8e03fe69ed0489ce49a78b1ebd891..5da804fb048de17603665d251ab0edc9b308400b 100644 (file)
@@ -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 }
index cacd695e50d59463c9568ca76f157a2d324f0c05..5beeeab1fa8e98720cf804719430ded8d4e20a90 100644 (file)
@@ -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)
index cf43da71c60ea0e33309edcbe6e1f599eb804a9f..ad65c7d46a64da84ea31225eed2d18bb9c5e02c3 100644 (file)
@@ -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 }
 };
 
index 9801b0cb01a4d3073be379013814513e8df6d007..200162ea29ea1fdbd15bcddf4431ed62fc1a051b 100644 (file)
@@ -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." },