squash 'cast between incompatible function types' warning
authorNoel Power <noel.power@suse.com>
Thu, 2 May 2019 18:47:29 +0000 (19:47 +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

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
auth/credentials/pycredentials.c
libcli/nbt/pynbt.c
libcli/security/pysecurity.c
libgpo/pygpo.c
python/pyglue.c

index 1b86e0015573bf6fdb652f40bae28a9401abfc62..966c625a10e210f35915c64200594db634da1e7d 100644 (file)
@@ -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]) -> "
index ccd7a039248dd3388bd10388722ec109576bb57d..2ae3ecfe8a736c7b8bdc9d453d3454e6bd10281f 100644 (file)
@@ -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" },
 
index 72058424d993e584f1f856223c9c0292429c7053..86b2cc893aac87e8f19a6546e2f28d634a8000cf 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 "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 },
 };
index e82cc5c984f377802034503c142dfadb2bd64e5d..35d35d69cbe72cf9680372e8bc1df43aeaa6bcaf 100644 (file)
@@ -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 }
index 70e211606ffba29bf598631a57a7ddb3cdabd30e..b998aff223e06f231fde34c76392ad5d0107c72d 100644 (file)
@@ -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;