chardev: Use QEMUChrEvent enum in IOEventHandler typedef
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Wed, 18 Dec 2019 17:20:09 +0000 (18:20 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jan 2020 10:15:35 +0000 (11:15 +0100)
The Chardev events are listed in the QEMUChrEvent enum.

By using the enum in the IOEventHandler typedef we:

- make the IOEventHandler type more explicit (this handler
  process out-of-band information, while the IOReadHandler
  is in-band),
- help static code analyzers.

This patch was produced with the following spatch script:

  @match@
  expression backend, opaque, context, set_open;
  identifier fd_can_read, fd_read, fd_event, be_change;
  @@
  qemu_chr_fe_set_handlers(backend, fd_can_read, fd_read, fd_event,
                           be_change, opaque, context, set_open);

  @depends on match@
  identifier opaque, event;
  identifier match.fd_event;
  @@
   static
  -void fd_event(void *opaque, int event)
  +void fd_event(void *opaque, QEMUChrEvent event)
   {
   ...
   }

Then the typedef was modified manually in
include/chardev/char-fe.h.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191218172009.8868-15-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
41 files changed:
backends/cryptodev-vhost-user.c
chardev/char-mux.c
gdbstub.c
hw/arm/pxa2xx.c
hw/arm/strongarm.c
hw/block/vhost-user-blk.c
hw/char/cadence_uart.c
hw/char/digic-uart.c
hw/char/escc.c
hw/char/etraxfs_ser.c
hw/char/exynos4210_uart.c
hw/char/grlib_apbuart.c
hw/char/imx_serial.c
hw/char/ipoctal232.c
hw/char/lm32_juart.c
hw/char/lm32_uart.c
hw/char/mcf_uart.c
hw/char/milkymist-uart.c
hw/char/nrf51_uart.c
hw/char/pl011.c
hw/char/serial.c
hw/char/sh_serial.c
hw/char/terminal3270.c
hw/char/virtio-console.c
hw/char/xilinx_uartlite.c
hw/ipmi/ipmi_bmc_extern.c
hw/mips/boston.c
hw/mips/mips_malta.c
hw/riscv/riscv_htif.c
hw/riscv/sifive_uart.c
hw/usb/ccid-card-passthru.c
hw/usb/dev-serial.c
hw/usb/redirect.c
include/chardev/char-fe.h
monitor/hmp.c
monitor/qmp.c
net/filter-mirror.c
net/vhost-user.c
qtest.c
tests/test-char.c
tests/vhost-user-test.c

index f1b407955fc4900f685e55ff4786ac962f79d7fa..6edada8e9e7bbe572ce17a0e7ed64a568808f768 100644 (file)
@@ -152,7 +152,7 @@ cryptodev_vhost_claim_chardev(CryptoDevBackendVhostUser *s,
     return chr;
 }
 
-static void cryptodev_vhost_user_event(void *opaque, int event)
+static void cryptodev_vhost_user_event(void *opaque, QEMUChrEvent event)
 {
     CryptoDevBackendVhostUser *s = opaque;
     CryptoDevBackend *b = CRYPTODEV_BACKEND(s);
index 2675ae0c0a85d63ce51ac453c79b2d16ebb3a35d..46c44af67c4ea5348eb1b6db637f62b8107c46be 100644 (file)
@@ -247,7 +247,7 @@ void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event)
     }
 }
 
-static void mux_chr_event(void *opaque, int event)
+static void mux_chr_event(void *opaque, QEMUChrEvent event)
 {
     mux_chr_send_all_event(CHARDEV(opaque), event);
 }
index 4cf8af365e213b60b1bd5053a80d1d8205b7e8bd..ce304ff4822ea99194d5c35ba39d30ad211b224e 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3171,7 +3171,7 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void gdb_chr_event(void *opaque, int event)
+static void gdb_chr_event(void *opaque, QEMUChrEvent event)
 {
     int i;
     GDBState *s = (GDBState *) opaque;
index cdafde2f7674b907269f461ef18ba8e7b9782a21..950ff4239a5833cca3e257f00ab50e7f11657292 100644 (file)
@@ -1955,7 +1955,7 @@ static void pxa2xx_fir_rx(void *opaque, const uint8_t *buf, int size)
     pxa2xx_fir_update(s);
 }
 
-static void pxa2xx_fir_event(void *opaque, int event)
+static void pxa2xx_fir_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index 6bee03491491154ecf65cfafa21eee0f03790f84..c6776e847959a77b3dd81437a057f8a3db960c3b 100644 (file)
@@ -1093,7 +1093,7 @@ static void strongarm_uart_receive(void *opaque, const uint8_t *buf, int size)
     strongarm_uart_update_int_status(s);
 }
 
-static void strongarm_uart_event(void *opaque, int event)
+static void strongarm_uart_event(void *opaque, QEMUChrEvent event)
 {
     StrongARMUARTState *s = opaque;
     if (event == CHR_EVENT_BREAK) {
index ccaf2ad97857344a97d5698e18894e97b77c7a45..98b383f90ef6cad754917ede085cb42f94826ff4 100644 (file)
@@ -361,7 +361,7 @@ static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond,
     return true;
 }
 
-static void vhost_user_blk_event(void *opaque, int event)
+static void vhost_user_blk_event(void *opaque, QEMUChrEvent event)
 {
     DeviceState *dev = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
index 0e315b23768189ae0894596ec2b1eef0df4b4685..51791bd217f01d367663feb8ec85c91458c34db8 100644 (file)
@@ -348,7 +348,7 @@ static void uart_receive(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
     CadenceUARTState *s = opaque;
     uint8_t buf = '\0';
index 974a2619dd875a95256dd5ff4bdd52ce2d201046..033eba0a6ac67fc4fcb1e7c7d72b70b7f75da4a6 100644 (file)
@@ -131,7 +131,7 @@ static void uart_rx(void *opaque, const uint8_t *buf, int size)
     s->reg_rx = *buf;
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index 8f7bf322cbef07b3ec9b2d740e975e457fa65b25..c40c1d28f186dcaf43c97ffd5838ac5a8b5db91f 100644 (file)
@@ -634,7 +634,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)
     serial_receive_byte(s, buf[0]);
 }
 
-static void serial_event(void *opaque, int event)
+static void serial_event(void *opaque, QEMUChrEvent event)
 {
     ESCCChannelState *s = opaque;
     if (event == CHR_EVENT_BREAK)
index 15ac12ef22d353a7c847e762906fa0d319c60446..f34f767c603cfd95a234d056f8bd27503dd3edc4 100644 (file)
@@ -202,7 +202,7 @@ static int serial_can_receive(void *opaque)
     return sizeof(s->rx_fifo) - s->rx_fifo_len;
 }
 
-static void serial_event(void *opaque, int event)
+static void serial_event(void *opaque, QEMUChrEvent event)
 {
 
 }
index d6b6b62366eb2065c060e3d92ec38a9e7b507e9e..7e5c5ce789b0a2273adae86d610d25155749bbad 100644 (file)
@@ -528,7 +528,7 @@ static void exynos4210_uart_receive(void *opaque, const uint8_t *buf, int size)
 }
 
 
-static void exynos4210_uart_event(void *opaque, int event)
+static void exynos4210_uart_event(void *opaque, QEMUChrEvent event)
 {
     Exynos4210UartState *s = (Exynos4210UartState *)opaque;
 
index fe3cbf41a31d64c9636fd78fb5903feed2871627..8e59c3bc6ef63dd0bda8d53bec24c5d3cdd2f628 100644 (file)
@@ -155,7 +155,7 @@ static void grlib_apbuart_receive(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void grlib_apbuart_event(void *opaque, int event)
+static void grlib_apbuart_event(void *opaque, QEMUChrEvent event)
 {
     trace_grlib_apbuart_event(event);
 }
index fddde9b43d5aefd48aa262d61ef317b907e98424..d09c2107098afcfca77cc4922e4a330daf6eb263 100644 (file)
@@ -323,7 +323,7 @@ static void imx_receive(void *opaque, const uint8_t *buf, int size)
     imx_put_data(opaque, *buf);
 }
 
-static void imx_event(void *opaque, int event)
+static void imx_event(void *opaque, QEMUChrEvent event)
 {
     if (event == CHR_EVENT_BREAK) {
         imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);
index 66c163ba26a205eac3641e0c8b8a31fa478df4a6..80e9dff701efd50671f91cfe68dc5e2742c3150e 100644 (file)
@@ -503,7 +503,7 @@ static void hostdev_receive(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void hostdev_event(void *opaque, int event)
+static void hostdev_event(void *opaque, QEMUChrEvent event)
 {
     SCC2698Channel *ch = opaque;
     switch (event) {
index e0b1bd655502e77e58c1f789d5819865441bb783..da9dd5668b8c2dd90dea80e4bd279d67272f9f8e 100644 (file)
@@ -104,7 +104,7 @@ static int juart_can_rx(void *opaque)
     return !(s->jrx & JRX_FULL);
 }
 
-static void juart_event(void *opaque, int event)
+static void juart_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index 32f29c44cfc0dd87f257faf180d9773310d5e144..8d7a475c9138dfa8a85596ddea39f19c0a5d2900 100644 (file)
@@ -235,7 +235,7 @@ static int uart_can_rx(void *opaque)
     return !(s->regs[R_LSR] & LSR_DR);
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index 58323baf43ef88c01e226d6ff02ae6ef4bcf18fd..2de3680b5d046374c9525025ed69fc27254a625c 100644 (file)
@@ -256,7 +256,7 @@ static void mcf_uart_push_byte(mcf_uart_state *s, uint8_t data)
     mcf_uart_update(s);
 }
 
-static void mcf_uart_event(void *opaque, int event)
+static void mcf_uart_event(void *opaque, QEMUChrEvent event)
 {
     mcf_uart_state *s = (mcf_uart_state *)opaque;
 
index c358ca07f34bbf3876c85d8368d39e63b1b51fc9..1c7b61480e63ba577d1db5602207fdd62438ebd7 100644 (file)
@@ -180,7 +180,7 @@ static int uart_can_rx(void *opaque)
     return !(s->regs[R_STAT] & STAT_RX_EVT);
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index 2777afe366c2101624a32837247a14a5b9aeefc4..b67fd21089a086eb6551deccb6a8c70eaaf885fa 100644 (file)
@@ -245,7 +245,7 @@ static int uart_can_receive(void *opaque)
     return s->rx_started ? (UART_FIFO_LENGTH - s->rx_fifo_len) : 0;
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
     NRF51UARTState *s = NRF51_UART(opaque);
 
index 84ad8ff9fb16b743525c9510d402a0b3d65416b5..23cd544cc557d85794a3db9a353f927338b58345 100644 (file)
@@ -280,7 +280,7 @@ static void pl011_receive(void *opaque, const uint8_t *buf, int size)
     pl011_put_fifo(opaque, *buf);
 }
 
-static void pl011_event(void *opaque, int event)
+static void pl011_event(void *opaque, QEMUChrEvent event)
 {
     if (event == CHR_EVENT_BREAK)
         pl011_put_fifo(opaque, 0x400);
index b4aa25095024b04e5be907a67cacf9edb6e6150a..992b5ee9443255be9d52acb010cc7ea1f77e0379 100644 (file)
@@ -634,7 +634,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)
     serial_update_irq(s);
 }
 
-static void serial_event(void *opaque, int event)
+static void serial_event(void *opaque, QEMUChrEvent event)
 {
     SerialState *s = opaque;
     DPRINTF("event %x\n", event);
index 07dc16be1371a4069bfd92ea285d90bdcdea412a..167f4d8cb9083b01518124c5d515206153d13f5f 100644 (file)
@@ -358,7 +358,7 @@ static void sh_serial_receive1(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void sh_serial_event(void *opaque, int event)
+static void sh_serial_event(void *opaque, QEMUChrEvent event)
 {
     sh_serial_state *s = opaque;
     if (event == CHR_EVENT_BREAK)
index 2aab04fd4b94b9ed9f6c8220c86a30a02ef03c44..f7aba12565fbf7656dcacee37a7cb387948324ec 100644 (file)
@@ -142,7 +142,7 @@ static void terminal_read(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void chr_event(void *opaque, int event)
+static void chr_event(void *opaque, QEMUChrEvent event)
 {
     Terminal3270 *t = opaque;
     CcwDevice *ccw_dev = CCW_DEVICE(t);
index cbb304d2702d12f245fa9f4fe785d9bb8eb1c569..a7d34fe0edcf245765e9b7acadbb643726653980 100644 (file)
@@ -145,7 +145,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     virtio_serial_write(port, buf, size);
 }
 
-static void chr_event(void *opaque, int event)
+static void chr_event(void *opaque, QEMUChrEvent event)
 {
     VirtConsole *vcon = opaque;
     VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(vcon);
index 2c4727506868ee494728d2076cfc863421320d24..aa6bf02e212e7bfa0544e2b5ded04551cb2ddd0c 100644 (file)
@@ -206,7 +206,7 @@ static int uart_can_rx(void *opaque)
     return s->rx_fifo_len < sizeof(s->rx_fifo);
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
 
 }
index adf2afe7282aed1374c862053cf7cc389b8dab1b..16a4117ab0523914b1846e1c7880d0d8b5b04dbf 100644 (file)
@@ -379,7 +379,7 @@ static void receive(void *opaque, const uint8_t *buf, int size)
     handle_hw_op(ibe, hw_op);
 }
 
-static void chr_event(void *opaque, int event)
+static void chr_event(void *opaque, QEMUChrEvent event)
 {
     IPMIBmcExtern *ibe = opaque;
     IPMIInterface *s = ibe->parent.intf;
index ca7d813a52178165a351b76d028c8b1dc34a3353..29b476b4bde2c0b20e5bc2e42793c43e56badcc5 100644 (file)
@@ -98,7 +98,7 @@ enum boston_plat_reg {
     PLAT_SYS_CTL        = 0x48,
 };
 
-static void boston_lcd_event(void *opaque, int event)
+static void boston_lcd_event(void *opaque, QEMUChrEvent event)
 {
     BostonState *s = opaque;
     if (event == CHR_EVENT_OPENED && !s->lcd_inited) {
index 783cd99848d91790e9600822d638c22ce1d3b1f2..72c03baa8eeaed56dbc95479c8cbd0f516e33952 100644 (file)
@@ -545,7 +545,7 @@ static void malta_fpga_reset(void *opaque)
     snprintf(s->display_text, 9, "        ");
 }
 
-static void malta_fgpa_display_event(void *opaque, int event)
+static void malta_fgpa_display_event(void *opaque, QEMUChrEvent event)
 {
     MaltaFPGAState *s = opaque;
 
index 4f7b11dc376897ebd251caa002e13fbd5a99d1c8..ca87a5cf9f86b210446456c30ef30de2418e7f7f 100644 (file)
@@ -96,7 +96,7 @@ static void htif_recv(void *opaque, const uint8_t *buf, int size)
  * Called by the char dev to supply special events to the HTIF console.
  * Not used for HTIF.
  */
-static void htif_event(void *opaque, int event)
+static void htif_event(void *opaque, QEMUChrEvent event)
 {
 
 }
index a403ae90f53bcc8e736ab6e62e2767f602cd1448..93504826626ecaced1496263e9aa44a0b8efd642 100644 (file)
@@ -162,7 +162,7 @@ static int uart_can_rx(void *opaque)
     return s->rx_fifo_len < sizeof(s->rx_fifo);
 }
 
-static void uart_event(void *opaque, int event)
+static void uart_event(void *opaque, QEMUChrEvent event)
 {
 }
 
index e53696c07ad1d75e2ec37e6f3e46b9c51c88b547..3d40b700dbeba1b431d771474d7f9a01c5170aa9 100644 (file)
@@ -307,7 +307,7 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void ccid_card_vscard_event(void *opaque, int event)
+static void ccid_card_vscard_event(void *opaque, QEMUChrEvent event)
 {
     PassthruState *card = opaque;
 
index 2ba6870b37441b11bef367f3bd5a893e27bf353a..9646fe77da18798a4387b7d2a19e3b95b83a9bcd 100644 (file)
@@ -461,7 +461,7 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size)
     s->recv_used += size;
 }
 
-static void usb_serial_event(void *opaque, int event)
+static void usb_serial_event(void *opaque, QEMUChrEvent event)
 {
     USBSerialState *s = opaque;
 
index ddc1a59cb4682f8963d70dfe34322101908b71c5..0068aa8a19f201c362b617d64c0a957f46485cb8 100644 (file)
@@ -1354,7 +1354,7 @@ static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)
     usbredirparser_do_write(dev->parser);
 }
 
-static void usbredir_chardev_event(void *opaque, int event)
+static void usbredir_chardev_event(void *opaque, QEMUChrEvent event)
 {
     USBRedirDevice *dev = opaque;
 
index 67601dc9a43ec7c3bcdc1dd83ba8ce7bdd4a9fe5..a5538433649488772f8dd7e8995d2f383506515b 100644 (file)
@@ -4,7 +4,7 @@
 #include "chardev/char.h"
 #include "qemu/main-loop.h"
 
-typedef void IOEventHandler(void *opaque, int event);
+typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
 typedef int BackendChangeHandler(void *opaque);
 
 /* This is the backend as seen by frontend, the actual backend is
index 706ebe707416d5b3e888a4d43168b98d48626786..944fa9651ede7ad4c0c25c816324e7d3c859596f 100644 (file)
@@ -1322,7 +1322,7 @@ static void monitor_read(void *opaque, const uint8_t *buf, int size)
     cur_mon = old_mon;
 }
 
-static void monitor_event(void *opaque, int event)
+static void monitor_event(void *opaque, QEMUChrEvent event)
 {
     Monitor *mon = opaque;
     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
index 6c46be40f814dd8aa3aefc82a4eb5aaf9ef38565..54c06ba824b036a9b16d56cdc6c92dffd9634f76 100644 (file)
@@ -337,7 +337,7 @@ static QDict *qmp_greeting(MonitorQMP *mon)
         ver, cap_list);
 }
 
-static void monitor_qmp_event(void *opaque, int event)
+static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
 {
     QDict *data;
     MonitorQMP *mon = opaque;
index 8d36009c5347ac87f83902a1130f90d44a32de61..d83e815545c83f3c2899102c363f00a650b264df 100644 (file)
@@ -132,7 +132,7 @@ static void redirector_chr_read(void *opaque, const uint8_t *buf, int size)
     }
 }
 
-static void redirector_chr_event(void *opaque, int event)
+static void redirector_chr_event(void *opaque, QEMUChrEvent event)
 {
     NetFilterState *nf = opaque;
     MirrorState *s = FILTER_REDIRECTOR(nf);
index c54c9c7d4c8825e77e4188055cf77e7dad6394fc..17532daaf32e31392c1036ffad3dde0532899192 100644 (file)
@@ -218,7 +218,7 @@ static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
     return TRUE;
 }
 
-static void net_vhost_user_event(void *opaque, int event);
+static void net_vhost_user_event(void *opaque, QEMUChrEvent event);
 
 static void chr_closed_bh(void *opaque)
 {
@@ -249,7 +249,7 @@ static void chr_closed_bh(void *opaque)
     }
 }
 
-static void net_vhost_user_event(void *opaque, int event)
+static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
 {
     const char *name = opaque;
     NetClientState *ncs[MAX_QUEUE_NUM];
diff --git a/qtest.c b/qtest.c
index 8b50e2783ee0dde871ecd944340b6a5115902d60..12432f99cf4424edc0a0934eba7aa4596986a41c 100644 (file)
--- a/qtest.c
+++ b/qtest.c
@@ -722,7 +722,7 @@ static int qtest_can_read(void *opaque)
     return 1024;
 }
 
-static void qtest_event(void *opaque, int event)
+static void qtest_event(void *opaque, QEMUChrEvent event)
 {
     int i;
 
index 45e42af290d4c55c0d8ed9358ef2f78e35048a2c..3afc9b1b8d59802919139012c2cb1802f0795503 100644 (file)
@@ -54,7 +54,7 @@ static void fe_read(void *opaque, const uint8_t *buf, int size)
     quit = true;
 }
 
-static void fe_event(void *opaque, int event)
+static void fe_event(void *opaque, QEMUChrEvent event)
 {
     FeHandler *h = opaque;
     bool new_open_state;
@@ -633,7 +633,7 @@ typedef struct {
 
 
 static void
-char_socket_event(void *opaque, int event)
+char_socket_event(void *opaque, QEMUChrEvent event)
 {
     CharSocketTestData *data = opaque;
     data->event = event;
@@ -1006,7 +1006,7 @@ static void char_socket_client_test(gconstpointer opaque)
 }
 
 static void
-count_closed_event(void *opaque, int event)
+count_closed_event(void *opaque, QEMUChrEvent event)
 {
     int *count = opaque;
     if (event == CHR_EVENT_CLOSED) {
index 91ea373ba5915c37216a36f0f7cc376e66c945fa..2324b964adeb9bf4bf0fe3e867778376149c8845 100644 (file)
@@ -499,7 +499,7 @@ static TestServer *test_server_new(const gchar *name)
     return server;
 }
 
-static void chr_event(void *opaque, int event)
+static void chr_event(void *opaque, QEMUChrEvent event)
 {
     TestServer *s = opaque;