ui: Clean up local variable shadowing

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230921121312.1301864-4-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2023-09-21 14:13:08 +02:00
parent 7f3de3f02f
commit e33e66b1b3
5 changed files with 22 additions and 24 deletions

View File

@ -930,8 +930,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win); GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
GdkRectangle geometry; GdkRectangle geometry;
int x = (int)motion->x_root; int xr = (int)motion->x_root;
int y = (int)motion->y_root; int yr = (int)motion->y_root;
gdk_monitor_get_geometry(monitor, &geometry); gdk_monitor_get_geometry(monitor, &geometry);
@ -942,13 +942,13 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
* may still be only half way across the screen. Without * may still be only half way across the screen. Without
* this warp, the server pointer would thus appear to hit * this warp, the server pointer would thus appear to hit
* an invisible wall */ * an invisible wall */
if (x <= geometry.x || x - geometry.x >= geometry.width - 1 || if (xr <= geometry.x || xr - geometry.x >= geometry.width - 1 ||
y <= geometry.y || y - geometry.y >= geometry.height - 1) { yr <= geometry.y || yr - geometry.y >= geometry.height - 1) {
GdkDevice *dev = gdk_event_get_device((GdkEvent *)motion); GdkDevice *dev = gdk_event_get_device((GdkEvent *)motion);
x = geometry.x + geometry.width / 2; xr = geometry.x + geometry.width / 2;
y = geometry.y + geometry.height / 2; yr = geometry.y + geometry.height / 2;
gdk_device_warp(dev, screen, x, y); gdk_device_warp(dev, screen, xr, yr);
s->last_set = FALSE; s->last_set = FALSE;
return FALSE; return FALSE;
} }

View File

@ -1081,15 +1081,16 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
} }
if (render_cursor) { if (render_cursor) {
int x, y; int ptr_x, ptr_y;
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
x = ssd->ptr_x; ptr_x = ssd->ptr_x;
y = ssd->ptr_y; ptr_y = ssd->ptr_y;
qemu_mutex_unlock(&ssd->lock); qemu_mutex_unlock(&ssd->lock);
egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb, egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb,
!y_0_top); !y_0_top);
egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb, egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb,
!y_0_top, x, y, 1.0, 1.0); !y_0_top, ptr_x, ptr_y, 1.0, 1.0);
glFlush(); glFlush();
} }

View File

@ -153,11 +153,12 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
} }
if (use_rle) { if (use_rle) {
ZRLE_PIXEL *ptr = data;
ZRLE_PIXEL *end = ptr + w * h;
ZRLE_PIXEL *run_start; ZRLE_PIXEL *run_start;
ZRLE_PIXEL pix; ZRLE_PIXEL pix;
ptr = data;
end = ptr + w * h;
while (ptr < end) { while (ptr < end) {
int len; int len;
int index = 0; int index = 0;
@ -198,7 +199,7 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
} }
} else if (use_palette) { /* no RLE */ } else if (use_palette) { /* no RLE */
int bppp; int bppp;
ZRLE_PIXEL *ptr = data; ptr = data;
/* packed pixels */ /* packed pixels */
@ -241,8 +242,6 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
#endif #endif
{ {
#ifdef ZRLE_COMPACT_PIXEL #ifdef ZRLE_COMPACT_PIXEL
ZRLE_PIXEL *ptr;
for (ptr = data; ptr < data + w * h; ptr++) { for (ptr = data; ptr < data + w * h; ptr++) {
ZRLE_WRITE_PIXEL(vs, *ptr); ZRLE_WRITE_PIXEL(vs, *ptr);
} }

View File

@ -86,8 +86,6 @@ int palette_put(VncPalette *palette, uint32_t color)
return 0; return 0;
} }
if (!entry) { if (!entry) {
VncPaletteEntry *entry;
entry = &palette->pool[palette->size]; entry = &palette->pool[palette->size];
entry->color = color; entry->color = color;
entry->idx = idx; entry->idx = idx;

View File

@ -1584,15 +1584,15 @@ static void vnc_jobs_bh(void *opaque)
*/ */
static int vnc_client_read(VncState *vs) static int vnc_client_read(VncState *vs)
{ {
size_t ret; size_t sz;
#ifdef CONFIG_VNC_SASL #ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF) if (vs->sasl.conn && vs->sasl.runSSF)
ret = vnc_client_read_sasl(vs); sz = vnc_client_read_sasl(vs);
else else
#endif /* CONFIG_VNC_SASL */ #endif /* CONFIG_VNC_SASL */
ret = vnc_client_read_plain(vs); sz = vnc_client_read_plain(vs);
if (!ret) { if (!sz) {
if (vs->disconnecting) { if (vs->disconnecting) {
vnc_disconnect_finish(vs); vnc_disconnect_finish(vs);
return -1; return -1;
@ -3118,8 +3118,8 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES, cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
server_stride); server_stride);
if (vd->guest.format != VNC_SERVER_FB_FORMAT) { if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
int width = pixman_image_get_width(vd->server); int w = pixman_image_get_width(vd->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width); tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, w);
} else { } else {
int guest_bpp = int guest_bpp =
PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb)); PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb));