diff mbox series

ui/input: Constify QemuInputHandler structure

Message ID 20231017131251.43708-1-philmd@linaro.org
State New
Headers show
Series ui/input: Constify QemuInputHandler structure | expand

Commit Message

Philippe Mathieu-Daudé Oct. 17, 2023, 1:12 p.m. UTC
Access to QemuInputHandlerState::handler are read-only.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/virtio/virtio-input.h | 2 +-
 include/ui/input.h               | 2 +-
 chardev/msmouse.c                | 2 +-
 chardev/wctablet.c               | 2 +-
 hw/char/escc.c                   | 2 +-
 hw/display/xenfb.c               | 6 +++---
 hw/input/adb-kbd.c               | 2 +-
 hw/input/hid.c                   | 6 +++---
 hw/input/ps2.c                   | 4 ++--
 hw/input/virtio-input-hid.c      | 8 ++++----
 ui/input-legacy.c                | 2 +-
 ui/input.c                       | 4 ++--
 ui/vdagent.c                     | 2 +-
 13 files changed, 22 insertions(+), 22 deletions(-)

Comments

Marc-André Lureau Oct. 17, 2023, 1:32 p.m. UTC | #1
On Tue, Oct 17, 2023 at 5:13 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Access to QemuInputHandlerState::handler are read-only.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  include/hw/virtio/virtio-input.h | 2 +-
>  include/ui/input.h               | 2 +-
>  chardev/msmouse.c                | 2 +-
>  chardev/wctablet.c               | 2 +-
>  hw/char/escc.c                   | 2 +-
>  hw/display/xenfb.c               | 6 +++---
>  hw/input/adb-kbd.c               | 2 +-
>  hw/input/hid.c                   | 6 +++---
>  hw/input/ps2.c                   | 4 ++--
>  hw/input/virtio-input-hid.c      | 8 ++++----
>  ui/input-legacy.c                | 2 +-
>  ui/input.c                       | 4 ++--
>  ui/vdagent.c                     | 2 +-
>  13 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
> index 08f1591424..a6c9703644 100644
> --- a/include/hw/virtio/virtio-input.h
> +++ b/include/hw/virtio/virtio-input.h
> @@ -84,7 +84,7 @@ struct VirtIOInputHID {
>      VirtIOInput                       parent_obj;
>      char                              *display;
>      uint32_t                          head;
> -    QemuInputHandler                  *handler;
> +    const QemuInputHandler            *handler;
>      QemuInputHandlerState             *hs;
>      int                               ledstate;
>      bool                              wheel_axis;
> diff --git a/include/ui/input.h b/include/ui/input.h
> index 24d8e4579e..8f9aac562e 100644
> --- a/include/ui/input.h
> +++ b/include/ui/input.h
> @@ -30,7 +30,7 @@ struct QemuInputHandler {
>  };
>
>  QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
> -                                                   QemuInputHandler *handler);
> +                                            const QemuInputHandler *handler);
>  void qemu_input_handler_activate(QemuInputHandlerState *s);
>  void qemu_input_handler_deactivate(QemuInputHandlerState *s);
>  void qemu_input_handler_unregister(QemuInputHandlerState *s);
> diff --git a/chardev/msmouse.c b/chardev/msmouse.c
> index ab8fe981d6..a774c397b4 100644
> --- a/chardev/msmouse.c
> +++ b/chardev/msmouse.c
> @@ -171,7 +171,7 @@ static int msmouse_chr_write(struct Chardev *s, const uint8_t *buf, int len)
>      return len;
>  }
>
> -static QemuInputHandler msmouse_handler = {
> +static const QemuInputHandler msmouse_handler = {
>      .name  = "QEMU Microsoft Mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>      .event = msmouse_input_event,
> diff --git a/chardev/wctablet.c b/chardev/wctablet.c
> index 43bdf6b608..f4008bf35b 100644
> --- a/chardev/wctablet.c
> +++ b/chardev/wctablet.c
> @@ -178,7 +178,7 @@ static void wctablet_input_sync(DeviceState *dev)
>      }
>  }
>
> -static QemuInputHandler wctablet_handler = {
> +static const QemuInputHandler wctablet_handler = {
>      .name  = "QEMU Wacom Pen Tablet",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>      .event = wctablet_input_event,
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 4be66053c1..48b30ee760 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -845,7 +845,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
>      put_queue(s, keycode);
>  }
>
> -static QemuInputHandler sunkbd_handler = {
> +static const QemuInputHandler sunkbd_handler = {
>      .name  = "sun keyboard",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = sunkbd_handle_event,
> diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> index 0074a9b6f8..b2130a0d70 100644
> --- a/hw/display/xenfb.c
> +++ b/hw/display/xenfb.c
> @@ -321,20 +321,20 @@ static void xenfb_mouse_sync(DeviceState *dev)
>      xenfb->wheel = 0;
>  }
>
> -static QemuInputHandler xenfb_keyboard = {
> +static const QemuInputHandler xenfb_keyboard = {
>      .name  = "Xen PV Keyboard",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = xenfb_key_event,
>  };
>
> -static QemuInputHandler xenfb_abs_mouse = {
> +static const QemuInputHandler xenfb_abs_mouse = {
>      .name  = "Xen PV Mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>      .event = xenfb_mouse_event,
>      .sync  = xenfb_mouse_sync,
>  };
>
> -static QemuInputHandler xenfb_rel_mouse = {
> +static const QemuInputHandler xenfb_rel_mouse = {
>      .name  = "Xen PV Mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>      .event = xenfb_mouse_event,
> diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
> index a9088c910c..e21edf9acd 100644
> --- a/hw/input/adb-kbd.c
> +++ b/hw/input/adb-kbd.c
> @@ -355,7 +355,7 @@ static void adb_kbd_reset(DeviceState *dev)
>      s->count = 0;
>  }
>
> -static QemuInputHandler adb_keyboard_handler = {
> +static const QemuInputHandler adb_keyboard_handler = {
>      .name  = "QEMU ADB Keyboard",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = adb_keyboard_event,
> diff --git a/hw/input/hid.c b/hw/input/hid.c
> index a9c7dd1ce1..b8e85374ca 100644
> --- a/hw/input/hid.c
> +++ b/hw/input/hid.c
> @@ -510,20 +510,20 @@ void hid_free(HIDState *hs)
>      hid_del_idle_timer(hs);
>  }
>
> -static QemuInputHandler hid_keyboard_handler = {
> +static const QemuInputHandler hid_keyboard_handler = {
>      .name  = "QEMU HID Keyboard",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = hid_keyboard_event,
>  };
>
> -static QemuInputHandler hid_mouse_handler = {
> +static const QemuInputHandler hid_mouse_handler = {
>      .name  = "QEMU HID Mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>      .event = hid_pointer_event,
>      .sync  = hid_pointer_sync,
>  };
>
> -static QemuInputHandler hid_tablet_handler = {
> +static const QemuInputHandler hid_tablet_handler = {
>      .name  = "QEMU HID Tablet",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>      .event = hid_pointer_event,
> diff --git a/hw/input/ps2.c b/hw/input/ps2.c
> index 45af76a837..c8fd23cf36 100644
> --- a/hw/input/ps2.c
> +++ b/hw/input/ps2.c
> @@ -1231,7 +1231,7 @@ static const VMStateDescription vmstate_ps2_mouse = {
>      }
>  };
>
> -static QemuInputHandler ps2_keyboard_handler = {
> +static const QemuInputHandler ps2_keyboard_handler = {
>      .name  = "QEMU PS/2 Keyboard",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = ps2_keyboard_event,
> @@ -1242,7 +1242,7 @@ static void ps2_kbd_realize(DeviceState *dev, Error **errp)
>      qemu_input_handler_register(dev, &ps2_keyboard_handler);
>  }
>
> -static QemuInputHandler ps2_mouse_handler = {
> +static const QemuInputHandler ps2_mouse_handler = {
>      .name  = "QEMU PS/2 Mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>      .event = ps2_mouse_event,
> diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
> index 7053ad72d4..45e4d4c75d 100644
> --- a/hw/input/virtio-input-hid.c
> +++ b/hw/input/virtio-input-hid.c
> @@ -265,7 +265,7 @@ static const TypeInfo virtio_input_hid_info = {
>
>  /* ----------------------------------------------------------------- */
>
> -static QemuInputHandler virtio_keyboard_handler = {
> +static const QemuInputHandler virtio_keyboard_handler = {
>      .name  = VIRTIO_ID_NAME_KEYBOARD,
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = virtio_input_handle_event,
> @@ -322,7 +322,7 @@ static const TypeInfo virtio_keyboard_info = {
>
>  /* ----------------------------------------------------------------- */
>
> -static QemuInputHandler virtio_mouse_handler = {
> +static const QemuInputHandler virtio_mouse_handler = {
>      .name  = VIRTIO_ID_NAME_MOUSE,
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>      .event = virtio_input_handle_event,
> @@ -416,7 +416,7 @@ static const TypeInfo virtio_mouse_info = {
>
>  /* ----------------------------------------------------------------- */
>
> -static QemuInputHandler virtio_tablet_handler = {
> +static const QemuInputHandler virtio_tablet_handler = {
>      .name  = VIRTIO_ID_NAME_TABLET,
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>      .event = virtio_input_handle_event,
> @@ -541,7 +541,7 @@ static const TypeInfo virtio_tablet_info = {
>
>  /* ----------------------------------------------------------------- */
>
> -static QemuInputHandler virtio_multitouch_handler = {
> +static const QemuInputHandler virtio_multitouch_handler = {
>      .name  = VIRTIO_ID_NAME_MULTITOUCH,
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_MTT,
>      .event = virtio_input_handle_event,
> diff --git a/ui/input-legacy.c b/ui/input-legacy.c
> index 46ea74e44d..210ae5eaca 100644
> --- a/ui/input-legacy.c
> +++ b/ui/input-legacy.c
> @@ -127,7 +127,7 @@ static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
>      }
>  }
>
> -static QemuInputHandler legacy_kbd_handler = {
> +static const QemuInputHandler legacy_kbd_handler = {
>      .name  = "legacy-kbd",
>      .mask  = INPUT_EVENT_MASK_KEY,
>      .event = legacy_kbd_event,
> diff --git a/ui/input.c b/ui/input.c
> index cbe8573c5c..dc745860f4 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -10,7 +10,7 @@
>
>  struct QemuInputHandlerState {
>      DeviceState       *dev;
> -    QemuInputHandler  *handler;
> +    const QemuInputHandler *handler;
>      int               id;
>      int               events;
>      QemuConsole       *con;
> @@ -46,7 +46,7 @@ static uint32_t queue_count;
>  static uint32_t queue_limit = 1024;
>
>  QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
> -                                                   QemuInputHandler *handler)
> +                                            const QemuInputHandler *handler)
>  {
>      QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
>      static int id = 1;
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index 00d36a8677..706d6d97bd 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -297,7 +297,7 @@ static void vdagent_pointer_sync(DeviceState *dev)
>      }
>  }
>
> -static QemuInputHandler vdagent_mouse_handler = {
> +static const QemuInputHandler vdagent_mouse_handler = {
>      .name  = "vdagent mouse",
>      .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>      .event = vdagent_pointer_event,
> --
> 2.41.0
>
Mark Cave-Ayland Oct. 17, 2023, 8:03 p.m. UTC | #2
On 17/10/2023 14:12, Philippe Mathieu-Daudé wrote:

> Access to QemuInputHandlerState::handler are read-only.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/virtio/virtio-input.h | 2 +-
>   include/ui/input.h               | 2 +-
>   chardev/msmouse.c                | 2 +-
>   chardev/wctablet.c               | 2 +-
>   hw/char/escc.c                   | 2 +-
>   hw/display/xenfb.c               | 6 +++---
>   hw/input/adb-kbd.c               | 2 +-
>   hw/input/hid.c                   | 6 +++---
>   hw/input/ps2.c                   | 4 ++--
>   hw/input/virtio-input-hid.c      | 8 ++++----
>   ui/input-legacy.c                | 2 +-
>   ui/input.c                       | 4 ++--
>   ui/vdagent.c                     | 2 +-
>   13 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
> index 08f1591424..a6c9703644 100644
> --- a/include/hw/virtio/virtio-input.h
> +++ b/include/hw/virtio/virtio-input.h
> @@ -84,7 +84,7 @@ struct VirtIOInputHID {
>       VirtIOInput                       parent_obj;
>       char                              *display;
>       uint32_t                          head;
> -    QemuInputHandler                  *handler;
> +    const QemuInputHandler            *handler;
>       QemuInputHandlerState             *hs;
>       int                               ledstate;
>       bool                              wheel_axis;
> diff --git a/include/ui/input.h b/include/ui/input.h
> index 24d8e4579e..8f9aac562e 100644
> --- a/include/ui/input.h
> +++ b/include/ui/input.h
> @@ -30,7 +30,7 @@ struct QemuInputHandler {
>   };
>   
>   QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
> -                                                   QemuInputHandler *handler);
> +                                            const QemuInputHandler *handler);
>   void qemu_input_handler_activate(QemuInputHandlerState *s);
>   void qemu_input_handler_deactivate(QemuInputHandlerState *s);
>   void qemu_input_handler_unregister(QemuInputHandlerState *s);
> diff --git a/chardev/msmouse.c b/chardev/msmouse.c
> index ab8fe981d6..a774c397b4 100644
> --- a/chardev/msmouse.c
> +++ b/chardev/msmouse.c
> @@ -171,7 +171,7 @@ static int msmouse_chr_write(struct Chardev *s, const uint8_t *buf, int len)
>       return len;
>   }
>   
> -static QemuInputHandler msmouse_handler = {
> +static const QemuInputHandler msmouse_handler = {
>       .name  = "QEMU Microsoft Mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>       .event = msmouse_input_event,
> diff --git a/chardev/wctablet.c b/chardev/wctablet.c
> index 43bdf6b608..f4008bf35b 100644
> --- a/chardev/wctablet.c
> +++ b/chardev/wctablet.c
> @@ -178,7 +178,7 @@ static void wctablet_input_sync(DeviceState *dev)
>       }
>   }
>   
> -static QemuInputHandler wctablet_handler = {
> +static const QemuInputHandler wctablet_handler = {
>       .name  = "QEMU Wacom Pen Tablet",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>       .event = wctablet_input_event,
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 4be66053c1..48b30ee760 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -845,7 +845,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
>       put_queue(s, keycode);
>   }
>   
> -static QemuInputHandler sunkbd_handler = {
> +static const QemuInputHandler sunkbd_handler = {
>       .name  = "sun keyboard",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = sunkbd_handle_event,
> diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> index 0074a9b6f8..b2130a0d70 100644
> --- a/hw/display/xenfb.c
> +++ b/hw/display/xenfb.c
> @@ -321,20 +321,20 @@ static void xenfb_mouse_sync(DeviceState *dev)
>       xenfb->wheel = 0;
>   }
>   
> -static QemuInputHandler xenfb_keyboard = {
> +static const QemuInputHandler xenfb_keyboard = {
>       .name  = "Xen PV Keyboard",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = xenfb_key_event,
>   };
>   
> -static QemuInputHandler xenfb_abs_mouse = {
> +static const QemuInputHandler xenfb_abs_mouse = {
>       .name  = "Xen PV Mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>       .event = xenfb_mouse_event,
>       .sync  = xenfb_mouse_sync,
>   };
>   
> -static QemuInputHandler xenfb_rel_mouse = {
> +static const QemuInputHandler xenfb_rel_mouse = {
>       .name  = "Xen PV Mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>       .event = xenfb_mouse_event,
> diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
> index a9088c910c..e21edf9acd 100644
> --- a/hw/input/adb-kbd.c
> +++ b/hw/input/adb-kbd.c
> @@ -355,7 +355,7 @@ static void adb_kbd_reset(DeviceState *dev)
>       s->count = 0;
>   }
>   
> -static QemuInputHandler adb_keyboard_handler = {
> +static const QemuInputHandler adb_keyboard_handler = {
>       .name  = "QEMU ADB Keyboard",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = adb_keyboard_event,
> diff --git a/hw/input/hid.c b/hw/input/hid.c
> index a9c7dd1ce1..b8e85374ca 100644
> --- a/hw/input/hid.c
> +++ b/hw/input/hid.c
> @@ -510,20 +510,20 @@ void hid_free(HIDState *hs)
>       hid_del_idle_timer(hs);
>   }
>   
> -static QemuInputHandler hid_keyboard_handler = {
> +static const QemuInputHandler hid_keyboard_handler = {
>       .name  = "QEMU HID Keyboard",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = hid_keyboard_event,
>   };
>   
> -static QemuInputHandler hid_mouse_handler = {
> +static const QemuInputHandler hid_mouse_handler = {
>       .name  = "QEMU HID Mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>       .event = hid_pointer_event,
>       .sync  = hid_pointer_sync,
>   };
>   
> -static QemuInputHandler hid_tablet_handler = {
> +static const QemuInputHandler hid_tablet_handler = {
>       .name  = "QEMU HID Tablet",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>       .event = hid_pointer_event,
> diff --git a/hw/input/ps2.c b/hw/input/ps2.c
> index 45af76a837..c8fd23cf36 100644
> --- a/hw/input/ps2.c
> +++ b/hw/input/ps2.c
> @@ -1231,7 +1231,7 @@ static const VMStateDescription vmstate_ps2_mouse = {
>       }
>   };
>   
> -static QemuInputHandler ps2_keyboard_handler = {
> +static const QemuInputHandler ps2_keyboard_handler = {
>       .name  = "QEMU PS/2 Keyboard",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = ps2_keyboard_event,
> @@ -1242,7 +1242,7 @@ static void ps2_kbd_realize(DeviceState *dev, Error **errp)
>       qemu_input_handler_register(dev, &ps2_keyboard_handler);
>   }
>   
> -static QemuInputHandler ps2_mouse_handler = {
> +static const QemuInputHandler ps2_mouse_handler = {
>       .name  = "QEMU PS/2 Mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>       .event = ps2_mouse_event,
> diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
> index 7053ad72d4..45e4d4c75d 100644
> --- a/hw/input/virtio-input-hid.c
> +++ b/hw/input/virtio-input-hid.c
> @@ -265,7 +265,7 @@ static const TypeInfo virtio_input_hid_info = {
>   
>   /* ----------------------------------------------------------------- */
>   
> -static QemuInputHandler virtio_keyboard_handler = {
> +static const QemuInputHandler virtio_keyboard_handler = {
>       .name  = VIRTIO_ID_NAME_KEYBOARD,
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = virtio_input_handle_event,
> @@ -322,7 +322,7 @@ static const TypeInfo virtio_keyboard_info = {
>   
>   /* ----------------------------------------------------------------- */
>   
> -static QemuInputHandler virtio_mouse_handler = {
> +static const QemuInputHandler virtio_mouse_handler = {
>       .name  = VIRTIO_ID_NAME_MOUSE,
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
>       .event = virtio_input_handle_event,
> @@ -416,7 +416,7 @@ static const TypeInfo virtio_mouse_info = {
>   
>   /* ----------------------------------------------------------------- */
>   
> -static QemuInputHandler virtio_tablet_handler = {
> +static const QemuInputHandler virtio_tablet_handler = {
>       .name  = VIRTIO_ID_NAME_TABLET,
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>       .event = virtio_input_handle_event,
> @@ -541,7 +541,7 @@ static const TypeInfo virtio_tablet_info = {
>   
>   /* ----------------------------------------------------------------- */
>   
> -static QemuInputHandler virtio_multitouch_handler = {
> +static const QemuInputHandler virtio_multitouch_handler = {
>       .name  = VIRTIO_ID_NAME_MULTITOUCH,
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_MTT,
>       .event = virtio_input_handle_event,
> diff --git a/ui/input-legacy.c b/ui/input-legacy.c
> index 46ea74e44d..210ae5eaca 100644
> --- a/ui/input-legacy.c
> +++ b/ui/input-legacy.c
> @@ -127,7 +127,7 @@ static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
>       }
>   }
>   
> -static QemuInputHandler legacy_kbd_handler = {
> +static const QemuInputHandler legacy_kbd_handler = {
>       .name  = "legacy-kbd",
>       .mask  = INPUT_EVENT_MASK_KEY,
>       .event = legacy_kbd_event,
> diff --git a/ui/input.c b/ui/input.c
> index cbe8573c5c..dc745860f4 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -10,7 +10,7 @@
>   
>   struct QemuInputHandlerState {
>       DeviceState       *dev;
> -    QemuInputHandler  *handler;
> +    const QemuInputHandler *handler;
>       int               id;
>       int               events;
>       QemuConsole       *con;
> @@ -46,7 +46,7 @@ static uint32_t queue_count;
>   static uint32_t queue_limit = 1024;
>   
>   QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
> -                                                   QemuInputHandler *handler)
> +                                            const QemuInputHandler *handler)
>   {
>       QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
>       static int id = 1;
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index 00d36a8677..706d6d97bd 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -297,7 +297,7 @@ static void vdagent_pointer_sync(DeviceState *dev)
>       }
>   }
>   
> -static QemuInputHandler vdagent_mouse_handler = {
> +static const QemuInputHandler vdagent_mouse_handler = {
>       .name  = "vdagent mouse",
>       .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
>       .event = vdagent_pointer_event,

Looks mostly harmless to me:

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
Philippe Mathieu-Daudé Oct. 19, 2023, 9:41 p.m. UTC | #3
On 17/10/23 15:12, Philippe Mathieu-Daudé wrote:
> Access to QemuInputHandlerState::handler are read-only.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/virtio/virtio-input.h | 2 +-
>   include/ui/input.h               | 2 +-
>   chardev/msmouse.c                | 2 +-
>   chardev/wctablet.c               | 2 +-
>   hw/char/escc.c                   | 2 +-
>   hw/display/xenfb.c               | 6 +++---
>   hw/input/adb-kbd.c               | 2 +-
>   hw/input/hid.c                   | 6 +++---
>   hw/input/ps2.c                   | 4 ++--
>   hw/input/virtio-input-hid.c      | 8 ++++----
>   ui/input-legacy.c                | 2 +-
>   ui/input.c                       | 4 ++--
>   ui/vdagent.c                     | 2 +-
>   13 files changed, 22 insertions(+), 22 deletions(-)

Patch queued to hw-misc.
diff mbox series

Patch

diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
index 08f1591424..a6c9703644 100644
--- a/include/hw/virtio/virtio-input.h
+++ b/include/hw/virtio/virtio-input.h
@@ -84,7 +84,7 @@  struct VirtIOInputHID {
     VirtIOInput                       parent_obj;
     char                              *display;
     uint32_t                          head;
-    QemuInputHandler                  *handler;
+    const QemuInputHandler            *handler;
     QemuInputHandlerState             *hs;
     int                               ledstate;
     bool                              wheel_axis;
diff --git a/include/ui/input.h b/include/ui/input.h
index 24d8e4579e..8f9aac562e 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -30,7 +30,7 @@  struct QemuInputHandler {
 };
 
 QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
-                                                   QemuInputHandler *handler);
+                                            const QemuInputHandler *handler);
 void qemu_input_handler_activate(QemuInputHandlerState *s);
 void qemu_input_handler_deactivate(QemuInputHandlerState *s);
 void qemu_input_handler_unregister(QemuInputHandlerState *s);
diff --git a/chardev/msmouse.c b/chardev/msmouse.c
index ab8fe981d6..a774c397b4 100644
--- a/chardev/msmouse.c
+++ b/chardev/msmouse.c
@@ -171,7 +171,7 @@  static int msmouse_chr_write(struct Chardev *s, const uint8_t *buf, int len)
     return len;
 }
 
-static QemuInputHandler msmouse_handler = {
+static const QemuInputHandler msmouse_handler = {
     .name  = "QEMU Microsoft Mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
     .event = msmouse_input_event,
diff --git a/chardev/wctablet.c b/chardev/wctablet.c
index 43bdf6b608..f4008bf35b 100644
--- a/chardev/wctablet.c
+++ b/chardev/wctablet.c
@@ -178,7 +178,7 @@  static void wctablet_input_sync(DeviceState *dev)
     }
 }
 
-static QemuInputHandler wctablet_handler = {
+static const QemuInputHandler wctablet_handler = {
     .name  = "QEMU Wacom Pen Tablet",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
     .event = wctablet_input_event,
diff --git a/hw/char/escc.c b/hw/char/escc.c
index 4be66053c1..48b30ee760 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -845,7 +845,7 @@  static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
     put_queue(s, keycode);
 }
 
-static QemuInputHandler sunkbd_handler = {
+static const QemuInputHandler sunkbd_handler = {
     .name  = "sun keyboard",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = sunkbd_handle_event,
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 0074a9b6f8..b2130a0d70 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -321,20 +321,20 @@  static void xenfb_mouse_sync(DeviceState *dev)
     xenfb->wheel = 0;
 }
 
-static QemuInputHandler xenfb_keyboard = {
+static const QemuInputHandler xenfb_keyboard = {
     .name  = "Xen PV Keyboard",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = xenfb_key_event,
 };
 
-static QemuInputHandler xenfb_abs_mouse = {
+static const QemuInputHandler xenfb_abs_mouse = {
     .name  = "Xen PV Mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
     .event = xenfb_mouse_event,
     .sync  = xenfb_mouse_sync,
 };
 
-static QemuInputHandler xenfb_rel_mouse = {
+static const QemuInputHandler xenfb_rel_mouse = {
     .name  = "Xen PV Mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
     .event = xenfb_mouse_event,
diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
index a9088c910c..e21edf9acd 100644
--- a/hw/input/adb-kbd.c
+++ b/hw/input/adb-kbd.c
@@ -355,7 +355,7 @@  static void adb_kbd_reset(DeviceState *dev)
     s->count = 0;
 }
 
-static QemuInputHandler adb_keyboard_handler = {
+static const QemuInputHandler adb_keyboard_handler = {
     .name  = "QEMU ADB Keyboard",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = adb_keyboard_event,
diff --git a/hw/input/hid.c b/hw/input/hid.c
index a9c7dd1ce1..b8e85374ca 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -510,20 +510,20 @@  void hid_free(HIDState *hs)
     hid_del_idle_timer(hs);
 }
 
-static QemuInputHandler hid_keyboard_handler = {
+static const QemuInputHandler hid_keyboard_handler = {
     .name  = "QEMU HID Keyboard",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = hid_keyboard_event,
 };
 
-static QemuInputHandler hid_mouse_handler = {
+static const QemuInputHandler hid_mouse_handler = {
     .name  = "QEMU HID Mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
     .event = hid_pointer_event,
     .sync  = hid_pointer_sync,
 };
 
-static QemuInputHandler hid_tablet_handler = {
+static const QemuInputHandler hid_tablet_handler = {
     .name  = "QEMU HID Tablet",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
     .event = hid_pointer_event,
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 45af76a837..c8fd23cf36 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -1231,7 +1231,7 @@  static const VMStateDescription vmstate_ps2_mouse = {
     }
 };
 
-static QemuInputHandler ps2_keyboard_handler = {
+static const QemuInputHandler ps2_keyboard_handler = {
     .name  = "QEMU PS/2 Keyboard",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = ps2_keyboard_event,
@@ -1242,7 +1242,7 @@  static void ps2_kbd_realize(DeviceState *dev, Error **errp)
     qemu_input_handler_register(dev, &ps2_keyboard_handler);
 }
 
-static QemuInputHandler ps2_mouse_handler = {
+static const QemuInputHandler ps2_mouse_handler = {
     .name  = "QEMU PS/2 Mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
     .event = ps2_mouse_event,
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 7053ad72d4..45e4d4c75d 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -265,7 +265,7 @@  static const TypeInfo virtio_input_hid_info = {
 
 /* ----------------------------------------------------------------- */
 
-static QemuInputHandler virtio_keyboard_handler = {
+static const QemuInputHandler virtio_keyboard_handler = {
     .name  = VIRTIO_ID_NAME_KEYBOARD,
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = virtio_input_handle_event,
@@ -322,7 +322,7 @@  static const TypeInfo virtio_keyboard_info = {
 
 /* ----------------------------------------------------------------- */
 
-static QemuInputHandler virtio_mouse_handler = {
+static const QemuInputHandler virtio_mouse_handler = {
     .name  = VIRTIO_ID_NAME_MOUSE,
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
     .event = virtio_input_handle_event,
@@ -416,7 +416,7 @@  static const TypeInfo virtio_mouse_info = {
 
 /* ----------------------------------------------------------------- */
 
-static QemuInputHandler virtio_tablet_handler = {
+static const QemuInputHandler virtio_tablet_handler = {
     .name  = VIRTIO_ID_NAME_TABLET,
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
     .event = virtio_input_handle_event,
@@ -541,7 +541,7 @@  static const TypeInfo virtio_tablet_info = {
 
 /* ----------------------------------------------------------------- */
 
-static QemuInputHandler virtio_multitouch_handler = {
+static const QemuInputHandler virtio_multitouch_handler = {
     .name  = VIRTIO_ID_NAME_MULTITOUCH,
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_MTT,
     .event = virtio_input_handle_event,
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 46ea74e44d..210ae5eaca 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -127,7 +127,7 @@  static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
     }
 }
 
-static QemuInputHandler legacy_kbd_handler = {
+static const QemuInputHandler legacy_kbd_handler = {
     .name  = "legacy-kbd",
     .mask  = INPUT_EVENT_MASK_KEY,
     .event = legacy_kbd_event,
diff --git a/ui/input.c b/ui/input.c
index cbe8573c5c..dc745860f4 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -10,7 +10,7 @@ 
 
 struct QemuInputHandlerState {
     DeviceState       *dev;
-    QemuInputHandler  *handler;
+    const QemuInputHandler *handler;
     int               id;
     int               events;
     QemuConsole       *con;
@@ -46,7 +46,7 @@  static uint32_t queue_count;
 static uint32_t queue_limit = 1024;
 
 QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
-                                                   QemuInputHandler *handler)
+                                            const QemuInputHandler *handler)
 {
     QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
     static int id = 1;
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 00d36a8677..706d6d97bd 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -297,7 +297,7 @@  static void vdagent_pointer_sync(DeviceState *dev)
     }
 }
 
-static QemuInputHandler vdagent_mouse_handler = {
+static const QemuInputHandler vdagent_mouse_handler = {
     .name  = "vdagent mouse",
     .mask  = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_ABS,
     .event = vdagent_pointer_event,