From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 1 Mar 2013 13:03:04 +0100
Subject: console: zap displaystate from dcl callbacks

Now that nobody depends on DisplayState in DisplayChangeListener
callbacks any more we can remove the parameter from all callbacks.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit bc2ed9704fff2c721e4056ab5281f0291718bfa6)
[BR: BSC#1026612 CVE-2017-2633 (infrastructure patch)]
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
 hw/qxl.c             |  5 +----
 include/ui/console.h | 10 +---------
 ui/cocoa.m           |  5 +----
 ui/console.c         | 18 +++++++++---------
 ui/curses.c          |  8 ++------
 ui/sdl.c             | 11 +++--------
 ui/spice-display.c   |  5 +----
 ui/vnc.c             |  4 ----
 8 files changed, 18 insertions(+), 48 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 5533c52431ced0174c84adc42a8a..53f78d797932dfaf94ea1aeb0387 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1867,7 +1867,6 @@ static void qxl_vm_change_state_handler(void *opaque, int running,
 /* display change listener */
 
 static void display_update(DisplayChangeListener *dcl,
-                           struct DisplayState *ds,
                            int x, int y, int w, int h)
 {
     if (qxl0->mode == QXL_MODE_VGA) {
@@ -1876,7 +1875,6 @@ static void display_update(DisplayChangeListener *dcl,
 }
 
 static void display_switch(DisplayChangeListener *dcl,
-                           struct DisplayState *ds,
                            struct DisplaySurface *surface)
 {
     if (qxl0->mode == QXL_MODE_VGA) {
@@ -1884,8 +1882,7 @@ static void display_switch(DisplayChangeListener *dcl,
     }
 }
 
-static void display_refresh(DisplayChangeListener *dcl,
-                            struct DisplayState *ds)
+static void display_refresh(DisplayChangeListener *dcl)
 {
     if (qxl0->mode == QXL_MODE_VGA) {
         qemu_spice_display_refresh(&qxl0->ssd);
diff --git a/include/ui/console.h b/include/ui/console.h
index 5d2a9cba5b54e066a6cfd1b73ac2..f7da4276b5449f3fb61553645a5a 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -150,30 +150,22 @@ void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
 typedef struct DisplayChangeListenerOps {
     const char *dpy_name;
 
-    void (*dpy_refresh)(DisplayChangeListener *dcl,
-                        struct DisplayState *s);
+    void (*dpy_refresh)(DisplayChangeListener *dcl);
 
     void (*dpy_gfx_update)(DisplayChangeListener *dcl,
-                           struct DisplayState *s,
                            int x, int y, int w, int h);
     void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
-                           struct DisplayState *s,
                            struct DisplaySurface *new_surface);
     void (*dpy_text_cursor)(DisplayChangeListener *dcl,
-                            struct DisplayState *s,
                             int x, int y);
     void (*dpy_text_resize)(DisplayChangeListener *dcl,
-                            struct DisplayState *s,
                             int w, int h);
     void (*dpy_text_update)(DisplayChangeListener *dcl,
-                            struct DisplayState *s,
                             int x, int y, int w, int h);
 
     void (*dpy_mouse_set)(DisplayChangeListener *dcl,
-                          struct DisplayState *s,
                           int x, int y, int on);
     void (*dpy_cursor_define)(DisplayChangeListener *dcl,
-                              struct DisplayState *s,
                               QEMUCursor *cursor);
 } DisplayChangeListenerOps;
 
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9a56fb89124aebef72585721c645..8e0eaa26019789ec3a1a08fefa6e 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -955,7 +955,6 @@ int main (int argc, const char * argv[]) {
 
 #pragma mark qemu
 static void cocoa_update(DisplayChangeListener *dcl,
-                         DisplayState *dontuse,
                          int x, int y, int w, int h)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_update\n");
@@ -974,7 +973,6 @@ static void cocoa_update(DisplayChangeListener *dcl,
 }
 
 static void cocoa_switch(DisplayChangeListener *dcl,
-                         DisplayState *dontuse,
                          DisplaySurface *surface)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
@@ -982,8 +980,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
     [cocoaView switchSurface:surface];
 }
 
-static void cocoa_refresh(DisplayChangeListener *dcl,
-                          DisplayState *dontuse)
+static void cocoa_refresh(DisplayChangeListener *dcl)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
 
diff --git a/ui/console.c b/ui/console.c
index 8673fe37384376b67c9ae61ba349..7f2118771e69ea5b867c6f9ad1ce 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1373,7 +1373,7 @@ void register_displaychangelistener(DisplayState *ds,
     QLIST_INSERT_HEAD(&ds->listeners, dcl, next);
     gui_setup_refresh(ds);
     if (dcl->ops->dpy_gfx_switch) {
-        dcl->ops->dpy_gfx_switch(dcl, ds, ds->surface);
+        dcl->ops->dpy_gfx_switch(dcl, ds->surface);
     }
 }
 
@@ -1400,7 +1400,7 @@ void dpy_gfx_update(DisplayState *s, int x, int y, int w, int h)
 
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_gfx_update) {
-            dcl->ops->dpy_gfx_update(dcl, s, x, y, w, h);
+            dcl->ops->dpy_gfx_update(dcl, x, y, w, h);
         }
     }
 }
@@ -1414,7 +1414,7 @@ void dpy_gfx_replace_surface(DisplayState *s,
     s->surface = surface;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_gfx_switch) {
-            dcl->ops->dpy_gfx_switch(dcl, s, surface);
+            dcl->ops->dpy_gfx_switch(dcl, surface);
         }
     }
     qemu_free_displaysurface(old_surface);
@@ -1425,7 +1425,7 @@ void dpy_refresh(DisplayState *s)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_refresh) {
-            dcl->ops->dpy_refresh(dcl, s);
+            dcl->ops->dpy_refresh(dcl);
         }
     }
 }
@@ -1435,7 +1435,7 @@ void dpy_text_cursor(struct DisplayState *s, int x, int y)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_text_cursor) {
-            dcl->ops->dpy_text_cursor(dcl, s, x, y);
+            dcl->ops->dpy_text_cursor(dcl, x, y);
         }
     }
 }
@@ -1445,7 +1445,7 @@ void dpy_text_update(DisplayState *s, int x, int y, int w, int h)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_text_update) {
-            dcl->ops->dpy_text_update(dcl, s, x, y, w, h);
+            dcl->ops->dpy_text_update(dcl, x, y, w, h);
         }
     }
 }
@@ -1455,7 +1455,7 @@ void dpy_text_resize(DisplayState *s, int w, int h)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_text_resize) {
-            dcl->ops->dpy_text_resize(dcl, s, w, h);
+            dcl->ops->dpy_text_resize(dcl, w, h);
         }
     }
 }
@@ -1465,7 +1465,7 @@ void dpy_mouse_set(struct DisplayState *s, int x, int y, int on)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_mouse_set) {
-            dcl->ops->dpy_mouse_set(dcl, s, x, y, on);
+            dcl->ops->dpy_mouse_set(dcl, x, y, on);
         }
     }
 }
@@ -1475,7 +1475,7 @@ void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor)
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_cursor_define) {
-            dcl->ops->dpy_cursor_define(dcl, s, cursor);
+            dcl->ops->dpy_cursor_define(dcl, cursor);
         }
     }
 }
diff --git a/ui/curses.c b/ui/curses.c
index ca9856ccef5c5c3f7cab7baf21d4..ff823073611b5368aa975fd1fcb4 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -42,7 +42,6 @@ static int width, height, gwidth, gheight, invalidate;
 static int px, py, sminx, sminy, smaxx, smaxy;
 
 static void curses_update(DisplayChangeListener *dcl,
-                          DisplayState *ds,
                           int x, int y, int w, int h)
 {
     chtype *line;
@@ -95,7 +94,6 @@ static void curses_calc_pad(void)
 }
 
 static void curses_resize(DisplayChangeListener *dcl,
-                          DisplayState *ds,
                           int width, int height)
 {
     if (width == gwidth && height == gheight) {
@@ -134,7 +132,6 @@ static void curses_winch_handler(int signum)
 #endif
 
 static void curses_cursor_position(DisplayChangeListener *dcl,
-                                   DisplayState *ds,
                                    int x, int y)
 {
     if (x >= 0) {
@@ -161,8 +158,7 @@ static void curses_cursor_position(DisplayChangeListener *dcl,
 
 static kbd_layout_t *kbd_layout = NULL;
 
-static void curses_refresh(DisplayChangeListener *dcl,
-                           DisplayState *ds)
+static void curses_refresh(DisplayChangeListener *dcl)
 {
     int chr, nextchr, keysym, keycode, keycode_alt;
 
@@ -195,7 +191,7 @@ static void curses_refresh(DisplayChangeListener *dcl,
             clear();
             refresh();
             curses_calc_pad();
-            curses_update(dcl, ds, 0, 0, width, height);
+            curses_update(dcl, 0, 0, width, height);
             continue;
         }
 #endif
diff --git a/ui/sdl.c b/ui/sdl.c
index 58f16bc63e0f4022af416bf5051d..8da05341bbf9526689f6315be1bc 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -61,7 +61,6 @@ static int scaling_active = 0;
 static Notifier mouse_mode_notifier;
 
 static void sdl_update(DisplayChangeListener *dcl,
-                       DisplayState *dontuse,
                        int x, int y, int w, int h)
 {
     //    printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
@@ -108,7 +107,6 @@ static void do_sdl_resize(int width, int height, int bpp)
 }
 
 static void sdl_switch(DisplayChangeListener *dcl,
-                       DisplayState *dontuse,
                        DisplaySurface *new_surface)
 {
 
@@ -523,7 +521,7 @@ static void handle_keydown(SDL_Event *ev)
         case 0x16: /* 'u' key on US keyboard */
             if (scaling_active) {
                 scaling_active = 0;
-                sdl_switch(dcl, NULL, NULL);
+                sdl_switch(dcl, NULL);
                 vga_hw_invalidate();
                 vga_hw_update();
             }
@@ -763,8 +761,7 @@ static void handle_activation(SDL_Event *ev)
     }
 }
 
-static void sdl_refresh(DisplayChangeListener *dcl,
-                        DisplayState *dontuse)
+static void sdl_refresh(DisplayChangeListener *dcl)
 {
     SDL_Event ev1, *ev = &ev1;
 
@@ -779,7 +776,7 @@ static void sdl_refresh(DisplayChangeListener *dcl,
     while (SDL_PollEvent(ev)) {
         switch (ev->type) {
         case SDL_VIDEOEXPOSE:
-            sdl_update(dcl, dontuse, 0, 0, real_screen->w, real_screen->h);
+            sdl_update(dcl, 0, 0, real_screen->w, real_screen->h);
             break;
         case SDL_KEYDOWN:
             handle_keydown(ev);
@@ -815,7 +812,6 @@ static void sdl_refresh(DisplayChangeListener *dcl,
 }
 
 static void sdl_mouse_warp(DisplayChangeListener *dcl,
-                           DisplayState *ds,
                            int x, int y, int on)
 {
     if (on) {
@@ -833,7 +829,6 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
 }
 
 static void sdl_mouse_define(DisplayChangeListener *dcl,
-                             DisplayState *ds,
                              QEMUCursor *c)
 {
     uint8_t *image, *mask;
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 2c4b28d2b9243fbf917b50c07f19..f50513f52a4052b7b1890a9668c6 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -585,21 +585,18 @@ static const QXLInterface dpy_interface = {
 static SimpleSpiceDisplay sdpy;
 
 static void display_update(DisplayChangeListener *dcl,
-                           struct DisplayState *ds,
                            int x, int y, int w, int h)
 {
     qemu_spice_display_update(&sdpy, x, y, w, h);
 }
 
 static void display_switch(DisplayChangeListener *dcl,
-                           struct DisplayState *ds,
                            struct DisplaySurface *surface)
 {
     qemu_spice_display_switch(&sdpy, surface);
 }
 
-static void display_refresh(DisplayChangeListener *dcl,
-                            struct DisplayState *ds)
+static void display_refresh(DisplayChangeListener *dcl)
 {
     qemu_spice_display_refresh(&sdpy);
 }
diff --git a/ui/vnc.c b/ui/vnc.c
index 60132643dda1a20cef8d24d6e9e6..db05741ba2a543ae1110a140da29 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -430,7 +430,6 @@ static void vnc_refresh(void *opaque);
 static int vnc_refresh_server_surface(VncDisplay *vd);
 
 static void vnc_dpy_update(DisplayChangeListener *dcl,
-                           DisplayState *ds,
                            int x, int y, int w, int h)
 {
     int i;
@@ -575,7 +574,6 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
 }
 
 static void vnc_dpy_switch(DisplayChangeListener *dcl,
-                           DisplayState *dontuse,
                            DisplaySurface *surface)
 {
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
@@ -726,7 +724,6 @@ int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
 }
 
 static void vnc_mouse_set(DisplayChangeListener *dcl,
-                          DisplayState *dontuse,
                           int x, int y, int visible)
 {
     /* can we ask the client(s) to move the pointer ??? */
@@ -754,7 +751,6 @@ static int vnc_cursor_define(VncState *vs)
 }
 
 static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
-                                  DisplayState *dontuse,
                                   QEMUCursor *c)
 {
     VncDisplay *vd = vnc_display;
