@samitouri / QOSamiQemu / commits / ee56761607

hw/display/macfb: Constify macfb_mode_table[] array

macfb_mode_table[] is only read, never updated, so can be const. Update the call sites accordingly. Make the MacfbState::mode pointer to const. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260216213121.47122-3-philmd@linaro.org>

Philippe Mathieu-Daudé committed Feb 11, 2026 at 14:45 UTC ee567616072e2b9861e8fc67921ad30612bcaf47
3 files changed +7 -7
hw/display/macfb.c
+5 -5
@@ -100,7 +100,7 @@ static const MacFbSense macfb_sense_table[] = {
100 { MACFB_DISPLAY_SVGA, 0x7, 0x5 },
101 };
102
103 -static MacFbMode macfb_mode_table[] = {
103 +static const MacFbMode macfb_mode_table[] = {
104 { MACFB_DISPLAY_VGA, 1, 0x100, 0x71e, 640, 480, 0x400, 0x1000 },
105 { MACFB_DISPLAY_VGA, 2, 0x100, 0x70e, 640, 480, 0x400, 0x1000 },
106 { MACFB_DISPLAY_VGA, 4, 0x100, 0x706, 640, 480, 0x400, 0x1000 },
@@ -397,7 +397,7 @@ static void macfb_update_mode(MacfbState *s)
397
398 static void macfb_mode_write(MacfbState *s)
399 {
400 - MacFbMode *macfb_mode;
400 + const MacFbMode *macfb_mode;
401 int i;
402
403 for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
@@ -418,11 +418,11 @@ static void macfb_mode_write(MacfbState *s)
418 }
419 }
420
421 -static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
421 +static const MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
422 uint16_t width, uint16_t height,
423 uint8_t depth)
424 {
425 - MacFbMode *macfb_mode;
425 + const MacFbMode *macfb_mode;
426 int i;
427
428 for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
@@ -440,7 +440,7 @@ static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
440 static gchar *macfb_mode_list(void)
441 {
442 GString *list = g_string_new("");
443 - MacFbMode *macfb_mode;
443 + const MacFbMode *macfb_mode;
444 int i;
445
446 for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
hw/m68k/q800.c
+1 -1
@@ -255,7 +255,7 @@ static void q800_machine_init(MachineState *machine)
255 int32_t initrd_size;
256 uint8_t *prom;
257 int i, checksum;
258 - MacFbMode *macfb_mode;
258 + const MacFbMode *macfb_mode;
259 ram_addr_t ram_size = machine->ram_size;
260 const char *kernel_filename = machine->kernel_filename;
261 const char *initrd_filename = machine->initrd_filename;
include/hw/display/macfb.h
+1 -1
@@ -66,7 +66,7 @@ typedef struct MacfbState {
66 uint8_t type;
67
68 uint32_t regs[MACFB_NUM_REGS];
69 - MacFbMode *mode;
69 + const MacFbMode *mode;
70
71 QEMUTimer *vbl_timer;
72 qemu_irq irq;