lib/tevent: squash 'cast between incompatible function types' warning
authorNoel Power <noel.power@suse.com>
Thu, 2 May 2019 18:49:09 +0000 (19:49 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 16 May 2019 17:55:17 +0000 (17:55 +0000)
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>
lib/tevent/pytevent.c

index 97976df32d3810a29e3c2fcfecce01590233764c..a73141bf87d1fa9a91bb9f859143a0d50f05df27 100644 (file)
@@ -37,6 +37,9 @@
 #define PyStr_AsUTF8 PyString_AsString
 #endif
 
+/* discard signature of 'func' in favour of 'target_sig' */
+#define PY_DISCARD_FUNC_SIG(target_sig, func) (target_sig)(void(*)(void))func
+
 void init_tevent(void);
 
 typedef struct {
@@ -205,7 +208,8 @@ static PyObject *py_register_backend(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_context_reinitialise(TeventContext_Object *self)
+static PyObject *py_tevent_context_reinitialise(TeventContext_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        int ret = tevent_re_initialise(self->ev);
        if (ret != 0) {
@@ -215,13 +219,15 @@ static PyObject *py_tevent_context_reinitialise(TeventContext_Object *self)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_queue_stop(TeventQueue_Object *self)
+static PyObject *py_tevent_queue_stop(TeventQueue_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        tevent_queue_stop(self->queue);
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_queue_start(TeventQueue_Object *self)
+static PyObject *py_tevent_queue_start(TeventQueue_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        tevent_queue_start(self->queue);
        Py_RETURN_NONE;
@@ -262,9 +268,11 @@ static PyObject *py_tevent_queue_add(TeventQueue_Object *self, PyObject *args)
 }
 
 static PyMethodDef py_tevent_queue_methods[] = {
-       { "stop", (PyCFunction)py_tevent_queue_stop, METH_NOARGS,
+       { "stop", (PyCFunction)py_tevent_queue_stop,
+               METH_NOARGS,
                "S.stop()" },
-       { "start", (PyCFunction)py_tevent_queue_start, METH_NOARGS,
+       { "start", (PyCFunction)py_tevent_queue_start,
+               METH_NOARGS,
                "S.start()" },
        { "add", (PyCFunction)py_tevent_queue_add, METH_VARARGS,
                "S.add(ctx, req, trigger, baton)" },
@@ -278,7 +286,8 @@ static PyObject *py_tevent_context_wakeup_send(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_context_loop_wait(TeventContext_Object *self)
+static PyObject *py_tevent_context_loop_wait(TeventContext_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        if (tevent_loop_wait(self->ev) != 0) {
                PyErr_SetNone(PyExc_RuntimeError);
@@ -287,7 +296,8 @@ static PyObject *py_tevent_context_loop_wait(TeventContext_Object *self)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_context_loop_once(TeventContext_Object *self)
+static PyObject *py_tevent_context_loop_once(TeventContext_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        if (tevent_loop_once(self->ev) != 0) {
                PyErr_SetNone(PyExc_RuntimeError);
@@ -379,7 +389,9 @@ static int py_tevent_timer_traverse(TeventTimer_Object *self, visitproc visit, v
        return 0;
 }
 
-static PyObject* py_tevent_timer_get_active(TeventTimer_Object *self) {
+static PyObject* py_tevent_timer_get_active(TeventTimer_Object *self,
+                       PyObject *Py_UNUSED(ignored))
+{
        return PyBool_FromLong(self->timer != NULL);
 }
 
@@ -554,7 +566,8 @@ static PyObject *py_tevent_context_add_fd(TeventContext_Object *self, PyObject *
 }
 
 static PyMethodDef py_tevent_context_methods[] = {
-       { "reinitialise", (PyCFunction)py_tevent_context_reinitialise, METH_NOARGS,
+       { "reinitialise", (PyCFunction)py_tevent_context_reinitialise,
+               METH_NOARGS,
                "S.reinitialise()" },
        { "wakeup_send", (PyCFunction)py_tevent_context_wakeup_send, 
                METH_VARARGS, "S.wakeup_send(wakeup_time) -> req" },
@@ -573,31 +586,36 @@ static PyMethodDef py_tevent_context_methods[] = {
        { NULL },
 };
 
-static PyObject *py_tevent_req_wakeup_recv(PyObject *self)
+static PyObject *py_tevent_req_wakeup_recv(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_received(PyObject *self)
+static PyObject *py_tevent_req_received(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_is_error(PyObject *self)
+static PyObject *py_tevent_req_is_error(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_poll(PyObject *self)
+static PyObject *py_tevent_req_poll(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_is_in_progress(PyObject *self)
+static PyObject *py_tevent_req_is_in_progress(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
@@ -624,13 +642,15 @@ static PyObject *py_tevent_req_set_error(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_done(PyObject *self)
+static PyObject *py_tevent_req_done(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_notify_callback(PyObject *self)
+static PyObject *py_tevent_req_notify_callback(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        /* FIXME */
        Py_RETURN_NONE;
@@ -642,7 +662,8 @@ static PyObject *py_tevent_req_set_endtime(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_tevent_req_cancel(TeventReq_Object *self)
+static PyObject *py_tevent_req_cancel(TeventReq_Object *self,
+               PyObject *Py_UNUSED(ignored))
 {
        if (!tevent_req_cancel(self->req)) {
                PyErr_SetNone(PyExc_RuntimeError);
@@ -652,9 +673,11 @@ static PyObject *py_tevent_req_cancel(TeventReq_Object *self)
 }
 
 static PyMethodDef py_tevent_req_methods[] = {
-       { "wakeup_recv", (PyCFunction)py_tevent_req_wakeup_recv, METH_NOARGS,
+       { "wakeup_recv", (PyCFunction)py_tevent_req_wakeup_recv,
+               METH_NOARGS,
                "Wakeup received" },
-       { "received", (PyCFunction)py_tevent_req_received, METH_NOARGS,
+       { "received", (PyCFunction)py_tevent_req_received,
+               METH_NOARGS,
                "Receive finished" },
        { "is_error", (PyCFunction)py_tevent_req_is_error, METH_NOARGS,
                "is_error() -> (error, state)" },
@@ -690,7 +713,8 @@ static PyTypeObject TeventReq_Type = {
        /* FIXME: .tp_new = py_tevent_req_new, */
 };
 
-static PyObject *py_tevent_queue_get_length(TeventQueue_Object *self)
+static PyObject *py_tevent_queue_get_length(TeventQueue_Object *self,
+                       PyObject *Py_UNUSED(ignored))
 {
        return PyInt_FromLong(tevent_queue_length(self->queue));
 }
@@ -719,7 +743,8 @@ static PyTypeObject TeventQueue_Type = {
        .tp_methods = py_tevent_queue_methods,
 };
 
-static PyObject *py_tevent_context_signal_support(PyObject *_self)
+static PyObject *py_tevent_context_signal_support(PyObject *_self,
+               PyObject *Py_UNUSED(ignored))
 {
        TeventContext_Object *self = (TeventContext_Object *)_self;
        return PyBool_FromLong(tevent_signal_support(self->ev));
@@ -728,7 +753,8 @@ static PyObject *py_tevent_context_signal_support(PyObject *_self)
 static PyGetSetDef py_tevent_context_getsetters[] = {
        {
                .name = discard_const_p(char, "signal_support"),
-               .get = (getter)py_tevent_context_signal_support,
+               .get = PY_DISCARD_FUNC_SIG(getter,
+                                          py_tevent_context_signal_support),
                .doc = discard_const_p(char, "if this platform and tevent context support signal handling"),
        },
        { NULL }
@@ -793,7 +819,8 @@ static PyObject *py_set_default_backend(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_backend_list(PyObject *self)
+static PyObject *py_backend_list(PyObject *self,
+               PyObject *Py_UNUSED(ignored))
 {
        PyObject *ret = NULL;
        PyObject *string = NULL;