chardev: Use QEMUChrEvent enum in IOEventHandler typedef

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>
This commit is contained in:
Philippe Mathieu-Daudé 2019-12-18 18:20:09 +01:00 committed by Paolo Bonzini
parent 2fa9044a4f
commit 083b266f69
41 changed files with 44 additions and 44 deletions

View File

@ -152,7 +152,7 @@ cryptodev_vhost_claim_chardev(CryptoDevBackendVhostUser *s,
return chr; 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; CryptoDevBackendVhostUser *s = opaque;
CryptoDevBackend *b = CRYPTODEV_BACKEND(s); CryptoDevBackend *b = CRYPTODEV_BACKEND(s);

View 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); mux_chr_send_all_event(CHARDEV(opaque), event);
} }

View File

@ -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; int i;
GDBState *s = (GDBState *) opaque; GDBState *s = (GDBState *) opaque;

View File

@ -1955,7 +1955,7 @@ static void pxa2xx_fir_rx(void *opaque, const uint8_t *buf, int size)
pxa2xx_fir_update(s); pxa2xx_fir_update(s);
} }
static void pxa2xx_fir_event(void *opaque, int event) static void pxa2xx_fir_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -1093,7 +1093,7 @@ static void strongarm_uart_receive(void *opaque, const uint8_t *buf, int size)
strongarm_uart_update_int_status(s); 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; StrongARMUARTState *s = opaque;
if (event == CHR_EVENT_BREAK) { if (event == CHR_EVENT_BREAK) {

View File

@ -361,7 +361,7 @@ static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond,
return true; 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; DeviceState *dev = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIODevice *vdev = VIRTIO_DEVICE(dev);

View 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; CadenceUARTState *s = opaque;
uint8_t buf = '\0'; uint8_t buf = '\0';

View File

@ -131,7 +131,7 @@ static void uart_rx(void *opaque, const uint8_t *buf, int size)
s->reg_rx = *buf; s->reg_rx = *buf;
} }
static void uart_event(void *opaque, int event) static void uart_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -634,7 +634,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)
serial_receive_byte(s, buf[0]); 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; ESCCChannelState *s = opaque;
if (event == CHR_EVENT_BREAK) if (event == CHR_EVENT_BREAK)

View File

@ -202,7 +202,7 @@ static int serial_can_receive(void *opaque)
return sizeof(s->rx_fifo) - s->rx_fifo_len; 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)
{ {
} }

View 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; Exynos4210UartState *s = (Exynos4210UartState *)opaque;

View 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); trace_grlib_apbuart_event(event);
} }

View File

@ -323,7 +323,7 @@ static void imx_receive(void *opaque, const uint8_t *buf, int size)
imx_put_data(opaque, *buf); 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) { if (event == CHR_EVENT_BREAK) {
imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR); imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);

View 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; SCC2698Channel *ch = opaque;
switch (event) { switch (event) {

View File

@ -104,7 +104,7 @@ static int juart_can_rx(void *opaque)
return !(s->jrx & JRX_FULL); return !(s->jrx & JRX_FULL);
} }
static void juart_event(void *opaque, int event) static void juart_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -235,7 +235,7 @@ static int uart_can_rx(void *opaque)
return !(s->regs[R_LSR] & LSR_DR); return !(s->regs[R_LSR] & LSR_DR);
} }
static void uart_event(void *opaque, int event) static void uart_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -256,7 +256,7 @@ static void mcf_uart_push_byte(mcf_uart_state *s, uint8_t data)
mcf_uart_update(s); 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; mcf_uart_state *s = (mcf_uart_state *)opaque;

View File

@ -180,7 +180,7 @@ static int uart_can_rx(void *opaque)
return !(s->regs[R_STAT] & STAT_RX_EVT); return !(s->regs[R_STAT] & STAT_RX_EVT);
} }
static void uart_event(void *opaque, int event) static void uart_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -245,7 +245,7 @@ static int uart_can_receive(void *opaque)
return s->rx_started ? (UART_FIFO_LENGTH - s->rx_fifo_len) : 0; 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); NRF51UARTState *s = NRF51_UART(opaque);

View File

@ -280,7 +280,7 @@ static void pl011_receive(void *opaque, const uint8_t *buf, int size)
pl011_put_fifo(opaque, *buf); 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) if (event == CHR_EVENT_BREAK)
pl011_put_fifo(opaque, 0x400); pl011_put_fifo(opaque, 0x400);

View File

@ -634,7 +634,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)
serial_update_irq(s); serial_update_irq(s);
} }
static void serial_event(void *opaque, int event) static void serial_event(void *opaque, QEMUChrEvent event)
{ {
SerialState *s = opaque; SerialState *s = opaque;
DPRINTF("event %x\n", event); DPRINTF("event %x\n", event);

View 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; sh_serial_state *s = opaque;
if (event == CHR_EVENT_BREAK) if (event == CHR_EVENT_BREAK)

View 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; Terminal3270 *t = opaque;
CcwDevice *ccw_dev = CCW_DEVICE(t); CcwDevice *ccw_dev = CCW_DEVICE(t);

View File

@ -145,7 +145,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
virtio_serial_write(port, buf, 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; VirtConsole *vcon = opaque;
VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(vcon); VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(vcon);

View File

@ -206,7 +206,7 @@ static int uart_can_rx(void *opaque)
return s->rx_fifo_len < sizeof(s->rx_fifo); 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)
{ {
} }

View File

@ -379,7 +379,7 @@ static void receive(void *opaque, const uint8_t *buf, int size)
handle_hw_op(ibe, hw_op); 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; IPMIBmcExtern *ibe = opaque;
IPMIInterface *s = ibe->parent.intf; IPMIInterface *s = ibe->parent.intf;

View File

@ -98,7 +98,7 @@ enum boston_plat_reg {
PLAT_SYS_CTL = 0x48, 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; BostonState *s = opaque;
if (event == CHR_EVENT_OPENED && !s->lcd_inited) { if (event == CHR_EVENT_OPENED && !s->lcd_inited) {

View File

@ -545,7 +545,7 @@ static void malta_fpga_reset(void *opaque)
snprintf(s->display_text, 9, " "); 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; MaltaFPGAState *s = opaque;

View 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. * Called by the char dev to supply special events to the HTIF console.
* Not used for HTIF. * Not used for HTIF.
*/ */
static void htif_event(void *opaque, int event) static void htif_event(void *opaque, QEMUChrEvent event)
{ {
} }

View File

@ -162,7 +162,7 @@ static int uart_can_rx(void *opaque)
return s->rx_fifo_len < sizeof(s->rx_fifo); 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)
{ {
} }

View 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; PassthruState *card = opaque;

View File

@ -461,7 +461,7 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size)
s->recv_used += 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; USBSerialState *s = opaque;

View File

@ -1354,7 +1354,7 @@ static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)
usbredirparser_do_write(dev->parser); 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; USBRedirDevice *dev = opaque;

View File

@ -4,7 +4,7 @@
#include "chardev/char.h" #include "chardev/char.h"
#include "qemu/main-loop.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); typedef int BackendChangeHandler(void *opaque);
/* This is the backend as seen by frontend, the actual backend is /* This is the backend as seen by frontend, the actual backend is

View File

@ -1322,7 +1322,7 @@ static void monitor_read(void *opaque, const uint8_t *buf, int size)
cur_mon = old_mon; cur_mon = old_mon;
} }
static void monitor_event(void *opaque, int event) static void monitor_event(void *opaque, QEMUChrEvent event)
{ {
Monitor *mon = opaque; Monitor *mon = opaque;
MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common); MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);

View File

@ -337,7 +337,7 @@ static QDict *qmp_greeting(MonitorQMP *mon)
ver, cap_list); ver, cap_list);
} }
static void monitor_qmp_event(void *opaque, int event) static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
{ {
QDict *data; QDict *data;
MonitorQMP *mon = opaque; MonitorQMP *mon = opaque;

View 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; NetFilterState *nf = opaque;
MirrorState *s = FILTER_REDIRECTOR(nf); MirrorState *s = FILTER_REDIRECTOR(nf);

View File

@ -218,7 +218,7 @@ static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
return TRUE; 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) 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; const char *name = opaque;
NetClientState *ncs[MAX_QUEUE_NUM]; NetClientState *ncs[MAX_QUEUE_NUM];

View File

@ -722,7 +722,7 @@ static int qtest_can_read(void *opaque)
return 1024; return 1024;
} }
static void qtest_event(void *opaque, int event) static void qtest_event(void *opaque, QEMUChrEvent event)
{ {
int i; int i;

View File

@ -54,7 +54,7 @@ static void fe_read(void *opaque, const uint8_t *buf, int size)
quit = true; quit = true;
} }
static void fe_event(void *opaque, int event) static void fe_event(void *opaque, QEMUChrEvent event)
{ {
FeHandler *h = opaque; FeHandler *h = opaque;
bool new_open_state; bool new_open_state;
@ -633,7 +633,7 @@ typedef struct {
static void static void
char_socket_event(void *opaque, int event) char_socket_event(void *opaque, QEMUChrEvent event)
{ {
CharSocketTestData *data = opaque; CharSocketTestData *data = opaque;
data->event = event; data->event = event;
@ -1006,7 +1006,7 @@ static void char_socket_client_test(gconstpointer opaque)
} }
static void static void
count_closed_event(void *opaque, int event) count_closed_event(void *opaque, QEMUChrEvent event)
{ {
int *count = opaque; int *count = opaque;
if (event == CHR_EVENT_CLOSED) { if (event == CHR_EVENT_CLOSED) {

View File

@ -499,7 +499,7 @@ static TestServer *test_server_new(const gchar *name)
return server; return server;
} }
static void chr_event(void *opaque, int event) static void chr_event(void *opaque, QEMUChrEvent event)
{ {
TestServer *s = opaque; TestServer *s = opaque;