]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
chardev: mark explicitly first argument as poisoned
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 4 Aug 2021 13:01:14 +0000 (17:01 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 5 Aug 2021 12:15:33 +0000 (16:15 +0400)
Since commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2 "char: convert
from GIOChannel to QIOChannel", the first argument to the watch callback
can actually be a QIOChannel, which is not a GIOChannel (but a QEMU
Object).

Even though we never used that pointer, change the callback type to warn
the users. Possibly a better fix later, we may want to store the
callback and call it from intermediary functions.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
12 files changed:
chardev/char-fe.c
hw/char/cadence_uart.c
hw/char/cmsdk-apb-uart.c
hw/char/ibex_uart.c
hw/char/nrf51_uart.c
hw/char/serial.c
hw/char/virtio-console.c
hw/usb/redirect.c
hw/virtio/vhost-user.c
include/chardev/char-fe.h
monitor/monitor.c
net/vhost-user.c

index 474715c5a9257ae9e9e286d2e02dacb8a6fcbfe6..7789f7be9c873928be895d618e98978b504005d5 100644 (file)
@@ -354,7 +354,7 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
 }
 
 guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
-                            GIOFunc func, void *user_data)
+                            FEWatchFunc func, void *user_data)
 {
     Chardev *s = be->chr;
     GSource *src;
index ceb677bc5a86da0787b1cd08258512fdcf9507cc..b4b5e8a3ee00b599560d76b0aca7e250c71b27bb 100644 (file)
@@ -288,7 +288,7 @@ static void uart_write_rx_fifo(void *opaque, const uint8_t *buf, int size)
     uart_update_status(s);
 }
 
-static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond,
+static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
                                   void *opaque)
 {
     CadenceUARTState *s = opaque;
index ba2cbbee3d893d90a45e5a82cd8b3dd75897fbfd..f8dc89ee3dc62bef9627f265840be281f13b8e61 100644 (file)
@@ -191,7 +191,7 @@ static uint64_t uart_read(void *opaque, hwaddr offset, unsigned size)
 /* Try to send tx data, and arrange to be called back later if
  * we can't (ie the char backend is busy/blocking).
  */
-static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque)
+static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
 {
     CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
     int ret;
index 6b0c9330bfa8c5ba6fdcf5eb6c3368e61096c834..9b0a81771349892fa716989da436af8df12c4378 100644 (file)
@@ -135,7 +135,7 @@ static void ibex_uart_receive(void *opaque, const uint8_t *buf, int size)
     ibex_uart_update_irqs(s);
 }
 
-static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond,
+static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
                                void *opaque)
 {
     IbexUartState *s = opaque;
index 045ca5fa40d3acebb50700f01038f1a5d88ed249..3c6f982de97db3a5bada35c95d92daca3e17a8b8 100644 (file)
@@ -75,7 +75,7 @@ static uint64_t uart_read(void *opaque, hwaddr addr, unsigned int size)
     return r;
 }
 
-static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque)
+static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
 {
     NRF51UARTState *s = NRF51_UART(opaque);
     int r;
index bc2e3229704ffdbe4d030ea237f68c3a63cd219b..7061aacbce9cd6a63449129c1e102047eb2543bc 100644 (file)
@@ -220,7 +220,7 @@ static void serial_update_msl(SerialState *s)
     }
 }
 
-static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
+static gboolean serial_watch_cb(void *do_not_use, GIOCondition cond,
                                 void *opaque)
 {
     SerialState *s = opaque;
index 6b132caa29d35a73d35ba8599ce142bd9dc34600..dd5a02e339223fd33f8ff942fc0f518ca4f582b7 100644 (file)
@@ -38,7 +38,7 @@ struct VirtConsole {
  * Callback function that's called from chardevs when backend becomes
  * writable.
  */
-static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond,
+static gboolean chr_write_unblocked(void *do_not_use, GIOCondition cond,
                                     void *opaque)
 {
     VirtConsole *vcon = opaque;
index 1ec909a63a8068de607174289e0532d0e494c261..5f0ef9cb3b0fc9e5f6706413d6c79b6b11423dca 100644 (file)
@@ -270,7 +270,7 @@ static int usbredir_read(void *priv, uint8_t *data, int count)
     return count;
 }
 
-static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond,
+static gboolean usbredir_write_unblocked(void *do_not_use, GIOCondition cond,
                                          void *opaque)
 {
     USBRedirDevice *dev = opaque;
index 29ea2b4fceb21933c5b0e1882701cab9058b9411..aec6cc199064400d89830ca298e9a39362cf0d0c 100644 (file)
@@ -303,7 +303,7 @@ struct vhost_user_read_cb_data {
     int ret;
 };
 
-static gboolean vhost_user_read_cb(GIOChannel *source, GIOCondition condition,
+static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
                                    gpointer opaque)
 {
     struct vhost_user_read_cb_data *data = opaque;
index a5538433649488772f8dd7e8995d2f383506515b..867ef1b3b28ae15bcc2e0b5300bb4e3bed408018 100644 (file)
@@ -174,6 +174,9 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
 void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
+
+typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *data);
+
 /**
  * qemu_chr_fe_add_watch:
  * @cond: the condition to poll for
@@ -188,10 +191,13 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
  * Note that you are responsible to update the front-end sources if
  * you are switching the main context with qemu_chr_fe_set_handlers().
  *
+ * Warning: DO NOT use the first callback argument (it may be either
+ * a GIOChannel or a QIOChannel, depending on the underlying chardev)
+ *
  * Returns: the source tag
  */
 guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
-                            GIOFunc func, void *user_data);
+                            FEWatchFunc func, void *user_data);
 
 /**
  * qemu_chr_fe_write:
index b90c0f40516f1404396da9deb0e880ddce23158b..46a171bca6e77087981488378eb44dc5cf672804 100644 (file)
@@ -156,7 +156,7 @@ static inline bool monitor_is_hmp_non_interactive(const Monitor *mon)
 
 static void monitor_flush_locked(Monitor *mon);
 
-static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
+static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
                                   void *opaque)
 {
     Monitor *mon = opaque;
index ffbd94d944faa08ad8ffc91a548661a653fd0470..6adfcd623aa20a6d4a04ba6f59bc3fc06ca6036f 100644 (file)
@@ -208,8 +208,8 @@ static NetClientInfo net_vhost_user_info = {
         .set_vnet_le = vhost_user_set_vnet_endianness,
 };
 
-static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
-                                           void *opaque)
+static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
+                                     void *opaque)
 {
     NetVhostUserState *s = opaque;