[PATCH 2/8] hw/display/macfb: Constify macfb_mode_table[] array

Philippe Mathieu-Daudé posted 8 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 2/8] hw/display/macfb: Constify macfb_mode_table[] array
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
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>
---
 include/hw/display/macfb.h |  2 +-
 hw/display/macfb.c         | 10 +++++-----
 hw/m68k/q800.c             |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h
index 495dead44b5..cb7aac7a4dd 100644
--- a/include/hw/display/macfb.h
+++ b/include/hw/display/macfb.h
@@ -66,7 +66,7 @@ typedef struct MacfbState {
     uint8_t type;
 
     uint32_t regs[MACFB_NUM_REGS];
-    MacFbMode *mode;
+    const MacFbMode *mode;
 
     QEMUTimer *vbl_timer;
     qemu_irq irq;
diff --git a/hw/display/macfb.c b/hw/display/macfb.c
index 57ad8ad5587..8ef174dc6df 100644
--- a/hw/display/macfb.c
+++ b/hw/display/macfb.c
@@ -100,7 +100,7 @@ static const MacFbSense macfb_sense_table[] = {
     { MACFB_DISPLAY_SVGA, 0x7, 0x5 },
 };
 
-static MacFbMode macfb_mode_table[] = {
+static const MacFbMode macfb_mode_table[] = {
     { MACFB_DISPLAY_VGA, 1, 0x100, 0x71e, 640, 480, 0x400, 0x1000 },
     { MACFB_DISPLAY_VGA, 2, 0x100, 0x70e, 640, 480, 0x400, 0x1000 },
     { MACFB_DISPLAY_VGA, 4, 0x100, 0x706, 640, 480, 0x400, 0x1000 },
@@ -397,7 +397,7 @@ static void macfb_update_mode(MacfbState *s)
 
 static void macfb_mode_write(MacfbState *s)
 {
-    MacFbMode *macfb_mode;
+    const MacFbMode *macfb_mode;
     int i;
 
     for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
@@ -418,11 +418,11 @@ static void macfb_mode_write(MacfbState *s)
     }
 }
 
-static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
+static const MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
                                   uint16_t width, uint16_t height,
                                   uint8_t depth)
 {
-    MacFbMode *macfb_mode;
+    const MacFbMode *macfb_mode;
     int i;
 
     for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
@@ -440,7 +440,7 @@ static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
 static gchar *macfb_mode_list(void)
 {
     GString *list = g_string_new("");
-    MacFbMode *macfb_mode;
+    const MacFbMode *macfb_mode;
     int i;
 
     for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 25ddddb5d9f..4767eb4298f 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -255,7 +255,7 @@ static void q800_machine_init(MachineState *machine)
     int32_t initrd_size;
     uint8_t *prom;
     int i, checksum;
-    MacFbMode *macfb_mode;
+    const MacFbMode *macfb_mode;
     ram_addr_t ram_size = machine->ram_size;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
-- 
2.52.0


Re: [PATCH 2/8] hw/display/macfb: Constify macfb_mode_table[] array
Posted by Mark Cave-Ayland 1 month, 3 weeks ago
On 14/02/2026 02:12, Philippe Mathieu-Daudé wrote:

> 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>
> ---
>   include/hw/display/macfb.h |  2 +-
>   hw/display/macfb.c         | 10 +++++-----
>   hw/m68k/q800.c             |  2 +-
>   3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h
> index 495dead44b5..cb7aac7a4dd 100644
> --- a/include/hw/display/macfb.h
> +++ b/include/hw/display/macfb.h
> @@ -66,7 +66,7 @@ typedef struct MacfbState {
>       uint8_t type;
>   
>       uint32_t regs[MACFB_NUM_REGS];
> -    MacFbMode *mode;
> +    const MacFbMode *mode;
>   
>       QEMUTimer *vbl_timer;
>       qemu_irq irq;
> diff --git a/hw/display/macfb.c b/hw/display/macfb.c
> index 57ad8ad5587..8ef174dc6df 100644
> --- a/hw/display/macfb.c
> +++ b/hw/display/macfb.c
> @@ -100,7 +100,7 @@ static const MacFbSense macfb_sense_table[] = {
>       { MACFB_DISPLAY_SVGA, 0x7, 0x5 },
>   };
>   
> -static MacFbMode macfb_mode_table[] = {
> +static const MacFbMode macfb_mode_table[] = {
>       { MACFB_DISPLAY_VGA, 1, 0x100, 0x71e, 640, 480, 0x400, 0x1000 },
>       { MACFB_DISPLAY_VGA, 2, 0x100, 0x70e, 640, 480, 0x400, 0x1000 },
>       { MACFB_DISPLAY_VGA, 4, 0x100, 0x706, 640, 480, 0x400, 0x1000 },
> @@ -397,7 +397,7 @@ static void macfb_update_mode(MacfbState *s)
>   
>   static void macfb_mode_write(MacfbState *s)
>   {
> -    MacFbMode *macfb_mode;
> +    const MacFbMode *macfb_mode;
>       int i;
>   
>       for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
> @@ -418,11 +418,11 @@ static void macfb_mode_write(MacfbState *s)
>       }
>   }
>   
> -static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
> +static const MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
>                                     uint16_t width, uint16_t height,
>                                     uint8_t depth)
>   {
> -    MacFbMode *macfb_mode;
> +    const MacFbMode *macfb_mode;
>       int i;
>   
>       for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
> @@ -440,7 +440,7 @@ static MacFbMode *macfb_find_mode(MacfbDisplayType display_type,
>   static gchar *macfb_mode_list(void)
>   {
>       GString *list = g_string_new("");
> -    MacFbMode *macfb_mode;
> +    const MacFbMode *macfb_mode;
>       int i;
>   
>       for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) {
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index 25ddddb5d9f..4767eb4298f 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -255,7 +255,7 @@ static void q800_machine_init(MachineState *machine)
>       int32_t initrd_size;
>       uint8_t *prom;
>       int i, checksum;
> -    MacFbMode *macfb_mode;
> +    const MacFbMode *macfb_mode;
>       ram_addr_t ram_size = machine->ram_size;
>       const char *kernel_filename = machine->kernel_filename;
>       const char *initrd_filename = machine->initrd_filename;

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.


Re: [PATCH 2/8] hw/display/macfb: Constify macfb_mode_table[] array
Posted by Pierrick Bouvier 1 month, 3 weeks ago
On 2/13/26 6:12 PM, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   include/hw/display/macfb.h |  2 +-
>   hw/display/macfb.c         | 10 +++++-----
>   hw/m68k/q800.c             |  2 +-
>   3 files changed, 7 insertions(+), 7 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>