]> sigrok.org Git - libsigrok.git/commitdiff
Fix compiler warnings related to -Wcast-function-type.
authorUwe Hermann <redacted>
Sat, 2 May 2020 14:11:42 +0000 (16:11 +0200)
committerUwe Hermann <redacted>
Sat, 2 May 2020 15:01:39 +0000 (17:01 +0200)
This fixes bug #1297.

src/libsigrok-internal.h
src/scpi/vxi_clnt.c
src/session.c
src/usb.c

index 4caceef6ba4a97ef0a0fe873fb2e7ee0d72528d7..1d45eea304564c6cd30b7e1487dd319ff10d602a 100644 (file)
@@ -56,6 +56,13 @@ struct zip_stat;
 #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
 #endif
 
+#ifndef G_SOURCE_FUNC
+#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) /* Since 2.58. */
+#endif
+
+#define SR_RECEIVE_DATA_CALLBACK(f) \
+       ((sr_receive_data_callback) (void (*)(void)) (f))
+
 /**
  * Read a 8 bits unsigned integer out of memory.
  * @param x a pointer to the input memory
index a7c24465aa88f98eb21a59dc5e5737cd80973764..f824f676b940b2de406b8fa72a65bc9521c26fa0 100644 (file)
@@ -7,6 +7,8 @@
 #include "vxi.h"
 #include <memory.h> /* for memset */
 
+#define SR_XDRPROC_CALLBACK(f) ((xdrproc_t) (void (*)(void)) (f))
+
 /* Default timeout can be changed using clnt_control() */
 static struct timeval TIMEOUT = { 25, 0 };
 
@@ -242,7 +244,7 @@ destroy_intr_chan_1(void *argp, CLIENT *clnt)
 
        memset((char *)&clnt_res, 0, sizeof(clnt_res));
        if (clnt_call (clnt, destroy_intr_chan,
-               (xdrproc_t) xdr_void, (caddr_t) argp,
+               SR_XDRPROC_CALLBACK(xdr_void), (caddr_t) argp,
                (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
                TIMEOUT) != RPC_SUCCESS) {
                return (NULL);
@@ -258,7 +260,7 @@ device_intr_srq_1(Device_SrqParms *argp, CLIENT *clnt)
        memset((char *)&clnt_res, 0, sizeof(clnt_res));
        if (clnt_call (clnt, device_intr_srq,
                (xdrproc_t) xdr_Device_SrqParms, (caddr_t) argp,
-               (xdrproc_t) xdr_void, (caddr_t) &clnt_res,
+               SR_XDRPROC_CALLBACK(xdr_void), (caddr_t) &clnt_res,
                TIMEOUT) != RPC_SUCCESS) {
                return (NULL);
        }
index 5e48f4a5aeee5b1aafaf5ea1e2d595d407f6a2c0..d1a19c56e9967a7187d3dc8fdfca01da25848ab1 100644 (file)
@@ -126,7 +126,7 @@ static gboolean fd_source_dispatch(GSource *source,
                sr_err("Callback not set, cannot dispatch event.");
                return G_SOURCE_REMOVE;
        }
-       keep = (*(sr_receive_data_callback)callback)
+       keep = (*SR_RECEIVE_DATA_CALLBACK(callback))
                        (fsource->pollfd.fd, revents, user_data);
 
        if (fsource->timeout_us >= 0 && G_LIKELY(keep)
@@ -1237,7 +1237,7 @@ SR_PRIV int sr_session_fd_source_add(struct sr_session *session,
        if (!source)
                return SR_ERR;
 
-       g_source_set_callback(source, (GSourceFunc)cb, cb_data, NULL);
+       g_source_set_callback(source, G_SOURCE_FUNC(cb), cb_data, NULL);
 
        ret = sr_session_source_add_internal(session, key, source);
        g_source_unref(source);
index 93286e8ad8289419ceaebb8b7069a1dd476db864..6bd9e8182960cc330164350ccc4f37facd8a7aea 100644 (file)
--- a/src/usb.c
+++ b/src/usb.c
@@ -138,7 +138,7 @@ static gboolean usb_source_dispatch(GSource *source,
                sr_err("Callback not set, cannot dispatch event.");
                return G_SOURCE_REMOVE;
        }
-       keep = (*(sr_receive_data_callback)callback)(-1, revents, user_data);
+       keep = (*SR_RECEIVE_DATA_CALLBACK(callback))(-1, revents, user_data);
 
        if (G_LIKELY(keep) && G_LIKELY(!g_source_is_destroyed(source))) {
                if (usource->timeout_us >= 0)
@@ -455,7 +455,7 @@ SR_PRIV int usb_source_add(struct sr_session *session, struct sr_context *ctx,
        if (!source)
                return SR_ERR;
 
-       g_source_set_callback(source, (GSourceFunc)cb, cb_data, NULL);
+       g_source_set_callback(source, G_SOURCE_FUNC(cb), cb_data, NULL);
 
        ret = sr_session_source_add_internal(session, ctx->libusb_ctx, source);
        g_source_unref(source);