ui/vnc: use RFB wire types for client message handlers
Use exact-width unsigned types for the static functions that process RFB client messages, matching the types returned by read_u8(), read_u16(), and read_u32(): - set_pixel_format: uint8_t/uint16_t for pixel format fields - pointer_event: uint8_t button_mask, uint16_t x/y - key_event/ext_key_event: bool down, uint32_t sym/keycode - do_key_event: uint32_t sym - framebuffer_update_request: uint8_t incremental, uint16_t x/y/w/h Drop needless declarations. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Jul 6, 2026 at 14:52 UTC
3162692a3b67603e2b01f0c6441daa682acd6164
1 file changed
+17
-22
ui/vnc.c
+17
-22
@@ -608,15 +608,7 @@ bool vnc_display_reload_certs(const char *id, Error **errp)
608
3) resolutions > 1024
609
*/
610
611
-static int vnc_update_client(VncState *vs, int has_dirty);
612
-static void vnc_disconnect_start(VncState *vs);
613
-
611
static void vnc_colordepth(VncState *vs);
615
-static void framebuffer_update_request(VncState *vs, int incremental,
616
- int x_position, int y_position,
617
- int w, int h);
618
-static void vnc_refresh(DisplayChangeListener *dcl);
619
-static int vnc_refresh_server_surface(VncDisplay *vd);
612
613
static int vnc_width(VncDisplay *vd)
614
{
@@ -1763,7 +1755,8 @@ static void check_pointer_type_change(Notifier *notifier, void *data)
1755
vs->absolute = absolute;
1756
}
1757
1766
-static void pointer_event(VncState *vs, int button_mask, int x, int y)
1758
+static void pointer_event(VncState *vs, uint8_t button_mask,
1759
+ uint16_t x, uint16_t y)
1760
{
1761
static uint32_t bmap[INPUT_BUTTON__MAX] = {
1762
[INPUT_BUTTON_LEFT] = 0x01,
@@ -1841,7 +1834,7 @@ static void kbd_leds(Notifier *notifier, void *data)
1834
}
1835
}
1836
1844
-static void do_key_event(VncState *vs, int down, int keycode, int sym)
1837
+static void do_key_event(VncState *vs, int down, int keycode, uint32_t sym)
1838
{
1839
unsigned int lnx = qemu_input_key_number_to_linux(keycode);
1840
@@ -2019,7 +2012,7 @@ static const char *code2name(int keycode)
2012
return QKeyCode_str(qemu_input_key_number_to_qcode(keycode));
2013
}
2014
2022
-static void key_event(VncState *vs, int down, uint32_t sym)
2015
+static void key_event(VncState *vs, bool down, uint32_t sym)
2016
{
2017
int keycode;
2018
int lsym = sym;
@@ -2034,8 +2027,8 @@ static void key_event(VncState *vs, int down, uint32_t sym)
2027
do_key_event(vs, down, keycode, sym);
2028
}
2029
2037
-static void ext_key_event(VncState *vs, int down,
2038
- uint32_t sym, uint16_t keycode)
2030
+static void ext_key_event(VncState *vs, bool down,
2031
+ uint32_t sym, uint32_t keycode)
2032
{
2033
/* if the user specifies a keyboard layout, always use it */
2034
if (keyboard_layout) {
@@ -2046,8 +2039,9 @@ static void ext_key_event(VncState *vs, int down,
2039
}
2040
}
2041
2049
-static void framebuffer_update_request(VncState *vs, int incremental,
2050
- int x, int y, int w, int h)
2042
+static void framebuffer_update_request(VncState *vs, uint8_t incremental,
2043
+ uint16_t x, uint16_t y,
2044
+ uint16_t w, uint16_t h)
2045
{
2046
if (incremental) {
2047
if (vs->update != VNC_STATE_UPDATE_FORCE) {
@@ -2250,10 +2244,11 @@ static void send_color_map(VncState *vs)
2244
vnc_unlock_output(vs);
2245
}
2246
2253
-static void set_pixel_format(VncState *vs, int bits_per_pixel,
2254
- int big_endian_flag, int true_color_flag,
2255
- int red_max, int green_max, int blue_max,
2256
- int red_shift, int green_shift, int blue_shift)
2247
+static void set_pixel_format(VncState *vs, uint8_t bits_per_pixel,
2248
+ uint8_t big_endian_flag, uint8_t true_color_flag,
2249
+ uint16_t red_max, uint16_t green_max,
2250
+ uint16_t blue_max, uint8_t red_shift,
2251
+ uint8_t green_shift, uint8_t blue_shift)
2252
{
2253
if (!true_color_flag) {
2254
/* Expose a reasonable default 256 color map */
@@ -2286,15 +2281,15 @@ static void set_pixel_format(VncState *vs, int bits_per_pixel,
2281
vs->client_pf.rmax = red_max ? red_max : 0xFF;
2282
vs->client_pf.rbits = ctpopl(red_max);
2283
vs->client_pf.rshift = red_shift;
2289
- vs->client_pf.rmask = red_max << red_shift;
2284
+ vs->client_pf.rmask = (uint32_t)red_max << red_shift;
2285
vs->client_pf.gmax = green_max ? green_max : 0xFF;
2286
vs->client_pf.gbits = ctpopl(green_max);
2287
vs->client_pf.gshift = green_shift;
2293
- vs->client_pf.gmask = green_max << green_shift;
2288
+ vs->client_pf.gmask = (uint32_t)green_max << green_shift;
2289
vs->client_pf.bmax = blue_max ? blue_max : 0xFF;
2290
vs->client_pf.bbits = ctpopl(blue_max);
2291
vs->client_pf.bshift = blue_shift;
2297
- vs->client_pf.bmask = blue_max << blue_shift;
2292
+ vs->client_pf.bmask = (uint32_t)blue_max << blue_shift;
2293
vs->client_pf.bits_per_pixel = bits_per_pixel;
2294
vs->client_pf.bytes_per_pixel = bits_per_pixel / 8;
2295
vs->client_pf.depth = bits_per_pixel == 32 ? 24 : bits_per_pixel;