@samitouri / QOSamiQemu / commits / 9e839f1ab7

ui/console: remove console_ch_t typedef and console_write_ch()

Since commit e2f82e924d05 ("console: purge curses bits from console.h"), console_ch_t is a plain uint32_t typedef and console_write_ch() is a trivial assignment (*dest = ch). These abstractions were originally needed because console_ch_t was the curses chtype when CONFIG_CURSES was enabled, and console_write_ch() handled VGA-to-curses character translation. That commit moved the curses logic into curses_update(), making the typedef and helper dead abstractions. Replace console_ch_t with uint32_t and console_write_ch() calls with direct assignments. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Apr 28, 2026 at 12:59 UTC 9e839f1ab704e6d172ecaddbf2f95b2e8aedfe0a
9 files changed +26 -34
hw/display/jazz_led.c
+5 -5
@@ -228,7 +228,7 @@ static void jazz_led_invalidate_display(void *opaque)
228 s->state |= REDRAW_SEGMENTS | REDRAW_BACKGROUND;
229 }
230
231 -static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
231 +static void jazz_led_text_update(void *opaque, uint32_t *chardata)
232 {
233 LedState *s = opaque;
234 char buf[3];
@@ -238,10 +238,10 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
238
239 /* TODO: draw the segments */
240 snprintf(buf, 3, "%02hhx", s->segments);
241 - console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
242 - QEMU_COLOR_BLACK, 1));
243 - console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,
244 - QEMU_COLOR_BLACK, 1));
241 + *chardata++ = ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
242 + QEMU_COLOR_BLACK, 1);
243 + *chardata++ = ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,
244 + QEMU_COLOR_BLACK, 1);
245
246 dpy_text_update(s->con, 0, 0, 2, 1);
247 }
hw/display/vga.c
+8 -8
@@ -1901,13 +1901,13 @@ static void vga_reset(void *opaque)
1901 ((v & 0x00000800) << 10) | ((v & 0x00007000) >> 1))
1902 /* relay text rendering to the display driver
1903 * instead of doing a full vga_update_display() */
1904 -static void vga_update_text(void *opaque, console_ch_t *chardata)
1904 +static void vga_update_text(void *opaque, uint32_t *chardata)
1905 {
1906 VGACommonState *s = opaque;
1907 int graphic_mode, i, cursor_offset, cursor_visible;
1908 int cw, cheight, width, height, size, c_min, c_max;
1909 uint32_t *src;
1910 - console_ch_t *dst, val;
1910 + uint32_t *dst, val;
1911 char msg_buffer[80];
1912 int full_update = 0;
1913
@@ -2007,14 +2007,14 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
2007
2008 if (full_update) {
2009 for (i = 0; i < size; src ++, dst ++, i ++)
2010 - console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
2010 + *dst = VMEM2CHTYPE(le32_to_cpu(*src));
2011
2012 dpy_text_update(s->con, 0, 0, width, height);
2013 } else {
2014 c_max = 0;
2015
2016 for (i = 0; i < size; src ++, dst ++, i ++) {
2017 - console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
2017 + val = VMEM2CHTYPE(le32_to_cpu(*src));
2018 if (*dst != val) {
2019 *dst = val;
2020 c_max = i;
@@ -2023,7 +2023,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
2023 }
2024 c_min = i;
2025 for (; i < size; src ++, dst ++, i ++) {
2026 - console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
2026 + val = VMEM2CHTYPE(le32_to_cpu(*src));
2027 if (*dst != val) {
2028 *dst = val;
2029 c_max = i;
@@ -2061,14 +2061,14 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
2061 dpy_text_resize(s->con, s->last_width, height);
2062
2063 for (dst = chardata, i = 0; i < s->last_width * height; i ++)
2064 - console_write_ch(dst ++, ' ');
2064 + *dst++ = ' ';
2065
2066 size = strlen(msg_buffer);
2067 width = (s->last_width - size) / 2;
2068 dst = chardata + s->last_width + width;
2069 for (i = 0; i < size; i ++)
2070 - console_write_ch(dst ++, ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
2071 - QEMU_COLOR_BLACK, 1));
2070 + *dst++ = ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
2071 + QEMU_COLOR_BLACK, 1);
2072
2073 dpy_text_update(s->con, 0, 0, s->last_width, height);
2074 }
hw/display/virtio-gpu-base.c
+1 -1
@@ -88,7 +88,7 @@ static bool virtio_gpu_update_display(void *opaque)
88 return true;
89 }
90
91 -static void virtio_gpu_text_update(void *opaque, console_ch_t *chardata)
91 +static void virtio_gpu_text_update(void *opaque, uint32_t *chardata)
92 {
93 }
94
hw/display/virtio-vga.c
+1 -1
@@ -31,7 +31,7 @@ static bool virtio_vga_base_update_display(void *opaque)
31 }
32 }
33
34 -static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata)
34 +static void virtio_vga_base_text_update(void *opaque, uint32_t *chardata)
35 {
36 VirtIOVGABase *vvga = opaque;
37 VirtIOGPUBase *g = vvga->vgpu;
hw/display/vmware_vga.c
+1 -1
@@ -1184,7 +1184,7 @@ static void vmsvga_invalidate_display(void *opaque)
1184 s->invalidated = 1;
1185 }
1186
1187 -static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
1187 +static void vmsvga_text_update(void *opaque, uint32_t *chardata)
1188 {
1189 struct vmsvga_state_s *s = opaque;
1190
include/ui/console.h
+1 -8
@@ -336,13 +336,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx);
336
337 bool console_has_gl(QemuConsole *con);
338
339 -typedef uint32_t console_ch_t;
340 -
341 -static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
342 -{
343 - *dest = ch;
344 -}
345 -
339 enum {
340 GRAPHIC_FLAGS_NONE = 0,
341 /* require a console/display with GL callbacks */
@@ -377,7 +370,7 @@ void graphic_console_close(QemuConsole *con);
370 void graphic_hw_update(QemuConsole *con);
371 void graphic_hw_update_done(QemuConsole *con);
372 void graphic_hw_invalidate(QemuConsole *con);
380 -void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
373 +void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata);
374 void graphic_hw_gl_block(QemuConsole *con, bool block);
375
376 void qemu_console_early_init(void);
ui/console-vc.c
+5 -6
@@ -386,7 +386,7 @@ void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym)
386 vt100_keysym(&s->vt, keysym);
387 }
388
389 -static void text_console_update(void *opaque, console_ch_t *chardata)
389 +static void text_console_update(void *opaque, uint32_t *chardata)
390 {
391 QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
392 int i, j, src;
@@ -396,11 +396,10 @@ static void text_console_update(void *opaque, console_ch_t *chardata)
396 chardata += s->vt.text_y[0] * s->vt.width;
397 for (i = s->vt.text_y[0]; i <= s->vt.text_y[1]; i ++)
398 for (j = 0; j < s->vt.width; j++, src++) {
399 - console_write_ch(chardata ++,
400 - ATTR2CHTYPE(s->vt.cells[src].ch,
401 - s->vt.cells[src].t_attrib.fgcol,
402 - s->vt.cells[src].t_attrib.bgcol,
403 - s->vt.cells[src].t_attrib.bold));
399 + *chardata++ = ATTR2CHTYPE(s->vt.cells[src].ch,
400 + s->vt.cells[src].t_attrib.fgcol,
401 + s->vt.cells[src].t_attrib.bgcol,
402 + s->vt.cells[src].t_attrib.bold);
403 }
404 dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0],
405 s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_y[0]);
ui/console.c
+1 -1
@@ -210,7 +210,7 @@ void graphic_hw_invalidate(QemuConsole *con)
210 }
211 }
212
213 -void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
213 +void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata)
214 {
215 if (con && con->hw_ops->text_update) {
216 con->hw_ops->text_update(con->hw, chardata);
ui/curses.c
+3 -3
@@ -57,7 +57,7 @@ enum maybe_keycode {
57 };
58
59 static DisplayChangeListener *dcl;
60 -static console_ch_t *screen;
60 +static uint32_t *screen;
61 static WINDOW *screenpad = NULL;
62 static int width, height, gwidth, gheight, invalidate;
63 static int px, py, sminx, sminy, smaxx, smaxy;
@@ -68,7 +68,7 @@ static cchar_t *vga_to_curses;
68 static void curses_update(DisplayChangeListener *dcl,
69 int x, int y, int w, int h)
70 {
71 - console_ch_t *line;
71 + uint32_t *line;
72 g_autofree cchar_t *curses_line = g_new(cchar_t, width);
73 wchar_t wch[CCHARW_MAX];
74 attr_t attrs;
@@ -796,7 +796,7 @@ static void curses_display_init(DisplayState *ds, DisplayOptions *opts)
796 if (opts->u.curses.charset) {
797 font_charset = opts->u.curses.charset;
798 }
799 - screen = g_new0(console_ch_t, 160 * 100);
799 + screen = g_new0(uint32_t, 160 * 100);
800 vga_to_curses = g_new0(cchar_t, 256);
801 curses_setup();
802 curses_keyboard_setup();