[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 07/18] ui: rename cursor_{get->ref}, return it
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v2 07/18] ui: rename cursor_{get->ref}, return it |
Date: |
Fri, 10 Mar 2023 09:52:41 +0000 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
On Tue, Mar 07, 2023 at 03:56:26PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The naming is more conventional in QEMU code, and allows to simplify
> some code.
Nit-pick, this commit also changes the API design, so it
returns the input parameter, instead of void. This makes
sense as it simplifies usage, but please mentioned it in
the commit as this is more than just a rename commit.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/console.h | 2 +-
> ui/cursor.c | 3 ++-
> ui/dbus-listener.c | 3 +--
> ui/spice-display.c | 4 ++--
> ui/vnc.c | 3 +--
> 5 files changed, 7 insertions(+), 8 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 3efd1f6b82..0b01df947e 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -151,7 +151,7 @@ typedef struct QEMUCursor {
> } QEMUCursor;
>
> QEMUCursor *cursor_alloc(int width, int height);
> -void cursor_get(QEMUCursor *c);
> +QEMUCursor *cursor_ref(QEMUCursor *c);
> void cursor_unref(QEMUCursor *c);
> QEMUCursor *cursor_builtin_hidden(void);
> QEMUCursor *cursor_builtin_left_ptr(void);
> diff --git a/ui/cursor.c b/ui/cursor.c
> index 31b09bf058..6fe67990e2 100644
> --- a/ui/cursor.c
> +++ b/ui/cursor.c
> @@ -106,9 +106,10 @@ QEMUCursor *cursor_alloc(int width, int height)
> return c;
> }
>
> -void cursor_get(QEMUCursor *c)
> +QEMUCursor *cursor_ref(QEMUCursor *c)
> {
> c->refcount++;
> + return c;
> }
>
> void cursor_unref(QEMUCursor *c)
> diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
> index 906ab296ca..2e87ed7e9a 100644
> --- a/ui/dbus-listener.c
> +++ b/ui/dbus-listener.c
> @@ -339,14 +339,13 @@ static void dbus_cursor_define(DisplayChangeListener
> *dcl,
> DBusDisplayListener *ddl = container_of(dcl, DBusDisplayListener, dcl);
> GVariant *v_data = NULL;
>
> - cursor_get(c);
> v_data = g_variant_new_from_data(
> G_VARIANT_TYPE("ay"),
> c->data,
> c->width * c->height * 4,
> TRUE,
> (GDestroyNotify)cursor_unref,
> - c);
> + cursor_ref(c));
>
> qemu_dbus_display1_listener_call_cursor_define(
> ddl->proxy,
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 243a794638..5bee19a7f9 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -460,7 +460,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque)
> if (ssd->cursor) {
> QEMUCursor *c = ssd->cursor;
> assert(ssd->dcl.con);
> - cursor_get(c);
> + cursor_ref(c);
> qemu_mutex_unlock(&ssd->lock);
> dpy_cursor_define(ssd->dcl.con, c);
> qemu_mutex_lock(&ssd->lock);
> @@ -765,7 +765,7 @@ static void display_mouse_define(DisplayChangeListener
> *dcl,
> SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
>
> qemu_mutex_lock(&ssd->lock);
> - cursor_get(c);
> + cursor_ref(c);
> cursor_unref(ssd->cursor);
> ssd->cursor = c;
> ssd->hot_x = c->hot_x;
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 0bdcc3dfce..8aec5d751e 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -1032,8 +1032,7 @@ static void vnc_dpy_cursor_define(DisplayChangeListener
> *dcl,
> cursor_unref(vd->cursor);
> g_free(vd->cursor_mask);
>
> - vd->cursor = c;
> - cursor_get(vd->cursor);
> + vd->cursor = cursor_ref(vd->cursor);
> vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
> vd->cursor_mask = g_malloc0(vd->cursor_msize);
> cursor_get_mono_mask(c, 0, vd->cursor_mask);
> --
> 2.39.2
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [PATCH v2 02/18] ui/dbus: unregister clipboard on connection close, (continued)
- [PATCH v2 03/18] audio/dbus: there are no sender for p2p mode, marcandre . lureau, 2023/03/07
- [PATCH v2 04/18] ui/dbus: set mouse is-absolute during console creation, marcandre . lureau, 2023/03/07
- [PATCH v2 05/18] meson: ensure dbus-display generated code is built before other units, marcandre . lureau, 2023/03/07
- [PATCH v2 06/18] ui: rename cursor_{put->unref}, marcandre . lureau, 2023/03/07
- [PATCH v2 07/18] ui: rename cursor_{get->ref}, return it, marcandre . lureau, 2023/03/07
- Re: [PATCH v2 07/18] ui: rename cursor_{get->ref}, return it,
Daniel P . Berrangé <=
- [PATCH v2 08/18] ui: keep current cursor with QemuConsole, marcandre . lureau, 2023/03/07
- [PATCH v2 09/18] ui: set cursor upon listener registration, marcandre . lureau, 2023/03/07
- [PATCH v2 10/18] ui: set cursor position upon listener registration, marcandre . lureau, 2023/03/07
- [PATCH v2 11/18] ui/sdl: get the GL context from the window, marcandre . lureau, 2023/03/07
- [PATCH v2 13/18] ui/egl: print EGL error, helping debugging, marcandre . lureau, 2023/03/07