diff mbox series

[1/9] hw/sysbus: Use sizeof(BusState) in main_system_bus_create()

Message ID 20250125181343.59151-2-philmd@linaro.org (mailing list archive)
State New
Headers show
Series hw/sysbus/platform-bus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE | expand

Commit Message

Philippe Mathieu-Daudé Jan. 25, 2025, 6:13 p.m. UTC
Rather than using the obscure system_bus_info.instance_size,
directly use sizeof(BusState).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/core/sysbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson Jan. 26, 2025, 9:42 p.m. UTC | #1
On 1/25/25 10:13, Philippe Mathieu-Daudé wrote:
> Rather than using the obscure system_bus_info.instance_size,
> directly use sizeof(BusState).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/core/sysbus.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Nice.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
CLEMENT MATHIEU--DRIF Jan. 27, 2025, 6:21 a.m. UTC | #2
Reviewed-by: Clément Mathieu--Drif<clement.mathieu--drif@eviden.com>



On 25/01/2025 19:13, Philippe Mathieu-Daudé wrote:
> Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
>
>
> Rather than using the obscure system_bus_info.instance_size,
> directly use sizeof(BusState).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/core/sysbus.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 9355849ff0a..f713bbfe04f 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -323,8 +323,8 @@ static void main_system_bus_create(void)
>        * assign main_system_bus before qbus_init()
>        * in order to make "if (bus != sysbus_get_default())" work
>        */
> -    main_system_bus = g_malloc0(system_bus_info.instance_size);
> -    qbus_init(main_system_bus, system_bus_info.instance_size,
> +    main_system_bus = g_new0(BusState, 1);
> +    qbus_init(main_system_bus, sizeof(BusState),
>                 TYPE_SYSTEM_BUS, NULL, "main-system-bus");
>       OBJECT(main_system_bus)->free = g_free;
>   }
> --
> 2.47.1
>
diff mbox series

Patch

diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 9355849ff0a..f713bbfe04f 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -323,8 +323,8 @@  static void main_system_bus_create(void)
      * assign main_system_bus before qbus_init()
      * in order to make "if (bus != sysbus_get_default())" work
      */
-    main_system_bus = g_malloc0(system_bus_info.instance_size);
-    qbus_init(main_system_bus, system_bus_info.instance_size,
+    main_system_bus = g_new0(BusState, 1);
+    qbus_init(main_system_bus, sizeof(BusState),
               TYPE_SYSTEM_BUS, NULL, "main-system-bus");
     OBJECT(main_system_bus)->free = g_free;
 }